Skip to content

Commit

Permalink
Merge pull request #9332 from cakephp/bugfix/fqcn
Browse files Browse the repository at this point in the history
Fix up FQCN via auto-fixers.
  • Loading branch information
markstory committed Aug 23, 2016
2 parents 5f77bac + ce8aff7 commit 68dcf5d
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Cache/CacheEngine.php
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Engine/FileEngine.php
Expand Up @@ -454,7 +454,7 @@ public function key($key)
$key = Inflector::underscore(str_replace(
[DIRECTORY_SEPARATOR, '/', '.', '<', '>', '?', ':', '|', '*', '"'],
'_',
strval($key)
(string)$key
));

return $key;
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Driver.php
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Type.php
Expand Up @@ -278,7 +278,7 @@ public static function strval($value)
$value = '';
}

return strval($value);
return (string)$value;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Type/FloatType.php
Expand Up @@ -76,7 +76,7 @@ public function toDatabase($value, Driver $driver)
return 1;
}

return floatval($value);
return (float)$value;
}

/**
Expand All @@ -96,7 +96,7 @@ public function toPHP($value, Driver $driver)
return 1;
}

return floatval($value);
return (float)$value;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Error/Middleware/ErrorHandlerMiddleware.php
Expand Up @@ -17,6 +17,7 @@
use Cake\Core\App;
use Cake\Http\ResponseTransformer;
use Cake\Log\Log;
use Exception;

/**
* Error handling middleware.
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/Event/EventList.php
Expand Up @@ -14,10 +14,13 @@
*/
namespace Cake\Event;

use ArrayAccess;
use Countable;

/**
* The Event List
*/
class EventList implements \ArrayAccess, \Countable
class EventList implements ArrayAccess, Countable
{

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Client/Auth/Oauth.php
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down
7 changes: 4 additions & 3 deletions src/I18n/Formatter/IcuFormatter.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Mailer/Mailer.php
Expand Up @@ -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))
);
}

Expand Down
6 changes: 4 additions & 2 deletions src/TestSuite/TestCase.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Validation/Validation.php
Expand Up @@ -17,6 +17,7 @@
use Cake\I18n\Time;
use Cake\Utility\Text;
use DateTimeInterface;
use InvalidArgumentException;
use LogicException;
use NumberFormatter;
use RuntimeException;
Expand Down Expand Up @@ -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];

Expand Down
3 changes: 2 additions & 1 deletion src/View/CellTrait.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 2 additions & 1 deletion src/View/HelperRegistry.php
Expand Up @@ -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
Expand Down Expand Up @@ -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
]);
Expand Down
9 changes: 6 additions & 3 deletions src/View/View.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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]);
}

/**
Expand Down Expand Up @@ -1179,7 +1182,7 @@ protected function _getLayoutFileName($name = null)
}
}
}
throw new Exception\MissingLayoutException([
throw new MissingLayoutException([
'file' => $layoutPaths[0] . $name . $this->_ext
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/View/Widget/DateTimeWidget.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/View/Widget/RadioWidget.php
Expand Up @@ -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'])) {
Expand Down

0 comments on commit 68dcf5d

Please sign in to comment.