Browse Source

Merge pull request #9792 from cakephp/3.next-remove-cloaking

Remove some cloaking for stricter null checks and fix a doc block.
Mark Story 9 years ago
parent
commit
a30ee07bbe

+ 8 - 8
src/Database/Query.php

@@ -94,24 +94,24 @@ class Query implements ExpressionInterface, IteratorAggregate
     /**
      * Statement object resulting from executing this query.
      *
-     * @var \Cake\Database\StatementInterface
+     * @var \Cake\Database\StatementInterface|null
      */
-    protected $_iterator;
+    protected $_iterator = null;
 
     /**
      * The object responsible for generating query placeholders and temporarily store values
      * associated to each of those.
      *
-     * @var \Cake\Database\ValueBinder
+     * @var \Cake\Database\ValueBinder|null
      */
-    protected $_valueBinder;
+    protected $_valueBinder = null;
 
     /**
      * Instance of functions builder object used for generating arbitrary SQL functions.
      *
-     * @var \Cake\Database\FunctionsBuilder
+     * @var \Cake\Database\FunctionsBuilder|null
      */
-    protected $_functionsBuilder;
+    protected $_functionsBuilder = null;
 
     /**
      * Boolean for tracking whether or not buffered results
@@ -1605,7 +1605,7 @@ class Query implements ExpressionInterface, IteratorAggregate
      */
     public function func()
     {
-        if (empty($this->_functionsBuilder)) {
+        if ($this->_functionsBuilder === null) {
             $this->_functionsBuilder = new FunctionsBuilder();
         }
 
@@ -1622,7 +1622,7 @@ class Query implements ExpressionInterface, IteratorAggregate
      */
     public function getIterator()
     {
-        if (empty($this->_iterator) || $this->_dirty) {
+        if ($this->_iterator === null || $this->_dirty) {
             $this->_iterator = $this->execute();
         }
 

+ 1 - 1
src/Event/EventDispatcherTrait.php

@@ -48,7 +48,7 @@ trait EventDispatcherTrait
     {
         if ($eventManager !== null) {
             $this->_eventManager = $eventManager;
-        } elseif (empty($this->_eventManager)) {
+        } elseif ($this->_eventManager === null) {
             $this->_eventManager = new EventManager();
         }
 

+ 4 - 4
src/Routing/Route/Route.php

@@ -52,7 +52,7 @@ class Route
     /**
      * The routes template string.
      *
-     * @var string
+     * @var string|null
      */
     public $template = null;
 
@@ -60,21 +60,21 @@ class Route
      * Is this route a greedy route?  Greedy routes have a `/*` in their
      * template
      *
-     * @var string
+     * @var bool
      */
     protected $_greedy = false;
 
     /**
      * The compiled route regular expression
      *
-     * @var string
+     * @var string|null
      */
     protected $_compiledRoute = null;
 
     /**
      * The name for a route.  Fetch with Route::getName();
      *
-     * @var string
+     * @var string|null
      */
     protected $_name = null;
 

+ 3 - 1
src/Routing/Router.php

@@ -458,7 +458,9 @@ class Router
     public static function getRequest($current = false)
     {
         if ($current) {
-            return end(static::$_requests);
+            $request = end(static::$_requests);
+
+            return $request ?: null;
         }
 
         return isset(static::$_requests[0]) ? static::$_requests[0] : null;

+ 2 - 2
src/TestSuite/IntegrationTestCase.php

@@ -945,7 +945,7 @@ abstract class IntegrationTestCase extends TestCase
      */
     public function assertCookie($expected, $name, $message = '')
     {
-        if (empty($this->_response)) {
+        if (!$this->_response) {
             $this->fail('Not response set, cannot assert cookies.');
         }
         $result = $this->_response->cookie($name);
@@ -990,7 +990,7 @@ abstract class IntegrationTestCase extends TestCase
      */
     public function assertCookieEncrypted($expected, $name, $encrypt = 'aes', $key = null, $message = '')
     {
-        if (empty($this->_response)) {
+        if (!$this->_response) {
             $this->fail('No response set, cannot assert cookies.');
         }
         $result = $this->_response->cookie($name);

+ 2 - 2
src/TestSuite/TestCase.php

@@ -35,7 +35,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
     /**
      * The class responsible for managing the creation, loading and removing of fixtures
      *
-     * @var \Cake\TestSuite\Fixture\FixtureManager
+     * @var \Cake\TestSuite\Fixture\FixtureManager|null
      */
     public $fixtureManager = null;
 
@@ -134,7 +134,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
      */
     public function loadFixtures()
     {
-        if (empty($this->fixtureManager)) {
+        if ($this->fixtureManager === null) {
             throw new Exception('No fixture manager to load the test fixture');
         }
         $args = func_get_args();

+ 1 - 1
src/View/View.php

@@ -334,7 +334,7 @@ class View implements EventDispatcherInterface
         $this->eventManager($eventManager);
         $this->request = $request ?: Router::getRequest(true);
         $this->response = $response ?: new Response();
-        if (empty($this->request)) {
+        if (!$this->request) {
             $this->request = new ServerRequest([
                 'base' => '',
                 'url' => '',