diff --git a/src/Cache/CacheEngine.php b/src/Cache/CacheEngine.php index 81f691f711c..c7b1a6d7e62 100644 --- a/src/Cache/CacheEngine.php +++ b/src/Cache/CacheEngine.php @@ -254,7 +254,7 @@ public function key($key) $prefix = vsprintf($this->_groupPrefix, $this->groups()); } - $key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace([DIRECTORY_SEPARATOR, '/', '.'], '_', strval($key))))); + $key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace([DIRECTORY_SEPARATOR, '/', '.'], '_', (string)$key)))); return $prefix . $key; } diff --git a/src/Cache/Engine/FileEngine.php b/src/Cache/Engine/FileEngine.php index e93e72f2cd3..0efcab60bc6 100644 --- a/src/Cache/Engine/FileEngine.php +++ b/src/Cache/Engine/FileEngine.php @@ -454,7 +454,7 @@ public function key($key) $key = Inflector::underscore(str_replace( [DIRECTORY_SEPARATOR, '/', '.', '<', '>', '?', ':', '|', '*', '"'], '_', - strval($key) + (string)$key )); return $key; diff --git a/src/Database/Driver.php b/src/Database/Driver.php index d686f4bd28e..9f21df29851 100644 --- a/src/Database/Driver.php +++ b/src/Database/Driver.php @@ -252,7 +252,7 @@ public function schemaValue($value) return 'TRUE'; } if (is_float($value)) { - return str_replace(',', '.', strval($value)); + return str_replace(',', '.', (string)$value); } if ((is_int($value) || $value === '0') || ( is_numeric($value) && strpos($value, ',') === false && diff --git a/src/Database/Type.php b/src/Database/Type.php index 89ff48a78d5..b6102132fad 100644 --- a/src/Database/Type.php +++ b/src/Database/Type.php @@ -278,7 +278,7 @@ public static function strval($value) $value = ''; } - return strval($value); + return (string)$value; } /** diff --git a/src/Database/Type/FloatType.php b/src/Database/Type/FloatType.php index a60b3e82bdb..483e113e391 100644 --- a/src/Database/Type/FloatType.php +++ b/src/Database/Type/FloatType.php @@ -76,7 +76,7 @@ public function toDatabase($value, Driver $driver) return 1; } - return floatval($value); + return (float)$value; } /** @@ -96,7 +96,7 @@ public function toPHP($value, Driver $driver) return 1; } - return floatval($value); + return (float)$value; } /** diff --git a/src/Error/Middleware/ErrorHandlerMiddleware.php b/src/Error/Middleware/ErrorHandlerMiddleware.php index ca753ce503e..cca55c4b7a2 100644 --- a/src/Error/Middleware/ErrorHandlerMiddleware.php +++ b/src/Error/Middleware/ErrorHandlerMiddleware.php @@ -17,6 +17,7 @@ use Cake\Core\App; use Cake\Http\ResponseTransformer; use Cake\Log\Log; +use Exception; /** * Error handling middleware. @@ -99,7 +100,7 @@ protected function getRenderer($exception) if (is_string($this->renderer)) { $class = App::className($this->renderer, 'Error'); if (!$class) { - throw new \Exception("The '{$this->renderer}' renderer class could not be found."); + throw new Exception("The '{$this->renderer}' renderer class could not be found."); } return new $class($exception); diff --git a/src/Event/EventList.php b/src/Event/EventList.php index c9554abfefd..311ee93ee65 100644 --- a/src/Event/EventList.php +++ b/src/Event/EventList.php @@ -14,10 +14,13 @@ */ namespace Cake\Event; +use ArrayAccess; +use Countable; + /** * The Event List */ -class EventList implements \ArrayAccess, \Countable +class EventList implements ArrayAccess, Countable { /** diff --git a/src/Http/Client/Auth/Oauth.php b/src/Http/Client/Auth/Oauth.php index 92fbaa5f79c..6a6d11fcfc4 100644 --- a/src/Http/Client/Auth/Oauth.php +++ b/src/Http/Client/Auth/Oauth.php @@ -16,6 +16,7 @@ use Cake\Core\Exception\Exception; use Cake\Http\Client\Request; use Cake\Utility\Security; +use RuntimeException; /** * Oauth 1 authentication strategy for Cake\Network\Http\Client @@ -168,7 +169,7 @@ protected function _hmacSha1($request, $credentials) protected function _rsaSha1($request, $credentials) { if (!function_exists('openssl_pkey_get_private')) { - throw new \RuntimeException('RSA-SHA1 signature method requires the OpenSSL extension.'); + throw new RuntimeException('RSA-SHA1 signature method requires the OpenSSL extension.'); } $nonce = isset($credentials['nonce']) ? $credentials['nonce'] : bin2hex(Security::randomBytes(16)); diff --git a/src/I18n/Formatter/IcuFormatter.php b/src/I18n/Formatter/IcuFormatter.php index 6090a370642..cbc04416624 100644 --- a/src/I18n/Formatter/IcuFormatter.php +++ b/src/I18n/Formatter/IcuFormatter.php @@ -14,7 +14,8 @@ */ namespace Cake\I18n\Formatter; -use Aura\Intl\Exception; +use Aura\Intl\Exception\CannotFormat; +use Aura\Intl\Exception\CannotInstantiateFormatter; use Aura\Intl\FormatterInterface; use Cake\I18n\PluralRules; use MessageFormatter; @@ -94,11 +95,11 @@ protected function _formatMessage($locale, $message, $vars) // previous action using the object oriented style to figure out $formatter = new MessageFormatter($locale, $message); if (!$formatter) { - throw new Exception\CannotInstantiateFormatter(intl_get_error_message(), intl_get_error_code()); + throw new CannotInstantiateFormatter(intl_get_error_message(), intl_get_error_code()); } $formatter->format($vars); - throw new Exception\CannotFormat($formatter->getErrorMessage(), $formatter->getErrorCode()); + throw new CannotFormat($formatter->getErrorMessage(), $formatter->getErrorCode()); } return $result; diff --git a/src/Mailer/Mailer.php b/src/Mailer/Mailer.php index c51864c7f05..78fb81e553e 100644 --- a/src/Mailer/Mailer.php +++ b/src/Mailer/Mailer.php @@ -163,7 +163,7 @@ public function getName() static::$name = str_replace( 'Mailer', '', - join('', array_slice(explode('\\', get_class($this)), -1)) + implode('', array_slice(explode('\\', get_class($this)), -1)) ); } diff --git a/src/TestSuite/TestCase.php b/src/TestSuite/TestCase.php index a33e32faacb..e906777c915 100644 --- a/src/TestSuite/TestCase.php +++ b/src/TestSuite/TestCase.php @@ -20,6 +20,8 @@ use Cake\ORM\Exception\MissingTableClassException; use Cake\ORM\TableRegistry; use Cake\Routing\Router; +use Cake\TestSuite\Constraint\EventFired; +use Cake\TestSuite\Constraint\EventFiredWith; use Cake\Utility\Inflector; use Exception; use PHPUnit_Framework_TestCase; @@ -153,7 +155,7 @@ public function assertEventFired($name, $eventManager = null, $message = '') if (!$eventManager) { $eventManager = EventManager::instance(); } - $this->assertThat($name, new Constraint\EventFired($eventManager), $message); + $this->assertThat($name, new EventFired($eventManager), $message); } /** @@ -173,7 +175,7 @@ public function assertEventFiredWith($name, $dataKey, $dataValue, $eventManager if (!$eventManager) { $eventManager = EventManager::instance(); } - $this->assertThat($name, new Constraint\EventFiredWith($eventManager, $dataKey, $dataValue), $message); + $this->assertThat($name, new EventFiredWith($eventManager, $dataKey, $dataValue), $message); } /** diff --git a/src/Validation/Validation.php b/src/Validation/Validation.php index d237e0e8a9e..5f432b13b7a 100644 --- a/src/Validation/Validation.php +++ b/src/Validation/Validation.php @@ -17,6 +17,7 @@ use Cake\I18n\Time; use Cake\Utility\Text; use DateTimeInterface; +use InvalidArgumentException; use LogicException; use NumberFormatter; use RuntimeException; @@ -511,7 +512,7 @@ public static function localizedTime($check, $type = 'datetime', $format = null) 'datetime' => 'parseDateTime', ]; if (empty($methods[$type])) { - throw new \InvalidArgumentException('Unsupported parser type given.'); + throw new InvalidArgumentException('Unsupported parser type given.'); } $method = $methods[$type]; diff --git a/src/View/CellTrait.php b/src/View/CellTrait.php index 4d40969965e..de94fc7daa0 100644 --- a/src/View/CellTrait.php +++ b/src/View/CellTrait.php @@ -16,6 +16,7 @@ use Cake\Core\App; use Cake\Utility\Inflector; +use Cake\View\Exception\MissingCellException; /** * Provides cell() method for usage in Controller and View classes. @@ -68,7 +69,7 @@ public function cell($cell, array $data = [], array $options = []) $className = App::className($pluginAndCell, 'View/Cell', 'Cell'); if (!$className) { - throw new Exception\MissingCellException(['className' => $pluginAndCell . 'Cell']); + throw new MissingCellException(['className' => $pluginAndCell . 'Cell']); } if (!empty($data)) { diff --git a/src/View/HelperRegistry.php b/src/View/HelperRegistry.php index 06a27146c79..4bd547a1fcc 100644 --- a/src/View/HelperRegistry.php +++ b/src/View/HelperRegistry.php @@ -18,6 +18,7 @@ use Cake\Core\ObjectRegistry; use Cake\Event\EventDispatcherInterface; use Cake\Event\EventDispatcherTrait; +use Cake\View\Exception\MissingHelperException; /** * HelperRegistry is used as a registry for loaded helpers and handles loading @@ -122,7 +123,7 @@ protected function _resolveClassName($class) */ protected function _throwMissingClassError($class, $plugin) { - throw new Exception\MissingHelperException([ + throw new MissingHelperException([ 'class' => $class . 'Helper', 'plugin' => $plugin ]); diff --git a/src/View/View.php b/src/View/View.php index b43d38e3288..6b6f41435d8 100644 --- a/src/View/View.php +++ b/src/View/View.php @@ -26,6 +26,9 @@ use Cake\Routing\RequestActionTrait; use Cake\Routing\Router; use Cake\Utility\Inflector; +use Cake\View\Exception\MissingElementException; +use Cake\View\Exception\MissingLayoutException; +use Cake\View\Exception\MissingTemplateException; use InvalidArgumentException; use LogicException; use RuntimeException; @@ -497,7 +500,7 @@ public function element($name, array $data = [], array $options = []) list ($plugin, $name) = pluginSplit($name, true); $name = str_replace('/', DIRECTORY_SEPARATOR, $name); $file = $plugin . 'Element' . DIRECTORY_SEPARATOR . $name . $this->_ext; - throw new Exception\MissingElementException($file); + throw new MissingElementException($file); } } @@ -1085,7 +1088,7 @@ protected function _getViewFileName($name = null) return $this->_checkFilePath($path . $name . $this->_ext, $path); } } - throw new Exception\MissingTemplateException(['file' => $name . $this->_ext]); + throw new MissingTemplateException(['file' => $name . $this->_ext]); } /** @@ -1179,7 +1182,7 @@ protected function _getLayoutFileName($name = null) } } } - throw new Exception\MissingLayoutException([ + throw new MissingLayoutException([ 'file' => $layoutPaths[0] . $name . $this->_ext ]); } diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index a3eb73bc561..3a8e1a01339 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -251,7 +251,7 @@ protected function _deconstructDate($value, $options) } if (!empty($dateArray['minute']) && isset($options['minute']['interval'])) { $dateArray['minute'] += $this->_adjustValue($dateArray['minute'], $options['minute']); - $dateArray['minute'] = str_pad(strval($dateArray['minute']), 2, '0', STR_PAD_LEFT); + $dateArray['minute'] = str_pad((string)$dateArray['minute'], 2, '0', STR_PAD_LEFT); } return $dateArray; diff --git a/src/View/Widget/RadioWidget.php b/src/View/Widget/RadioWidget.php index 82d7fd4218a..e91cf570b84 100644 --- a/src/View/Widget/RadioWidget.php +++ b/src/View/Widget/RadioWidget.php @@ -170,7 +170,7 @@ protected function _renderInput($val, $text, $data, $context) if (isset($data['val']) && is_bool($data['val'])) { $data['val'] = $data['val'] ? 1 : 0; } - if (isset($data['val']) && strval($data['val']) === strval($radio['value'])) { + if (isset($data['val']) && (string)$data['val'] === (string)$radio['value']) { $radio['checked'] = true; } if ($this->_isDisabled($radio, $data['disabled'])) {