Browse Source

Merge branch '4.next' into 5.0

Corey Taylor 4 years ago
parent
commit
29db62dc02

+ 3 - 0
src/Collection/Iterator/BufferedIterator.php

@@ -18,6 +18,7 @@ namespace Cake\Collection\Iterator;
 
 use Cake\Collection\Collection;
 use Countable;
+use ReturnTypeWillChange;
 use SplDoublyLinkedList;
 
 /**
@@ -86,6 +87,7 @@ class BufferedIterator extends Collection implements Countable
      *
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function key()
     {
         return $this->_key;
@@ -96,6 +98,7 @@ class BufferedIterator extends Collection implements Countable
      *
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function current()
     {
         return $this->_current;

+ 2 - 0
src/Collection/Iterator/ExtractIterator.php

@@ -19,6 +19,7 @@ namespace Cake\Collection\Iterator;
 use ArrayIterator;
 use Cake\Collection\Collection;
 use Cake\Collection\CollectionInterface;
+use ReturnTypeWillChange;
 use Traversable;
 
 /**
@@ -68,6 +69,7 @@ class ExtractIterator extends Collection
      *
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function current()
     {
         $extractor = $this->_extractor;

+ 2 - 0
src/Collection/Iterator/InsertIterator.php

@@ -17,6 +17,7 @@ declare(strict_types=1);
 namespace Cake\Collection\Iterator;
 
 use Cake\Collection\Collection;
+use ReturnTypeWillChange;
 
 /**
  * This iterator will insert values into a property of each of the records returned.
@@ -101,6 +102,7 @@ class InsertIterator extends Collection
      *
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function current()
     {
         $row = parent::current();

+ 1 - 1
src/Collection/Iterator/NestIterator.php

@@ -51,7 +51,7 @@ class NestIterator extends Collection implements RecursiveIterator
      *
      * @return \RecursiveIterator
      */
-    public function getChildren()
+    public function getChildren(): RecursiveIterator
     {
         $property = $this->_propertyExtractor($this->_nestKey);
 

+ 1 - 1
src/Collection/Iterator/NoChildrenIterator.php

@@ -41,7 +41,7 @@ class NoChildrenIterator extends Collection implements RecursiveIterator
      *
      * @return \RecursiveIterator
      */
-    public function getChildren()
+    public function getChildren(): RecursiveIterator
     {
         return new static([]);
     }

+ 2 - 0
src/Collection/Iterator/ReplaceIterator.php

@@ -19,6 +19,7 @@ namespace Cake\Collection\Iterator;
 use ArrayIterator;
 use Cake\Collection\Collection;
 use Cake\Collection\CollectionInterface;
+use ReturnTypeWillChange;
 use Traversable;
 
 /**
@@ -65,6 +66,7 @@ class ReplaceIterator extends Collection
      *
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function current()
     {
         $callback = $this->_callback;

+ 2 - 0
src/Collection/Iterator/TreePrinter.php

@@ -20,6 +20,7 @@ use Cake\Collection\CollectionInterface;
 use Cake\Collection\CollectionTrait;
 use RecursiveIterator;
 use RecursiveIteratorIterator;
+use ReturnTypeWillChange;
 
 /**
  * Iterator for flattening elements in a tree structure while adding some
@@ -87,6 +88,7 @@ class TreePrinter extends RecursiveIteratorIterator implements CollectionInterfa
      *
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function key()
     {
         $extractor = $this->_key;

+ 1 - 1
src/Collection/Iterator/UnfoldIterator.php

@@ -77,7 +77,7 @@ class UnfoldIterator extends IteratorIterator implements RecursiveIterator
      *
      * @return \RecursiveIterator
      */
-    public function getChildren()
+    public function getChildren(): RecursiveIterator
     {
         $current = $this->current();
         $key = $this->key();

+ 2 - 0
src/Database/Query.php

@@ -28,6 +28,7 @@ use Cake\Database\Statement\CallbackStatement;
 use Closure;
 use InvalidArgumentException;
 use IteratorAggregate;
+use ReturnTypeWillChange;
 use RuntimeException;
 
 /**
@@ -1932,6 +1933,7 @@ class Query implements ExpressionInterface, IteratorAggregate
      * @return \Cake\Database\StatementInterface
      * @psalm-suppress ImplementedReturnTypeMismatch
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         if ($this->_iterator === null || $this->_dirty) {

+ 3 - 0
src/Database/Statement/BufferedStatement.php

@@ -20,6 +20,7 @@ use Cake\Database\DriverInterface;
 use Cake\Database\StatementInterface;
 use Cake\Database\TypeConverterTrait;
 use Iterator;
+use ReturnTypeWillChange;
 
 /**
  * A statement decorator that implements buffered results.
@@ -281,6 +282,7 @@ class BufferedStatement implements Iterator, StatementInterface
      *
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function key()
     {
         return $this->index;
@@ -291,6 +293,7 @@ class BufferedStatement implements Iterator, StatementInterface
      *
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function current()
     {
         return $this->buffer[$this->index];

+ 2 - 0
src/Database/Statement/StatementDecorator.php

@@ -21,6 +21,7 @@ use Cake\Database\StatementInterface;
 use Cake\Database\TypeConverterTrait;
 use Countable;
 use IteratorAggregate;
+use ReturnTypeWillChange;
 
 /**
  * Represents a database statement. Statements contains queries that can be
@@ -282,6 +283,7 @@ class StatementDecorator implements StatementInterface, Countable, IteratorAggre
      * @return \Cake\Database\StatementInterface
      * @psalm-suppress ImplementedReturnTypeMismatch
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         if (!$this->_hasExecuted) {

+ 1 - 1
src/Database/Type/DateTimeType.php

@@ -321,7 +321,7 @@ class DateTimeType extends BaseType implements BatchCastingInterface
                 return null;
             }
 
-            if (ctype_digit($value)) {
+            if (is_int($value) || (is_string($value) && ctype_digit($value))) {
                 /** @var \Datetime|\DateTimeImmutable $dateTime */
                 $dateTime = new $class('@' . $value);
 

+ 2 - 0
src/Datasource/EntityTrait.php

@@ -21,6 +21,7 @@ use Cake\ORM\Entity;
 use Cake\Utility\Hash;
 use Cake\Utility\Inflector;
 use InvalidArgumentException;
+use ReturnTypeWillChange;
 use Traversable;
 
 /**
@@ -587,6 +588,7 @@ trait EntityTrait
      * @param string $offset The offset to get.
      * @return mixed
      */
+    #[ReturnTypeWillChange]
     public function &offsetGet($offset)
     {
         return $this->get($offset);

+ 2 - 0
src/Event/EventList.php

@@ -18,6 +18,7 @@ namespace Cake\Event;
 
 use ArrayAccess;
 use Countable;
+use ReturnTypeWillChange;
 
 /**
  * The Event List
@@ -71,6 +72,7 @@ class EventList implements ArrayAccess, Countable
      * @param mixed $offset The offset to retrieve.
      * @return mixed Can return all value types.
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         if ($this->offsetExists($offset)) {

+ 5 - 3
src/ORM/Association/BelongsToMany.php

@@ -721,10 +721,12 @@ class BelongsToMany extends Association
     protected function _saveTarget(EntityInterface $parentEntity, array $entities, $options)
     {
         $joinAssociations = false;
-        if (!empty($options['associated'][$this->_junctionProperty]['associated'])) {
-            $joinAssociations = $options['associated'][$this->_junctionProperty]['associated'];
+        if (isset($options['associated']) && is_array($options['associated'])) {
+            if (!empty($options['associated'][$this->_junctionProperty]['associated'])) {
+                $joinAssociations = $options['associated'][$this->_junctionProperty]['associated'];
+            }
+            unset($options['associated'][$this->_junctionProperty]);
         }
-        unset($options['associated'][$this->_junctionProperty]);
 
         $table = $this->getTarget();
         $original = $entities;

+ 2 - 0
src/ORM/ResultSet.php

@@ -22,6 +22,7 @@ use Cake\Database\Exception\DatabaseException;
 use Cake\Database\StatementInterface;
 use Cake\Datasource\EntityInterface;
 use Cake\Datasource\ResultSetInterface;
+use ReturnTypeWillChange;
 use SplFixedArray;
 
 /**
@@ -184,6 +185,7 @@ class ResultSet implements ResultSetInterface
      *
      * @return object|array
      */
+    #[ReturnTypeWillChange]
     public function current()
     {
         return $this->_current;

+ 2 - 1
tests/TestCase/Collection/Iterator/InsertIteratorTest.php

@@ -16,6 +16,7 @@ declare(strict_types=1);
  */
 namespace Cake\Test\TestCase\Collection\Iterator;
 
+use ArrayIterator;
 use Cake\Collection\Iterator\InsertIterator;
 use Cake\TestSuite\TestCase;
 
@@ -52,7 +53,7 @@ class InsertIteratorTest extends TestCase
             'a' => ['name' => 'Derp', 'a' => ['deep' => ['thing' => 1]]],
             'b' => ['name' => 'Derpina', 'a' => ['deep' => ['thing' => 2]]],
         ];
-        $values = new \ArrayIterator([20, 21]);
+        $values = new ArrayIterator([20, 21]);
         $iterator = new InsertIterator($items, 'a.deep.path', $values);
         $result = $iterator->toArray();
         $expected = [

+ 8 - 4
tests/test_app/TestApp/Http/Client/Adapter/CakeStreamWrapper.php

@@ -3,7 +3,10 @@ declare(strict_types=1);
 
 namespace TestApp\Http\Client\Adapter;
 
-class CakeStreamWrapper implements \ArrayAccess
+use ArrayAccess;
+use ReturnTypeWillChange;
+
+class CakeStreamWrapper implements ArrayAccess
 {
     private $_stream;
 
@@ -60,7 +63,7 @@ class CakeStreamWrapper implements \ArrayAccess
     /**
      * @inheritDoc
      */
-    public function offsetExists($offset)
+    public function offsetExists($offset): bool
     {
         return isset($this->_data[$offset]);
     }
@@ -68,6 +71,7 @@ class CakeStreamWrapper implements \ArrayAccess
     /**
      * @inheritDoc
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->_data[$offset];
@@ -76,7 +80,7 @@ class CakeStreamWrapper implements \ArrayAccess
     /**
      * @inheritDoc
      */
-    public function offsetSet($offset, $value)
+    public function offsetSet($offset, $value): void
     {
         $this->_data[$offset] = $value;
     }
@@ -84,7 +88,7 @@ class CakeStreamWrapper implements \ArrayAccess
     /**
      * @inheritDoc
      */
-    public function offsetUnset($offset)
+    public function offsetUnset($offset): void
     {
         unset($this->_data[$offset]);
     }