Browse Source

Fix up return types for Console.

mscherer 7 years ago
parent
commit
88068f78f6

+ 3 - 3
src/Console/ConsoleInputSubcommand.php

@@ -112,15 +112,15 @@ class ConsoleInputSubcommand
     /**
      * Get the usage value for this option
      *
-     * @return \Cake\Console\ConsoleOptionParser|bool Either false or a ConsoleOptionParser
+     * @return \Cake\Console\ConsoleOptionParser|null
      */
-    public function parser()
+    public function parser(): ?ConsoleOptionParser
     {
         if ($this->_parser instanceof ConsoleOptionParser) {
             return $this->_parser;
         }
 
-        return false;
+        return null;
     }
 
     /**

+ 6 - 6
src/Console/ShellDispatcher.php

@@ -95,16 +95,16 @@ class ShellDispatcher
      *
      * @param string $short The new short name for the shell.
      * @param string|null $original The original full name for the shell.
-     * @return string|false The aliased class name, or false if the alias does not exist
+     * @return string|null The aliased class name, or null if the alias does not exist
      */
-    public static function alias(string $short, ?string $original = null)
+    public static function alias(string $short, ?string $original = null): ?string
     {
         $short = Inflector::camelize($short);
         if ($original) {
             static::$_aliases[$short] = $original;
         }
 
-        return isset(static::$_aliases[$short]) ? static::$_aliases[$short] : false;
+        return static::$_aliases[$short] ?? null;
     }
 
     /**
@@ -357,16 +357,16 @@ class ShellDispatcher
      * Check if a shell class exists for the given name.
      *
      * @param string $shell The shell name to look for.
-     * @return string|bool Either the classname or false.
+     * @return string|null Either the classname or null.
      */
-    protected function _shellExists(string $shell)
+    protected function _shellExists(string $shell): ?string
     {
         $class = App::className($shell, 'Shell', 'Shell');
         if ($class && class_exists($class)) {
             return $class;
         }
 
-        return false;
+        return null;
     }
 
     /**

+ 1 - 1
tests/TestCase/Console/ConsoleOptionParserTest.php

@@ -639,7 +639,7 @@ class ConsoleOptionParserTest extends TestCase
 
         $result = $parser->subcommands();
         $this->assertArrayHasKey('build', $result);
-        $this->assertFalse($result['build']->parser(), 'No parser should be created');
+        $this->assertNull($result['build']->parser(), 'No parser should be created');
     }
 
     /**