Browse Source

Revert "Merge pull request #11440 from cakephp/fix-build"

This reverts commit 58dd59f9e59ff1375a843cac51a15f7a28386600, reversing
changes made to 701114c5cabd4818adc7df3bfdccb20e195acf28.
chinpei215 8 years ago
parent
commit
ffb4f9f53e
2 changed files with 5 additions and 12 deletions
  1. 3 11
      src/Collection/Collection.php
  2. 2 1
      tests/TestCase/Collection/CollectionTest.php

+ 3 - 11
src/Collection/Collection.php

@@ -73,25 +73,17 @@ class Collection extends IteratorIterator implements CollectionInterface, Serial
     }
 
     /**
-     * Dynamic method handler
+     * Throws an exception.
      *
-     * Collections do not allow access to methods of the inner iterator,
-     * if that iterator is one of the PHP base classes as many of
-     * these methods allow in-place mutation which breaks the immutability
-     * Collection tries to provide.
+     * Collection doesn't permit access to methods of the inner iterator.
      *
      * @param string $name Method name.
      * @param array $args Method arguments.
-     * @return mixed
+     * @return void
      * @throws \BadMethodCallException
      */
     public function __call($name, $args)
     {
-        if (!method_exists(ArrayIterator::class, $name)) {
-            $inner = $this->getInnerIterator();
-
-            return call_user_func_array([$inner, $name], $args);
-        }
         throw new BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $name));
     }
 

+ 2 - 1
tests/TestCase/Collection/CollectionTest.php

@@ -2547,7 +2547,7 @@ class CollectionTest extends TestCase
         $this->assertTrue(method_exists($iterator, 'checkValues'));
         $this->assertTrue($iterator->checkValues());
 
-        // We need to perform at least two collection operation to trigger the issue.
+        //We need to perform at least two collection operation to trigger the issue.
         $newIterator = $iterator
             ->filter(function ($item) {
                 return $item < 5;
@@ -2556,6 +2556,7 @@ class CollectionTest extends TestCase
                 return $item > 2;
             });
 
+        $this->assertTrue(method_exists($newIterator, 'checkValues'), 'Our method has gone missing!');
         $this->assertTrue($newIterator->checkValues());
         $this->assertCount(3, $newIterator->toArray());
     }