Browse Source

Merge branch 'master' into 3.next

ADmad 7 years ago
parent
commit
1eb4f6bd4d

+ 1 - 1
src/Controller/Component/FlashComponent.php

@@ -86,7 +86,7 @@ class FlashComponent extends Component
      */
     public function set($message, array $options = [])
     {
-        $options += $this->getConfig();
+        $options += (array)$this->getConfig();
 
         if ($message instanceof Exception) {
             if (!isset($options['params']['code'])) {

+ 1 - 1
src/Database/Log/LoggingStatement.php

@@ -78,7 +78,7 @@ class LoggingStatement extends StatementDecorator
      */
     protected function _log($query, $params, $startTime)
     {
-        $query->took = round((microtime(true) - $startTime) * 1000, 0);
+        $query->took = (int)round((microtime(true) - $startTime) * 1000, 0);
         $query->params = $params ?: $this->_compiledParams;
         $query->query = $this->queryString;
         $this->getLogger()->log($query);

+ 1 - 1
src/Database/Schema/TableSchema.php

@@ -780,7 +780,7 @@ class TableSchema implements TableSchemaInterface, SqlGeneratorInterface
     {
         deprecationWarning(
             'TableSchema::temporary() is deprecated. ' .
-            'Use TableSchema::setTemporary()/getTemporary() instead.'
+            'Use TableSchema::setTemporary()/isTemporary() instead.'
         );
         if ($temporary !== null) {
             return $this->setTemporary($temporary);

+ 1 - 0
src/Database/SchemaCache.php

@@ -93,6 +93,7 @@ class SchemaCache
      *
      * @param \Cake\Database\Connection $connection Connection object
      * @return \Cake\Database\Schema\Collection|\Cake\Database\Schema\CachedCollection
+     * @throws \RuntimeException If given connection object is not compatible with schema caching
      */
     public function getSchema(Connection $connection)
     {

+ 1 - 1
src/Datasource/QueryTrait.php

@@ -61,7 +61,7 @@ trait QueryTrait
     /**
      * A query cacher instance if this query has caching enabled.
      *
-     * @var \Cake\Datasource\QueryCacher
+     * @var \Cake\Datasource\QueryCacher|null
      */
     protected $_cache;
 

+ 3 - 1
src/Datasource/RepositoryInterface.php

@@ -18,8 +18,10 @@ namespace Cake\Datasource;
  * Describes the methods that any class representing a data storage should
  * comply with.
  *
- * @method $this setAlias($alias)
+ * @method $this setAlias(string $alias)
  * @method string getAlias()
+ * @method $this setRegistryAlias(string $alias)
+ * @method string getRegistryAlias()
  */
 interface RepositoryInterface
 {

+ 1 - 1
src/Event/EventDispatcherTrait.php

@@ -24,7 +24,7 @@ trait EventDispatcherTrait
      * Instance of the Cake\Event\EventManager this object is using
      * to dispatch inner events.
      *
-     * @var \Cake\Event\EventManager
+     * @var \Cake\Event\EventManagerInterface|\Cake\Event\EventManager
      */
     protected $_eventManager;
 

+ 1 - 1
src/Http/Client.php

@@ -197,7 +197,7 @@ class Client
     /**
      * Get the cookies stored in the Client.
      *
-     * @return \Cake\Http\Client\CookieCollection
+     * @return \Cake\Http\Cookie\CookieCollection
      */
     public function cookies()
     {

+ 4 - 1
src/Http/ControllerFactory.php

@@ -43,7 +43,10 @@ class ControllerFactory
             $this->missingController($request);
         }
 
-        return $reflection->newInstance($request, $response);
+        /** @var \Cake\Controller\Controller $controller */
+        $controller = $reflection->newInstance($request, $response);
+
+        return $controller;
     }
 
     /**

+ 3 - 1
src/Http/Response.php

@@ -2718,7 +2718,9 @@ class Response implements ResponseInterface
         }
 
         $bufferSize = 8192;
-        set_time_limit(0);
+        if (strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
+            set_time_limit(0);
+        }
         session_write_close();
         while (!feof($file->handle)) {
             if (!$this->_isActive()) {

+ 1 - 1
src/Http/Server.php

@@ -167,7 +167,7 @@ class Server implements EventDispatcherInterface
     /**
      * Get the application's event manager or the global one.
      *
-     * @return \Cake\Event\EventManagerInterface
+     * @return \Cake\Event\EventManager
      */
     public function getEventManager()
     {

+ 1 - 1
src/Http/Session.php

@@ -228,7 +228,7 @@ class Session
             $this->engine($class, $config['handler']);
         }
 
-        $this->_lifetime = ini_get('session.gc_maxlifetime');
+        $this->_lifetime = (int)ini_get('session.gc_maxlifetime');
         $this->_isCLI = (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg');
         session_register_shutdown();
     }

+ 1 - 1
src/Http/Session/DatabaseSession.php

@@ -62,7 +62,7 @@ class DatabaseSession implements SessionHandlerInterface
             $this->_table = $tableLocator->get($config['model']);
         }
 
-        $this->_timeout = ini_get('session.gc_maxlifetime');
+        $this->_timeout = (int)ini_get('session.gc_maxlifetime');
     }
 
     /**

+ 1 - 1
src/I18n/DateFormatTrait.php

@@ -156,7 +156,7 @@ trait DateFormatTrait
      * in which the date will be displayed. The timezone stored for this object will not
      * be changed.
      * @param string|null $locale The locale name in which the date should be displayed (e.g. pt-BR)
-     * @return string Formatted and translated date string
+     * @return string|int Formatted and translated date string
      */
     public function i18nFormat($format = null, $timezone = null, $locale = null)
     {

+ 3 - 3
src/Mailer/Email.php

@@ -1195,10 +1195,10 @@ class Email implements JsonSerializable, Serializable
         }
         if ($this->_messageId !== false) {
             if ($this->_messageId === true) {
-                $headers['Message-ID'] = '<' . str_replace('-', '', Text::uuid()) . '@' . $this->_domain . '>';
-            } else {
-                $headers['Message-ID'] = $this->_messageId;
+                $this->_messageId = '<' . str_replace('-', '', Text::uuid()) . '@' . $this->_domain . '>';
             }
+
+            $headers['Message-ID'] = $this->_messageId;
         }
 
         if ($this->_priority) {

+ 1 - 1
src/ORM/ResultSet.php

@@ -65,7 +65,7 @@ class ResultSet implements ResultSetInterface
     /**
      * Default table instance
      *
-     * @var \Cake\ORM\Table
+     * @var \Cake\ORM\Table|\Cake\Datasource\RepositoryInterface
      */
     protected $_defaultTable;
 

+ 1 - 1
src/ORM/Table.php

@@ -494,7 +494,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
     /**
      * Sets the connection instance.
      *
-     * @param \Cake\Database\Connection|\Cake\Datasource\ConnectionInterface $connection The connection instance
+     * @param \Cake\Database\Connection $connection The connection instance
      * @return $this
      */
     public function setConnection(ConnectionInterface $connection)

+ 1 - 1
src/Shell/ServerShell.php

@@ -82,7 +82,7 @@ class ServerShell extends Shell
             $this->_host = $this->param('host');
         }
         if ($this->param('port')) {
-            $this->_port = $this->param('port');
+            $this->_port = (int)$this->param('port');
         }
         if ($this->param('document_root')) {
             $this->_documentRoot = $this->param('document_root');

+ 4 - 1
src/TestSuite/MiddlewareDispatcher.php

@@ -68,6 +68,7 @@ class MiddlewareDispatcher
      * @param string|null $class The application class name. Defaults to App\Application.
      * @param array|null $constructorArgs The constructor arguments for your application class.
      *   Defaults to `['./config']`
+     * @throws \LogicException If it cannot load class for use in integration testing.
      */
     public function __construct($test, $class = null, $constructorArgs = null)
     {
@@ -77,7 +78,9 @@ class MiddlewareDispatcher
 
         try {
             $reflect = new ReflectionClass($this->_class);
-            $this->app = $reflect->newInstanceArgs($this->_constructorArgs);
+            /** @var \Cake\Core\HttpApplicationInterface $app */
+            $app = $reflect->newInstanceArgs($this->_constructorArgs);
+            $this->app = $app;
         } catch (ReflectionException $e) {
             throw new LogicException(sprintf('Cannot load "%s" for use in integration testing.', $this->_class));
         }

+ 1 - 1
src/View/ViewVarsTrait.php

@@ -29,7 +29,7 @@ trait ViewVarsTrait
     /**
      * The name of default View class.
      *
-     * @var string
+     * @var string|null
      * @deprecated 3.1.0 Use `$this->viewBuilder()->getClassName()`/`$this->viewBuilder()->setClassName()` instead.
      */
     public $viewClass;

+ 1 - 1
src/View/Widget/DateTimeWidget.php

@@ -267,7 +267,7 @@ class DateTimeWidget implements WidgetInterface
         }
 
         if (isset($options['minute']['interval'])) {
-            $change = $this->_adjustValue($date->format('i'), $options['minute']);
+            $change = $this->_adjustValue((int)$date->format('i'), $options['minute']);
             $date->modify($change > 0 ? "+$change minutes" : "$change minutes");
         }
 

+ 1 - 5
tests/TestCase/Controller/ControllerTest.php

@@ -300,11 +300,7 @@ class ControllerTest extends TestCase
         $controller->Bar = true;
         $this->assertTrue($controller->Bar);
 
-        if (class_exists(Notice::class)) {
-            $this->expectException(Notice::class);
-        } else {
-            $this->expectException(\PHPUnit_Framework_Error_Notice::class);
-        }
+        $this->expectException(Notice::class);
         $this->expectExceptionMessage(sprintf(
             'Undefined property: Controller::$Foo in %s on line %s',
             __FILE__,

+ 9 - 0
tests/TestCase/Mailer/EmailTest.php

@@ -620,6 +620,15 @@ class EmailTest extends TestCase
         $this->assertSame('<my-email@localhost>', $result);
     }
 
+    public function testAutoMessageIdIsIdempotent()
+    {
+        $headers = $this->Email->getHeaders();
+        $this->assertArrayHasKey('Message-ID', $headers);
+
+        $regeneratedHeaders = $this->Email->getHeaders();
+        $this->assertSame($headers['Message-ID'], $regeneratedHeaders['Message-ID']);
+    }
+
     /**
      * @return void
      */

+ 2 - 1
tests/phpunit_aliases.php

@@ -4,7 +4,7 @@ if (class_exists('PHPUnit_Runner_Version')) {
         trigger_error(sprintf('Your PHPUnit Version must be at least 5.7.0 to use CakePHP Testsuite, found %s', \PHPUnit_Runner_Version::id()), E_USER_ERROR);
     }
 
-    if (!class_exists('PHPUnit_Framework_Test') && class_exists('PHPUnit_Framework_TestCase')) {
+    if (!class_exists('PHPUnit\Runner\Version')) {
         class_alias('PHPUnit_Framework_Constraint', 'PHPUnit\Framework\Constraint\Constraint');
         class_alias('PHPUnit_Framework_Test', 'PHPUnit\Framework\Test');
         class_alias('PHPUnit_Framework_AssertionFailedError', 'PHPUnit\Framework\AssertionFailedError');
@@ -12,6 +12,7 @@ if (class_exists('PHPUnit_Runner_Version')) {
         class_alias('PHPUnit_Framework_TestResult', 'PHPUnit\Framework\TestResult');
         class_alias('PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error');
         class_alias('PHPUnit_Framework_Error_Deprecated', 'PHPUnit\Framework\Error\Deprecated');
+        class_alias('PHPUnit_Framework_Error_Notice', 'PHPUnit\Framework\Error\Notice');
         class_alias('PHPUnit_Framework_Error_Warning', 'PHPUnit\Framework\Error\Warning');
         class_alias('PHPUnit_Framework_ExpectationFailedException', 'PHPUnit\Framework\ExpectationFailedException');
     }