Skip to content

Commit

Permalink
Revert "Merge pull request #11440 from cakephp/fix-build"
Browse files Browse the repository at this point in the history
This reverts commit 58dd59f, reversing
changes made to 701114c.
  • Loading branch information
chinpei215 committed Jan 18, 2018
1 parent c1f9b61 commit ffb4f9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
14 changes: 3 additions & 11 deletions src/Collection/Collection.php
Expand Up @@ -73,25 +73,17 @@ public function unserialize($collection)
}

/**
* 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));
}

Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Collection/CollectionTest.php
Expand Up @@ -2547,7 +2547,7 @@ public function testArrayIteratorExtend()
$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;
Expand All @@ -2556,6 +2556,7 @@ public function testArrayIteratorExtend()
return $item > 2;
});

$this->assertTrue(method_exists($newIterator, 'checkValues'), 'Our method has gone missing!');
$this->assertTrue($newIterator->checkValues());
$this->assertCount(3, $newIterator->toArray());
}
Expand Down

0 comments on commit ffb4f9f

Please sign in to comment.