Browse Source

Fix strict typing errors.

ADmad 7 years ago
parent
commit
e2b8505cda

+ 1 - 1
src/Console/ConsoleInputArgument.php

@@ -186,7 +186,7 @@ class ConsoleInputArgument
         $option = $parent->addChild('argument');
         $option->addAttribute('name', $this->_name);
         $option->addAttribute('help', $this->_help);
-        $option->addAttribute('required', (int)$this->isRequired());
+        $option->addAttribute('required', (string)(int)$this->isRequired());
         $choices = $option->addChild('choices');
         foreach ($this->_choices as $valid) {
             $choices->addChild('choice', $valid);

+ 1 - 1
src/Console/ConsoleInputOption.php

@@ -253,7 +253,7 @@ class ConsoleInputOption
         }
         $option->addAttribute('short', $short);
         $option->addAttribute('help', $this->_help);
-        $option->addAttribute('boolean', (int)$this->_boolean);
+        $option->addAttribute('boolean', (string)(int)$this->_boolean);
         $option->addChild('default', $this->_default);
         $choices = $option->addChild('choices');
         foreach ($this->_choices as $valid) {

+ 2 - 2
src/Console/ConsoleOptionParser.php

@@ -418,9 +418,9 @@ class ConsoleOptionParser
         } else {
             $defaults = [
                 'name' => $name,
-                'short' => null,
+                'short' => '',
                 'help' => '',
-                'default' => null,
+                'default' => '',
                 'boolean' => false,
                 'choices' => [],
             ];

+ 3 - 1
src/Routing/Route/Route.php

@@ -617,7 +617,9 @@ class Route
         ) {
             $hostOptions += $context;
 
-            if (getservbyname($hostOptions['_scheme'], 'tcp') === $hostOptions['_port']) {
+            if ($hostOptions['_scheme'] &&
+                getservbyname($hostOptions['_scheme'], 'tcp') === $hostOptions['_port']
+            ) {
                 unset($hostOptions['_port']);
             }
         }

+ 2 - 1
tests/TestCase/Routing/Middleware/RoutingMiddlewareTest.php

@@ -502,6 +502,7 @@ class RoutingMiddlewareTest extends TestCase
     public function testCacheNotUsedIfCacheDisabled()
     {
         $cacheConfigName = '_cake_router_';
+        Cache::drop($cacheConfigName);
         Cache::disable();
         Cache::setConfig($cacheConfigName, [
             'engine' => 'File',
@@ -532,7 +533,7 @@ class RoutingMiddlewareTest extends TestCase
     public function testCacheConfigNotFound()
     {
         $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionMessage('The "notfound" cache configuration does not exist');
+        $this->expectExceptionMessage('The "notfound" cache configuration does not exist.');
 
         Cache::setConfig('_cake_router_', [
             'engine' => 'File',

+ 1 - 1
tests/TestCase/Routing/Route/DashedRouteTest.php

@@ -130,7 +130,7 @@ class DashedRouteTest extends TestCase
         $result = $route->match([
             'controller' => 'MyPosts',
             'action' => 'myView',
-            'id' => 1,
+            'id' => '1',
             'slug' => 'the-slug',
         ]);
         $this->assertEquals('/my-posts/my-view/the-slug-1', $result);

+ 1 - 1
tests/TestCase/Routing/Route/InflectedRouteTest.php

@@ -130,7 +130,7 @@ class InflectedRouteTest extends TestCase
         $result = $route->match([
             'controller' => 'MyPosts',
             'action' => 'my_view',
-            'id' => 1,
+            'id' => '1',
             'slug' => 'the-slug',
         ]);
         $this->assertEquals('/my_posts/my_view/the-slug-1', $result);

+ 12 - 12
tests/TestCase/Routing/Route/RouteTest.php

@@ -135,9 +135,9 @@ class RouteTest extends TestCase
         $result = $route->match([
             'controller' => 'Fighters',
             'action' => 'move',
-            'id' => 123,
-            'x' => 8,
-            'y' => 42,
+            'id' => '123',
+            'x' => '8',
+            'y' => '42',
         ]);
         $this->assertEquals('/fighters/123/move/8/42', $result);
     }
@@ -159,9 +159,9 @@ class RouteTest extends TestCase
         $result = $route->match([
             'controller' => 'Fighters',
             'action' => 'move',
-            'id' => 123,
-            'x' => 8,
-            'y' => 42,
+            'id' => '123',
+            'x' => '8',
+            'y' => '42',
         ]);
         $this->assertEquals('/fighters/123/move/8/42', $result);
 
@@ -174,9 +174,9 @@ class RouteTest extends TestCase
         $result = $route->match([
             'controller' => 'Images',
             'action' => 'view',
-            'id' => 123,
-            'x' => 8,
-            'y' => 42,
+            'id' => '123',
+            'x' => '8',
+            'y' => '42',
         ]);
         $this->assertEquals('/images/123/8x42', $result);
     }
@@ -256,9 +256,9 @@ class RouteTest extends TestCase
         $result = $route->match([
             'controller' => 'Fighters',
             'action' => 'move',
-            'id' => 123,
-            'x' => 8,
-            'y' => 9,
+            'id' => '123',
+            'x' => '8',
+            'y' => '9',
         ]);
         $this->assertEquals('/fighters/123/move/8/:y?y=9', $result);
     }

+ 2 - 2
tests/TestCase/Routing/RouteBuilderTest.php

@@ -726,7 +726,7 @@ class RouteBuilderTest extends TestCase
             'controller' => 'Articles',
             'action' => 'edit',
             '_method' => 'PUT',
-            'id' => 99,
+            'id' => '99',
         ]);
         $this->assertEquals('/api/articles/99', $url);
 
@@ -736,7 +736,7 @@ class RouteBuilderTest extends TestCase
             'action' => 'edit',
             '_method' => 'PUT',
             '_ext' => 'json',
-            'id' => 99,
+            'id' => '99',
         ]);
         $this->assertEquals('/api/articles/99.json', $url);
     }

+ 20 - 10
tests/TestCase/Routing/RouterTest.php

@@ -234,7 +234,7 @@ class RouterTest extends TestCase
             'controller' => 'Posts',
             'action' => 'view',
             '_method' => 'GET',
-            'id' => 10,
+            'id' => '10',
         ]);
         $expected = '/posts/10';
         $this->assertEquals($expected, $result);
@@ -243,15 +243,25 @@ class RouterTest extends TestCase
         $expected = '/posts';
         $this->assertEquals($expected, $result);
 
-        $result = Router::url(['controller' => 'Posts', 'action' => 'edit', '_method' => 'PUT', 'id' => 10]);
+        $result = Router::url(['controller' => 'Posts', 'action' => 'edit', '_method' => 'PUT', 'id' => '10']);
         $expected = '/posts/10';
         $this->assertEquals($expected, $result);
 
-        $result = Router::url(['controller' => 'Posts', 'action' => 'delete', '_method' => 'DELETE', 'id' => 10]);
+        $result = Router::url([
+            'controller' => 'Posts',
+            'action' => 'delete',
+            '_method' => 'DELETE',
+            'id' => '10'
+        ]);
         $expected = '/posts/10';
         $this->assertEquals($expected, $result);
 
-        $result = Router::url(['controller' => 'Posts', 'action' => 'edit', '_method' => 'PATCH', 'id' => 10]);
+        $result = Router::url([
+            'controller' => 'Posts',
+            'action' => 'edit',
+            '_method' => 'PATCH',
+            'id' => '10'
+        ]);
         $expected = '/posts/10';
         $this->assertEquals($expected, $result);
     }
@@ -630,8 +640,8 @@ class RouterTest extends TestCase
             'plugin' => 'shows',
             'controller' => 'shows',
             'action' => 'calendar',
-            'month' => 10,
-            'year' => 2007,
+            'month' => '10',
+            'year' => '2007',
             'min-forestilling',
         ]);
         $expected = '/forestillinger/10/2007/min-forestilling';
@@ -653,8 +663,8 @@ class RouterTest extends TestCase
             'plugin' => 'shows',
             'controller' => 'shows',
             'action' => 'calendar',
-            'year' => 2007,
-            'month' => 10,
+            'year' => '2007',
+            'month' => '10',
             'min-forestilling',
         ]);
         $expected = '/kalender/10/2007/min-forestilling';
@@ -1625,7 +1635,7 @@ class RouterTest extends TestCase
             'controller' => 'Articles',
             'action' => 'edit',
             '_method' => 'PUT',
-            'id' => 99,
+            'id' => '99',
         ]);
         $this->assertEquals('/api/articles/99', $url);
 
@@ -1635,7 +1645,7 @@ class RouterTest extends TestCase
             'action' => 'edit',
             '_method' => 'PUT',
             '_ext' => 'json',
-            'id' => 99,
+            'id' => '99',
         ]);
         $this->assertEquals('/api/articles/99.json', $url);
     }

+ 1 - 1
tests/test_app/TestApp/Auth/TestAuthenticate.php

@@ -54,7 +54,7 @@ class TestAuthenticate extends BaseAuthenticate
     public function afterIdentify(EventInterface $event, array $user)
     {
         $this->callStack[] = __FUNCTION__;
-        $this->authenticationProvider = $event->getData(1);
+        $this->authenticationProvider = $event->getData('1');
 
         if (!empty($this->modifiedUser)) {
             return $user + ['extra' => 'foo'];