Browse Source

Adding strict types = 1 to shell tests

Florian Krämer 7 years ago
parent
commit
5e25dabb27

+ 2 - 2
src/Shell/Helper/ProgressHelper.php

@@ -134,12 +134,12 @@ class ProgressHelper extends Helper
         $barLen = ($this->_width - $numberLen) * ($this->_progress / $this->_total);
         $bar = '';
         if ($barLen > 1) {
-            $bar = str_repeat('=', $barLen - 1) . '>';
+            $bar = str_repeat('=', (int)$barLen - 1) . '>';
         }
 
         $pad = ceil($this->_width - $numberLen - $barLen);
         if ($pad > 0) {
-            $bar .= str_repeat(' ', $pad);
+            $bar .= str_repeat(' ', (int)$pad);
         }
         $percent = ($complete * 100) . '%';
         $bar .= str_pad($percent, $numberLen, ' ', STR_PAD_LEFT);

+ 2 - 2
src/Shell/Helper/TableHelper.php

@@ -44,7 +44,7 @@ class TableHelper extends Helper
         $widths = [];
         foreach ($rows as $line) {
             foreach (array_values($line) as $k => $v) {
-                $columnLength = mb_strwidth($v);
+                $columnLength = mb_strwidth((string)$v);
                 if ($columnLength >= ($widths[$k] ?? 0)) {
                     $widths[$k] = $columnLength;
                 }
@@ -86,7 +86,7 @@ class TableHelper extends Helper
 
         $out = '';
         foreach (array_values($row) as $i => $column) {
-            $pad = $widths[$i] - mb_strwidth($column);
+            $pad = $widths[$i] - mb_strwidth((string)$column);
             if (!empty($options['style'])) {
                 $column = $this->_addStyle($column, $options['style']);
             }

+ 1 - 1
src/Shell/Task/CommandTask.php

@@ -208,7 +208,7 @@ class CommandTask extends Shell
     {
         list($pluginDot, $name) = pluginSplit($commandName, true);
 
-        if (in_array(strtolower($pluginDot), ['app.', 'core.'])) {
+        if (in_array(strtolower((string)$pluginDot), ['app.', 'core.'])) {
             $commandName = $name;
             $pluginDot = '';
         }

+ 4 - 4
src/Shell/Task/ExtractTask.php

@@ -179,10 +179,10 @@ class ExtractTask extends Shell
         }
 
         if (isset($this->params['extract-core'])) {
-            $this->_extractCore = !(strtolower($this->params['extract-core']) === 'no');
+            $this->_extractCore = !(strtolower((string)$this->params['extract-core']) === 'no');
         } else {
             $response = $this->in('Would you like to extract the messages from the CakePHP core?', ['y', 'n'], 'n');
-            $this->_extractCore = strtolower($response) === 'y';
+            $this->_extractCore = strtolower((string)$response) === 'y';
         }
 
         if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {
@@ -226,11 +226,11 @@ class ExtractTask extends Shell
         }
 
         if (isset($this->params['merge'])) {
-            $this->_merge = !(strtolower($this->params['merge']) === 'no');
+            $this->_merge = !(strtolower((string)$this->params['merge']) === 'no');
         } else {
             $this->out();
             $response = $this->in('Would you like to merge all domain strings into the default.pot file?', ['y', 'n'], 'n');
-            $this->_merge = strtolower($response) === 'y';
+            $this->_merge = strtolower((string)$response) === 'y';
         }
 
         if (empty($this->_files)) {

+ 1 - 0
tests/TestCase/Shell/CacheShellTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/CompletionShellTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP :  Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/Helper/ProgressHelperTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP :  Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/Helper/TableHelperTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP :  Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/I18nShellTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/PluginShellTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/RoutesShellTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP :  Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/SchemaCacheShellTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/ServerShellTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/Task/AssetsTaskTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP :  Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/Task/ExtractTaskTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP :  Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/Task/LoadTaskTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP :  Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

+ 1 - 0
tests/TestCase/Shell/Task/UnloadTaskTest.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 /**
  * CakePHP :  Rapid Development Framework (https://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)