Browse Source

Revert "Disable access to methods of inner iterator of Collection"

This reverts commit 661ea328a1124ebc8185de70152e20cc0f80c912.

Conflicts:
	tests/TestCase/Collection/CollectionTest.php
chinpei215 8 years ago
parent
commit
04fcd629c2
1 changed files with 6 additions and 7 deletions
  1. 6 7
      src/Collection/Collection.php

+ 6 - 7
src/Collection/Collection.php

@@ -15,9 +15,9 @@
 namespace Cake\Collection;
 
 use ArrayIterator;
-use BadMethodCallException;
 use InvalidArgumentException;
 use IteratorIterator;
+use LogicException;
 use Serializable;
 use Traversable;
 
@@ -75,16 +75,15 @@ class Collection extends IteratorIterator implements CollectionInterface, Serial
     /**
      * Throws an exception.
      *
-     * Collection doesn't permit access to methods of the inner iterator.
+     * Issuing a count on a Collection can have many side effects, some making the
+     * Collection unusable after the count operation.
      *
-     * @param string $name Method name.
-     * @param array $args Method arguments.
      * @return void
-     * @throws \BadMethodCallException
+     * @throws \LogicException
      */
-    public function __call($name, $args)
+    public function count()
     {
-        throw new BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $name));
+        throw new LogicException('You cannot issue a count on a Collection.');
     }
 
     /**