ソースを参照

Merge pull request #9332 from cakephp/bugfix/fqcn

Fix up FQCN via auto-fixers.
Mark Story 9 年 前
コミット
68dcf5db76

+ 1 - 1
src/Cache/CacheEngine.php

@@ -254,7 +254,7 @@ abstract class CacheEngine
             $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;
     }

+ 1 - 1
src/Cache/Engine/FileEngine.php

@@ -454,7 +454,7 @@ class FileEngine extends CacheEngine
         $key = Inflector::underscore(str_replace(
             [DIRECTORY_SEPARATOR, '/', '.', '<', '>', '?', ':', '|', '*', '"'],
             '_',
-            strval($key)
+            (string)$key
         ));
 
         return $key;

+ 1 - 1
src/Database/Driver.php

@@ -252,7 +252,7 @@ abstract class Driver
             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 &&

+ 1 - 1
src/Database/Type.php

@@ -278,7 +278,7 @@ class Type implements TypeInterface
             $value = '';
         }
 
-        return strval($value);
+        return (string)$value;
     }
 
     /**

+ 2 - 2
src/Database/Type/FloatType.php

@@ -76,7 +76,7 @@ class FloatType extends Type implements TypeInterface
             return 1;
         }
 
-        return floatval($value);
+        return (float)$value;
     }
 
     /**
@@ -96,7 +96,7 @@ class FloatType extends Type implements TypeInterface
             return 1;
         }
 
-        return floatval($value);
+        return (float)$value;
     }
 
     /**

+ 2 - 1
src/Error/Middleware/ErrorHandlerMiddleware.php

@@ -17,6 +17,7 @@ namespace Cake\Error\Middleware;
 use Cake\Core\App;
 use Cake\Http\ResponseTransformer;
 use Cake\Log\Log;
+use Exception;
 
 /**
  * Error handling middleware.
@@ -99,7 +100,7 @@ class ErrorHandlerMiddleware
         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);

+ 4 - 1
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
 {
 
     /**

+ 2 - 1
src/Http/Client/Auth/Oauth.php

@@ -16,6 +16,7 @@ namespace Cake\Http\Client\Auth;
 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 @@ class Oauth
     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));

+ 4 - 3
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 @@ class IcuFormatter implements FormatterInterface
             // 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;

+ 1 - 1
src/Mailer/Mailer.php

@@ -163,7 +163,7 @@ abstract class Mailer implements EventListenerInterface
             static::$name = str_replace(
                 'Mailer',
                 '',
-                join('', array_slice(explode('\\', get_class($this)), -1))
+                implode('', array_slice(explode('\\', get_class($this)), -1))
             );
         }
 

+ 4 - 2
src/TestSuite/TestCase.php

@@ -20,6 +20,8 @@ use Cake\Event\EventManager;
 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 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
         if (!$eventManager) {
             $eventManager = EventManager::instance();
         }
-        $this->assertThat($name, new Constraint\EventFired($eventManager), $message);
+        $this->assertThat($name, new EventFired($eventManager), $message);
     }
 
     /**
@@ -173,7 +175,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
         if (!$eventManager) {
             $eventManager = EventManager::instance();
         }
-        $this->assertThat($name, new Constraint\EventFiredWith($eventManager, $dataKey, $dataValue), $message);
+        $this->assertThat($name, new EventFiredWith($eventManager, $dataKey, $dataValue), $message);
     }
 
     /**

+ 2 - 1
src/Validation/Validation.php

@@ -17,6 +17,7 @@ namespace Cake\Validation;
 use Cake\I18n\Time;
 use Cake\Utility\Text;
 use DateTimeInterface;
+use InvalidArgumentException;
 use LogicException;
 use NumberFormatter;
 use RuntimeException;
@@ -511,7 +512,7 @@ class Validation
             'datetime' => 'parseDateTime',
         ];
         if (empty($methods[$type])) {
-            throw new \InvalidArgumentException('Unsupported parser type given.');
+            throw new InvalidArgumentException('Unsupported parser type given.');
         }
         $method = $methods[$type];
 

+ 2 - 1
src/View/CellTrait.php

@@ -16,6 +16,7 @@ namespace Cake\View;
 
 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 @@ trait CellTrait
         $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)) {

+ 2 - 1
src/View/HelperRegistry.php

@@ -18,6 +18,7 @@ use Cake\Core\App;
 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 @@ class HelperRegistry extends ObjectRegistry implements EventDispatcherInterface
      */
     protected function _throwMissingClassError($class, $plugin)
     {
-        throw new Exception\MissingHelperException([
+        throw new MissingHelperException([
             'class' => $class . 'Helper',
             'plugin' => $plugin
         ]);

+ 6 - 3
src/View/View.php

@@ -26,6 +26,9 @@ use Cake\Network\Response;
 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 @@ class View implements EventDispatcherInterface
             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 @@ class View implements EventDispatcherInterface
                 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 @@ class View implements EventDispatcherInterface
                 }
             }
         }
-        throw new Exception\MissingLayoutException([
+        throw new MissingLayoutException([
             'file' => $layoutPaths[0] . $name . $this->_ext
         ]);
     }

+ 1 - 1
src/View/Widget/DateTimeWidget.php

@@ -251,7 +251,7 @@ class DateTimeWidget implements WidgetInterface
                     }
                     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;

+ 1 - 1
src/View/Widget/RadioWidget.php

@@ -170,7 +170,7 @@ class RadioWidget implements WidgetInterface
         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'])) {