diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php
index 60333723d..69dd70ad9 100644
--- a/system/src/Grav/Common/Assets.php
+++ b/system/src/Grav/Common/Assets.php
@@ -9,6 +9,7 @@
namespace Grav\Common;
+use Closure;
use Grav\Common\Assets\Pipeline;
use Grav\Common\Assets\Traits\LegacyAssetsTrait;
use Grav\Common\Assets\Traits\TestingAssetsTrait;
@@ -81,7 +82,7 @@ class Assets extends PropertyObject
/** @var array */
protected $pipeline_options = [];
- /** @var \Closure|string */
+ /** @var Closure|string */
protected $fetch_command;
/** @var string */
protected $autoload;
diff --git a/system/src/Grav/Common/Assets/Pipeline.php b/system/src/Grav/Common/Assets/Pipeline.php
index 6fdc2cc1d..750239158 100644
--- a/system/src/Grav/Common/Assets/Pipeline.php
+++ b/system/src/Grav/Common/Assets/Pipeline.php
@@ -15,6 +15,8 @@ use Grav\Common\Grav;
use Grav\Common\Uri;
use Grav\Common\Utils;
use Grav\Framework\Object\PropertyObject;
+use MatthiasMullie\Minify\CSS;
+use MatthiasMullie\Minify\JS;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use function array_key_exists;
@@ -131,7 +133,7 @@ class Pipeline extends PropertyObject
// Minify if required
if ($this->shouldMinify('css')) {
- $minifier = new \MatthiasMullie\Minify\CSS();
+ $minifier = new CSS();
$minifier->add($buffer);
$buffer = $minifier->minify();
}
@@ -194,7 +196,7 @@ class Pipeline extends PropertyObject
// Minify if required
if ($this->shouldMinify('js')) {
- $minifier = new \MatthiasMullie\Minify\JS();
+ $minifier = new JS();
$minifier->add($buffer);
$buffer = $minifier->minify();
}
diff --git a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
index 4c85e00a2..34152a526 100644
--- a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
+++ b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
@@ -12,6 +12,7 @@ namespace Grav\Common\Assets\Traits;
use Closure;
use Grav\Common\Grav;
use Grav\Common\Utils;
+use function dirname;
use function in_array;
use function is_array;
@@ -80,7 +81,7 @@ trait AssetUtilsTrait
if (0 === strpos($link, '//')) {
$link = 'http:' . $link;
}
- $relative_dir = \dirname($relative_path);
+ $relative_dir = dirname($relative_path);
} else {
// Fix to remove relative dir if grav is in one
if (($this->base_url !== '/') && Utils::startsWith($relative_path, $this->base_url)) {
@@ -88,7 +89,7 @@ trait AssetUtilsTrait
$relative_path = ltrim(preg_replace($base_url, '/', $link, 1), '/');
}
- $relative_dir = \dirname($relative_path);
+ $relative_dir = dirname($relative_path);
$link = ROOT_DIR . $relative_path;
}
diff --git a/system/src/Grav/Common/Browser.php b/system/src/Grav/Common/Browser.php
index ff085f1bb..36faf3aee 100644
--- a/system/src/Grav/Common/Browser.php
+++ b/system/src/Grav/Common/Browser.php
@@ -9,6 +9,7 @@
namespace Grav\Common;
+use InvalidArgumentException;
use function donatj\UserAgent\parse_user_agent;
/**
@@ -26,7 +27,7 @@ class Browser
{
try {
$this->useragent = parse_user_agent();
- } catch (\InvalidArgumentException $e) {
+ } catch (InvalidArgumentException $e) {
$this->useragent = parse_user_agent("Mozilla/5.0 (compatible; Unknown;)");
}
}
diff --git a/system/src/Grav/Common/Config/CompiledConfig.php b/system/src/Grav/Common/Config/CompiledConfig.php
index d63888c96..d6f89ec6c 100644
--- a/system/src/Grav/Common/Config/CompiledConfig.php
+++ b/system/src/Grav/Common/Config/CompiledConfig.php
@@ -10,6 +10,7 @@
namespace Grav\Common\Config;
use Grav\Common\File\CompiledYamlFile;
+use function is_callable;
/**
* Class CompiledConfig
@@ -68,7 +69,7 @@ class CompiledConfig extends CompiledBase
*/
protected function createObject(array $data = [])
{
- if ($this->withDefaults && empty($data) && \is_callable($this->callable)) {
+ if ($this->withDefaults && empty($data) && is_callable($this->callable)) {
$blueprints = $this->callable;
$data = $blueprints()->getDefaults();
}
diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php
index 10391d4fe..e43e1d278 100644
--- a/system/src/Grav/Common/Config/Config.php
+++ b/system/src/Grav/Common/Config/Config.php
@@ -14,6 +14,7 @@ use Grav\Common\Grav;
use Grav\Common\Data\Data;
use Grav\Common\Service\ConfigServiceProvider;
use Grav\Common\Utils;
+use function is_array;
/**
* Class Config
@@ -130,7 +131,7 @@ class Config extends Data
{
$setup = Grav::instance()['setup']->toArray();
foreach ($setup as $key => $value) {
- if ($key === 'streams' || !\is_array($value)) {
+ if ($key === 'streams' || !is_array($value)) {
// Optimized as streams and simple values are fully defined in setup.
$this->items[$key] = $value;
} else {
diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php
index bc6332a34..e1ac0bedf 100644
--- a/system/src/Grav/Common/Data/Blueprint.php
+++ b/system/src/Grav/Common/Data/Blueprint.php
@@ -23,6 +23,7 @@ use function is_array;
use function is_int;
use function is_object;
use function is_string;
+use function strlen;
/**
* Class Blueprint
@@ -387,7 +388,7 @@ class Blueprint extends BlueprintForm
$context = $this->context;
}
- if ($context && $context[\strlen($context)-1] !== '/') {
+ if ($context && $context[strlen($context)-1] !== '/') {
$context .= '/';
}
diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php
index 65f7fceca..dabe40fa4 100644
--- a/system/src/Grav/Common/Data/Data.php
+++ b/system/src/Grav/Common/Data/Data.php
@@ -9,7 +9,9 @@
namespace Grav\Common\Data;
+use ArrayAccess;
use Exception;
+use JsonSerializable;
use RocketTheme\Toolbox\ArrayTraits\Countable;
use RocketTheme\Toolbox\ArrayTraits\Export;
use RocketTheme\Toolbox\ArrayTraits\ExportInterface;
@@ -25,7 +27,7 @@ use function is_object;
* Class Data
* @package Grav\Common\Data
*/
-class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable, ExportInterface
+class Data implements DataInterface, ArrayAccess, \Countable, JsonSerializable, ExportInterface
{
use NestedArrayAccessWithGetters, Countable, Export;
diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php
index 6cfe35487..f9aef9d5b 100644
--- a/system/src/Grav/Common/Data/Validation.php
+++ b/system/src/Grav/Common/Data/Validation.php
@@ -27,6 +27,7 @@ use function is_bool;
use function is_float;
use function is_int;
use function is_string;
+use function strlen;
/**
* Class Validation
@@ -238,16 +239,16 @@ class Validation
$value = trim($value);
}
- if (isset($params['min']) && \strlen($value) < $params['min']) {
+ if (isset($params['min']) && strlen($value) < $params['min']) {
return false;
}
- if (isset($params['max']) && \strlen($value) > $params['max']) {
+ if (isset($params['max']) && strlen($value) > $params['max']) {
return false;
}
$min = $params['min'] ?? 0;
- if (isset($params['step']) && (\strlen($value) - $min) % $params['step'] === 0) {
+ if (isset($params['step']) && (strlen($value) - $min) % $params['step'] === 0) {
return false;
}
diff --git a/system/src/Grav/Common/Data/ValidationException.php b/system/src/Grav/Common/Data/ValidationException.php
index 67d02e73a..be9846b3d 100644
--- a/system/src/Grav/Common/Data/ValidationException.php
+++ b/system/src/Grav/Common/Data/ValidationException.php
@@ -10,12 +10,13 @@
namespace Grav\Common\Data;
use Grav\Common\Grav;
+use RuntimeException;
/**
* Class ValidationException
* @package Grav\Common\Data
*/
-class ValidationException extends \RuntimeException
+class ValidationException extends RuntimeException
{
/** @var array */
protected $messages = [];
diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php
index 6b7e49a3a..b90f9743c 100644
--- a/system/src/Grav/Common/Debugger.php
+++ b/system/src/Grav/Common/Debugger.php
@@ -36,12 +36,14 @@ use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use ReflectionObject;
+use SplFileInfo;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Throwable;
use Twig\Environment;
use Twig\Template;
use Twig\TemplateWrapper;
use function array_slice;
+use function call_user_func;
use function count;
use function define;
use function defined;
@@ -837,7 +839,7 @@ class Debugger
{
if ($errno !== E_USER_DEPRECATED && $errno !== E_DEPRECATED) {
if ($this->errorHandler) {
- return \call_user_func($this->errorHandler, $errno, $errstr, $errfile, $errline);
+ return call_user_func($this->errorHandler, $errno, $errstr, $errfile, $errline);
}
return true;
@@ -870,7 +872,7 @@ class Debugger
foreach ($backtrace as $current) {
if (isset($current['args'])) {
foreach ($current['args'] as $arg) {
- if ($arg instanceof \SplFileInfo) {
+ if ($arg instanceof SplFileInfo) {
$arg = $arg->getPathname();
}
if (is_string($arg) && preg_match('/.+\.(yaml|md)$/i', $arg)) {
diff --git a/system/src/Grav/Common/Errors/SimplePageHandler.php b/system/src/Grav/Common/Errors/SimplePageHandler.php
index eba0f47fc..6ade01620 100644
--- a/system/src/Grav/Common/Errors/SimplePageHandler.php
+++ b/system/src/Grav/Common/Errors/SimplePageHandler.php
@@ -9,6 +9,7 @@
namespace Grav\Common\Errors;
+use ErrorException;
use InvalidArgumentException;
use RuntimeException;
use Whoops\Handler\Handler;
@@ -49,7 +50,7 @@ class SimplePageHandler extends Handler
}
$message = $inspector->getException()->getMessage();
- if ($inspector->getException() instanceof \ErrorException) {
+ if ($inspector->getException() instanceof ErrorException) {
$code = Misc::translateErrorCode($code);
}
diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
index 88cdfd253..e7f857773 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Grav\Common\Flex\Types\Pages;
+use Exception;
use Grav\Common\Flex\Traits\FlexCollectionTrait;
use Grav\Common\Flex\Traits\FlexGravTrait;
use Grav\Common\Grav;
@@ -432,7 +433,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* @param string|false $endDate
* @param string|null $field
* @return static
- * @throws \Exception
+ * @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null)
{
@@ -771,7 +772,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* Get the extended version of this Collection with each page keyed by route
*
* @return array
- * @throws \Exception
+ * @throws Exception
*/
public function toExtendedArray(): array
{
diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
index ab0015dc0..12d7f9f7a 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
@@ -26,6 +26,7 @@ use Grav\Framework\Flex\FlexDirectory;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexStorageInterface;
use Grav\Framework\Flex\Pages\FlexPageIndex;
+use InvalidArgumentException;
use RuntimeException;
use function is_array;
use function is_string;
@@ -652,7 +653,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
* @param PageInterface|string|null $key
*
* @return $this
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function remove($key = null)
{
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
index 8081d28c0..2362fa937 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
@@ -16,6 +16,7 @@ use Grav\Common\Language\Language;
use Grav\Common\Page\Page;
use Grav\Common\Utils;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
+use SplFileInfo;
/**
* Implements PageTranslateInterface
@@ -75,7 +76,7 @@ trait PageTranslateTrait
// FIXME: use flex, also rawRoute() does not fully work?
$aPage = new Page();
- $aPage->init(new \SplFileInfo($path), $languageExtension);
+ $aPage->init(new SplFileInfo($path), $languageExtension);
if ($onlyPublished && !$aPage->published()) {
continue;
}
diff --git a/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php b/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
index 2063cc365..82f1bf729 100644
--- a/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
@@ -13,6 +13,7 @@ namespace Grav\Common\Flex\Types\Users\Traits;
use Grav\Common\Page\Medium\ImageMedium;
use Grav\Common\Page\Medium\StaticImageMedium;
+use function count;
/**
* Trait UserObjectLegacyTrait
@@ -87,6 +88,6 @@ trait UserObjectLegacyTrait
{
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
- return \count($this->jsonSerialize());
+ return count($this->jsonSerialize());
}
}
diff --git a/system/src/Grav/Common/Flex/Types/Users/UserObject.php b/system/src/Grav/Common/Flex/Types/Users/UserObject.php
index 14d714282..a89782053 100644
--- a/system/src/Grav/Common/Flex/Types/Users/UserObject.php
+++ b/system/src/Grav/Common/Flex/Types/Users/UserObject.php
@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Grav\Common\Flex\Types\Users;
+use Countable;
use Grav\Common\Config\Config;
use Grav\Common\Data\Blueprint;
use Grav\Common\Flex\Traits\FlexGravTrait;
@@ -65,7 +66,7 @@ use function is_object;
* @property bool $authenticated
* @property bool $authorized
*/
-class UserObject extends FlexObject implements UserInterface, \Countable
+class UserObject extends FlexObject implements UserInterface, Countable
{
use FlexGravTrait;
use FlexObjectTrait;
diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php
index 02f495d92..bc58fabae 100644
--- a/system/src/Grav/Common/GPM/GPM.php
+++ b/system/src/Grav/Common/GPM/GPM.php
@@ -17,6 +17,7 @@ use Grav\Common\Iterator;
use Grav\Common\Utils;
use RocketTheme\Toolbox\File\YamlFile;
use RuntimeException;
+use stdClass;
use function array_key_exists;
use function count;
use function in_array;
@@ -728,7 +729,7 @@ class GPM extends Iterator
$type = 'plugins';
}
- $not_found = new \stdClass();
+ $not_found = new stdClass();
$not_found->name = $inflector::camelize($search);
$not_found->slug = $search;
$not_found->package_type = $type;
diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php
index 2fc0eb647..c894b74b4 100644
--- a/system/src/Grav/Common/GPM/Installer.php
+++ b/system/src/Grav/Common/GPM/Installer.php
@@ -12,6 +12,7 @@ namespace Grav\Common\GPM;
use DirectoryIterator;
use Grav\Common\Filesystem\Folder;
use Grav\Common\Grav;
+use RuntimeException;
use ZipArchive;
use function count;
use function in_array;
@@ -274,7 +275,7 @@ class Installer
public static function copyInstall($source_path, $install_path)
{
if (empty($source_path)) {
- throw new \RuntimeException("Directory $source_path is missing");
+ throw new RuntimeException("Directory $source_path is missing");
}
Folder::rcopy($source_path, $install_path);
diff --git a/system/src/Grav/Common/GPM/Response.php b/system/src/Grav/Common/GPM/Response.php
index 47734a1c1..85e57bc92 100644
--- a/system/src/Grav/Common/GPM/Response.php
+++ b/system/src/Grav/Common/GPM/Response.php
@@ -17,7 +17,9 @@ use Symfony\Component\HttpClient\Exception\TransportException;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\HttpOptions;
use Symfony\Component\HttpClient\NativeHttpClient;
+use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use function call_user_func;
+use function defined;
use function function_exists;
/**
@@ -40,7 +42,7 @@ class Response
* @param array $overrides An array of parameters for both `curl` and `fopen`
* @param callable|null $callback Either a function or callback in array notation
* @return string The response of the request
- * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
+ * @throws TransportExceptionInterface
*/
public static function get($uri = '', $overrides = [], $callback = null)
{
@@ -57,7 +59,7 @@ class Response
}
$config = Grav::instance()['config'];
- $referer = \defined('GRAV_CLI') ? 'grav_cli' : Grav::instance()['uri']->rootUrl(true);
+ $referer = defined('GRAV_CLI') ? 'grav_cli' : Grav::instance()['uri']->rootUrl(true);
$options = new HttpOptions();
// Set default Headers
diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php
index 851d84c1c..c65dd50fa 100644
--- a/system/src/Grav/Common/Grav.php
+++ b/system/src/Grav/Common/Grav.php
@@ -29,6 +29,21 @@ use Grav\Common\Processors\TasksProcessor;
use Grav\Common\Processors\ThemesProcessor;
use Grav\Common\Processors\TwigProcessor;
use Grav\Common\Scheduler\Scheduler;
+use Grav\Common\Service\AccountsServiceProvider;
+use Grav\Common\Service\AssetsServiceProvider;
+use Grav\Common\Service\BackupsServiceProvider;
+use Grav\Common\Service\ConfigServiceProvider;
+use Grav\Common\Service\ErrorServiceProvider;
+use Grav\Common\Service\FilesystemServiceProvider;
+use Grav\Common\Service\FlexServiceProvider;
+use Grav\Common\Service\InflectorServiceProvider;
+use Grav\Common\Service\LoggerServiceProvider;
+use Grav\Common\Service\OutputServiceProvider;
+use Grav\Common\Service\PagesServiceProvider;
+use Grav\Common\Service\RequestServiceProvider;
+use Grav\Common\Service\SessionServiceProvider;
+use Grav\Common\Service\StreamsServiceProvider;
+use Grav\Common\Service\TaskServiceProvider;
use Grav\Common\Twig\Twig;
use Grav\Framework\DI\Container;
use Grav\Framework\Psr7\Response;
@@ -41,6 +56,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use function array_key_exists;
use function call_user_func_array;
+use function function_exists;
use function get_class;
use function in_array;
use function is_callable;
@@ -65,21 +81,21 @@ class Grav extends Container
* to the dependency injection container.
*/
protected static $diMap = [
- 'Grav\Common\Service\AccountsServiceProvider',
- 'Grav\Common\Service\AssetsServiceProvider',
- 'Grav\Common\Service\BackupsServiceProvider',
- 'Grav\Common\Service\ConfigServiceProvider',
- 'Grav\Common\Service\ErrorServiceProvider',
- 'Grav\Common\Service\FilesystemServiceProvider',
- 'Grav\Common\Service\FlexServiceProvider',
- 'Grav\Common\Service\InflectorServiceProvider',
- 'Grav\Common\Service\LoggerServiceProvider',
- 'Grav\Common\Service\OutputServiceProvider',
- 'Grav\Common\Service\PagesServiceProvider',
- 'Grav\Common\Service\RequestServiceProvider',
- 'Grav\Common\Service\SessionServiceProvider',
- 'Grav\Common\Service\StreamsServiceProvider',
- 'Grav\Common\Service\TaskServiceProvider',
+ AccountsServiceProvider::class,
+ AssetsServiceProvider::class,
+ BackupsServiceProvider::class,
+ ConfigServiceProvider::class,
+ ErrorServiceProvider::class,
+ FilesystemServiceProvider::class,
+ FlexServiceProvider::class,
+ InflectorServiceProvider::class,
+ LoggerServiceProvider::class,
+ OutputServiceProvider::class,
+ PagesServiceProvider::class,
+ RequestServiceProvider::class,
+ SessionServiceProvider::class,
+ StreamsServiceProvider::class,
+ TaskServiceProvider::class,
'browser' => Browser::class,
'cache' => Cache::class,
'events' => EventDispatcher::class,
@@ -530,7 +546,7 @@ class Grav extends Container
public function shutdown()
{
// Prevent user abort allowing onShutdown event to run without interruptions.
- if (\function_exists('ignore_user_abort')) {
+ if (function_exists('ignore_user_abort')) {
@ignore_user_abort(true);
}
@@ -546,7 +562,7 @@ class Grav extends Container
// the connection to the client open. This will make page loads to feel much faster.
// FastCGI allows us to flush all response data to the client and finish the request.
- $success = \function_exists('fastcgi_finish_request') ? @fastcgi_finish_request() : false;
+ $success = function_exists('fastcgi_finish_request') ? @fastcgi_finish_request() : false;
if (!$success) {
// Unfortunately without FastCGI there is no way to force close the connection.
// We need to ask browser to close the connection for us.
diff --git a/system/src/Grav/Common/Helpers/LogViewer.php b/system/src/Grav/Common/Helpers/LogViewer.php
index 0f64d15a0..f450a6e6a 100644
--- a/system/src/Grav/Common/Helpers/LogViewer.php
+++ b/system/src/Grav/Common/Helpers/LogViewer.php
@@ -139,7 +139,7 @@ class LogViewer
}
return array(
- 'date' => \DateTime::createFromFormat('Y-m-d H:i:s', $data['date']),
+ 'date' => DateTime::createFromFormat('Y-m-d H:i:s', $data['date']),
'logger' => $data['logger'],
'level' => $data['level'],
'message' => $data['message'],
diff --git a/system/src/Grav/Common/Helpers/YamlLinter.php b/system/src/Grav/Common/Helpers/YamlLinter.php
index 1e445d53e..a5bc9b5a0 100644
--- a/system/src/Grav/Common/Helpers/YamlLinter.php
+++ b/system/src/Grav/Common/Helpers/YamlLinter.php
@@ -9,6 +9,7 @@
namespace Grav\Common\Helpers;
+use Exception;
use Grav\Common\Grav;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
@@ -93,7 +94,7 @@ class YamlLinter
foreach ($iterator as $filepath => $file) {
try {
Yaml::parse(static::extractYaml($filepath));
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$lint_errors[str_replace(GRAV_ROOT, '', $filepath)] = $e->getMessage();
}
}
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
index 9527f8a3d..a3cce1bfc 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
@@ -9,6 +9,7 @@
namespace Grav\Common\Media\Interfaces;
+use ArrayAccess;
use Grav\Common\Data\Data;
/**
@@ -16,7 +17,7 @@ use Grav\Common\Data\Data;
*
* @property string $type
*/
-interface MediaObjectInterface extends \Grav\Framework\Media\Interfaces\MediaObjectInterface, \ArrayAccess
+interface MediaObjectInterface extends \Grav\Framework\Media\Interfaces\MediaObjectInterface, ArrayAccess
{
/**
* Create a copy of this media object
diff --git a/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php b/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
index 419e14b86..cca287fdb 100644
--- a/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
@@ -12,6 +12,7 @@ namespace Grav\Common\Page\Interfaces;
use ArrayAccess;
use Countable;
use Exception;
+use InvalidArgumentException;
use Serializable;
use Traversable;
@@ -91,7 +92,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* @param PageInterface|string|null $key
* @return PageCollectionInterface
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
//public function remove($key = null);
diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php
index c0d1c913c..0a8385188 100644
--- a/system/src/Grav/Common/Page/Page.php
+++ b/system/src/Grav/Common/Page/Page.php
@@ -30,6 +30,7 @@ use Grav\Common\Yaml;
use InvalidArgumentException;
use RocketTheme\Toolbox\Event\Event;
use RocketTheme\Toolbox\File\MarkdownFile;
+use RuntimeException;
use SplFileInfo;
use function dirname;
use function in_array;
@@ -1104,10 +1105,10 @@ class Page implements PageInterface
$this->_action = 'move';
if ($this->route() === $parent->route()) {
- throw new \RuntimeException('Failed: Cannot set page parent to self');
+ throw new RuntimeException('Failed: Cannot set page parent to self');
}
if (Utils::startsWith($parent->rawRoute(), $this->rawRoute())) {
- throw new \RuntimeException('Failed: Cannot set page parent to a child of current page');
+ throw new RuntimeException('Failed: Cannot set page parent to a child of current page');
}
$this->parent($parent);
diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php
index 37e000b7b..84a9bec35 100644
--- a/system/src/Grav/Common/Page/Pages.php
+++ b/system/src/Grav/Common/Page/Pages.php
@@ -34,6 +34,7 @@ use Grav\Plugin\Admin;
use RocketTheme\Toolbox\Event\Event;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use RuntimeException;
+use SplFileInfo;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Whoops\Exception\ErrorException;
use Collator;
@@ -1344,7 +1345,7 @@ class Pages
/** @var PageInterface $page */
$page = $event['page'];
- $page->init(new \SplFileInfo('plugin://admin/pages/admin/error.md'));
+ $page->init(new SplFileInfo('plugin://admin/pages/admin/error.md'));
$page->routable(true);
$header = $page->header();
$header->title = 'Please install missing plugin';
diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php
index c37ea953f..d734a9827 100644
--- a/system/src/Grav/Common/Plugin.php
+++ b/system/src/Grav/Common/Plugin.php
@@ -9,6 +9,7 @@
namespace Grav\Common;
+use ArrayAccess;
use Grav\Common\Data\Blueprint;
use Grav\Common\Data\Data;
use Grav\Common\Page\Interfaces\PageInterface;
@@ -25,7 +26,7 @@ use function is_string;
* Class Plugin
* @package Grav\Common
*/
-class Plugin implements EventSubscriberInterface, \ArrayAccess
+class Plugin implements EventSubscriberInterface, ArrayAccess
{
/** @var string */
public $name;
diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php
index 11dda8ef1..02a189d9b 100644
--- a/system/src/Grav/Common/Plugins.php
+++ b/system/src/Grav/Common/Plugins.php
@@ -30,6 +30,7 @@ class Plugins extends Iterator
/** @var array */
public $formFieldTypes;
+ /** @var bool */
private $plugins_initialized = false;
/**
diff --git a/system/src/Grav/Common/Processors/PagesProcessor.php b/system/src/Grav/Common/Processors/PagesProcessor.php
index fc9da7eec..8d1377b86 100644
--- a/system/src/Grav/Common/Processors/PagesProcessor.php
+++ b/system/src/Grav/Common/Processors/PagesProcessor.php
@@ -14,6 +14,7 @@ use RocketTheme\Toolbox\Event\Event;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
+use RuntimeException;
/**
* Class PagesProcessor
@@ -55,7 +56,7 @@ class PagesProcessor extends ProcessorBase
unset($this->container['page']);
$this->container['page'] = $page = $event->page;
} else {
- throw new \RuntimeException('Page Not Found', 404);
+ throw new RuntimeException('Page Not Found', 404);
}
$this->addMessage("Routed to page {$page->rawRoute()} (type: {$page->template()}) [Not Found fallback]");
diff --git a/system/src/Grav/Common/Scheduler/Cron.php b/system/src/Grav/Common/Scheduler/Cron.php
index f75afb077..48a138470 100644
--- a/system/src/Grav/Common/Scheduler/Cron.php
+++ b/system/src/Grav/Common/Scheduler/Cron.php
@@ -46,6 +46,7 @@ namespace Grav\Common\Scheduler;
* // bool(true)
*/
+use DateInterval;
use DateTime;
use RuntimeException;
use function count;
@@ -473,9 +474,9 @@ class Cron
}
$date = $this->parseDate($date, $min, $hour, $day, $month, $weekday);
- $interval = new \DateInterval('PT1M'); // 1 min
+ $interval = new DateInterval('PT1M'); // 1 min
if ($minuteBefore !== 0) {
- $date->sub(new \DateInterval('PT' . abs($minuteBefore) . 'M'));
+ $date->sub(new DateInterval('PT' . abs($minuteBefore) . 'M'));
}
$n = $minuteAfter - $minuteBefore + 1;
for ($i = 0; $i < $n; $i++) {
diff --git a/system/src/Grav/Common/Scheduler/Job.php b/system/src/Grav/Common/Scheduler/Job.php
index 62c7f1c1c..35bd261b9 100644
--- a/system/src/Grav/Common/Scheduler/Job.php
+++ b/system/src/Grav/Common/Scheduler/Job.php
@@ -9,6 +9,7 @@
namespace Grav\Common\Scheduler;
+use Closure;
use Cron\CronExpression;
use DateTime;
use Grav\Common\Grav;
@@ -109,7 +110,7 @@ class Job
/**
* Get the command
*
- * @return \Closure|string
+ * @return Closure|string
*/
public function getCommand()
{
@@ -336,7 +337,7 @@ class Job
if (is_callable($this->command)) {
$this->output = $this->exec();
} else {
- $args = \is_string($this->args) ? explode(' ', $this->args) : $this->args;
+ $args = is_string($this->args) ? explode(' ', $this->args) : $this->args;
$command = array_merge([$this->command], $args);
$process = new Process($command);
diff --git a/system/src/Grav/Common/Scheduler/Scheduler.php b/system/src/Grav/Common/Scheduler/Scheduler.php
index a77b4e465..41211b2b1 100644
--- a/system/src/Grav/Common/Scheduler/Scheduler.php
+++ b/system/src/Grav/Common/Scheduler/Scheduler.php
@@ -13,6 +13,7 @@ use DateTime;
use Grav\Common\Filesystem\Folder;
use Grav\Common\Grav;
use Grav\Common\Utils;
+use InvalidArgumentException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use RocketTheme\Toolbox\File\YamlFile;
@@ -247,7 +248,7 @@ class Scheduler
case 'array':
return $this->output_schedule;
default:
- throw new \InvalidArgumentException('Invalid output type');
+ throw new InvalidArgumentException('Invalid output type');
}
}
diff --git a/system/src/Grav/Common/Service/ConfigServiceProvider.php b/system/src/Grav/Common/Service/ConfigServiceProvider.php
index 90c70a2fc..38d933cfc 100644
--- a/system/src/Grav/Common/Service/ConfigServiceProvider.php
+++ b/system/src/Grav/Common/Service/ConfigServiceProvider.php
@@ -9,6 +9,7 @@
namespace Grav\Common\Service;
+use DirectoryIterator;
use Grav\Common\Config\CompiledBlueprints;
use Grav\Common\Config\CompiledConfig;
use Grav\Common\Config\CompiledLanguages;
@@ -169,9 +170,9 @@ class ConfigServiceProvider implements ServiceProviderInterface
$paths = [];
foreach ($plugins as $path) {
- $iterator = new \DirectoryIterator($path);
+ $iterator = new DirectoryIterator($path);
- /** @var \DirectoryIterator $directory */
+ /** @var DirectoryIterator $directory */
foreach ($iterator as $directory) {
if (!$directory->isDir() || $directory->isDot()) {
continue;
diff --git a/system/src/Grav/Common/Session.php b/system/src/Grav/Common/Session.php
index 6441987ce..ee86080cb 100644
--- a/system/src/Grav/Common/Session.php
+++ b/system/src/Grav/Common/Session.php
@@ -11,6 +11,7 @@ namespace Grav\Common;
use Grav\Common\Form\FormFlash;
use Grav\Events\SessionStartEvent;
+use Grav\Plugin\Form\Forms;
use function is_string;
/**
@@ -126,7 +127,7 @@ class Session extends \Grav\Framework\Session\Session
/** @var Uri $uri */
$uri = $grav['uri'];
- /** @var Grav\Plugin\Form\Forms|null $form */
+ /** @var Forms|null $form */
$form = $grav['forms']->getActiveForm();
$sessionField = base64_encode($uri->url);
diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php
index 157bee473..1e6bcf5a7 100644
--- a/system/src/Grav/Common/Twig/TwigExtension.php
+++ b/system/src/Grav/Common/Twig/TwigExtension.php
@@ -130,12 +130,12 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
new TwigFilter('pad', [$this, 'padFilter']),
new TwigFilter('regex_replace', [$this, 'regexReplace']),
new TwigFilter('safe_email', [$this, 'safeEmailFilter'], ['is_safe' => ['html']]),
- new TwigFilter('safe_truncate', ['\Grav\Common\Utils', 'safeTruncate']),
- new TwigFilter('safe_truncate_html', ['\Grav\Common\Utils', 'safeTruncateHTML']),
+ new TwigFilter('safe_truncate', [Utils::class, 'safeTruncate']),
+ new TwigFilter('safe_truncate_html', [Utils::class, 'safeTruncateHTML']),
new TwigFilter('sort_by_key', [$this, 'sortByKeyFilter']),
new TwigFilter('starts_with', [$this, 'startsWithFilter']),
- new TwigFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
- new TwigFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
+ new TwigFilter('truncate', [Utils::class, 'truncate']),
+ new TwigFilter('truncate_html', [Utils::class, 'truncateHTML']),
new TwigFilter('json_decode', [$this, 'jsonDecodeFilter']),
new TwigFilter('array_unique', 'array_unique'),
new TwigFilter('basename', 'basename'),
diff --git a/system/src/Grav/Common/User/DataUser/User.php b/system/src/Grav/Common/User/DataUser/User.php
index 690d7ce56..49339885c 100644
--- a/system/src/Grav/Common/User/DataUser/User.php
+++ b/system/src/Grav/Common/User/DataUser/User.php
@@ -22,6 +22,7 @@ use Grav\Common\User\Authentication;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\User\Traits\UserTrait;
use Grav\Framework\Flex\Flex;
+use function is_array;
/**
* Class User
@@ -303,7 +304,7 @@ class User extends Data implements UserInterface
protected function getAvatarFile(): ?string
{
$avatars = $this->get('avatar');
- if (\is_array($avatars) && $avatars) {
+ if (is_array($avatars) && $avatars) {
$avatar = array_shift($avatars);
return $avatar['path'] ?? null;
}
diff --git a/system/src/Grav/Common/User/DataUser/UserCollection.php b/system/src/Grav/Common/User/DataUser/UserCollection.php
index 2f921d414..5be500155 100644
--- a/system/src/Grav/Common/User/DataUser/UserCollection.php
+++ b/system/src/Grav/Common/User/DataUser/UserCollection.php
@@ -17,6 +17,7 @@ use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\Utils;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use RuntimeException;
+use function count;
use function in_array;
use function is_string;
diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php
index 252c838d9..a6dccd418 100644
--- a/system/src/Grav/Common/Utils.php
+++ b/system/src/Grav/Common/Utils.php
@@ -30,6 +30,7 @@ use function extension_loaded;
use function function_exists;
use function in_array;
use function is_array;
+use function is_callable;
use function is_string;
use function strlen;
diff --git a/system/src/Grav/Console/Cli/BackupCommand.php b/system/src/Grav/Console/Cli/BackupCommand.php
index a85e10933..f135d7850 100644
--- a/system/src/Grav/Console/Cli/BackupCommand.php
+++ b/system/src/Grav/Console/Cli/BackupCommand.php
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
+use ZipArchive;
use function count;
/**
@@ -62,7 +63,7 @@ class BackupCommand extends ConsoleCommand
$io = new SymfonyStyle($this->input, $this->output);
$io->title('Grav Backup');
- if (!class_exists(\ZipArchive::class)) {
+ if (!class_exists(ZipArchive::class)) {
$io->error('php-zip extension needs to be enabled!');
return 1;
}
diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php
index 795fbf123..a2c45921e 100644
--- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php
+++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php
@@ -22,6 +22,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
+use ZipArchive;
use function is_array;
use function is_callable;
@@ -72,7 +73,7 @@ class DirectInstallCommand extends ConsoleCommand
*/
protected function serve(): int
{
- if (!class_exists(\ZipArchive::class)) {
+ if (!class_exists(ZipArchive::class)) {
$io = new SymfonyStyle($this->input, $this->output);
$io->title('Direct Install');
$io->error('php-zip extension needs to be enabled!');
diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php
index 0093e0f8f..49f87f745 100644
--- a/system/src/Grav/Console/Gpm/InfoCommand.php
+++ b/system/src/Grav/Console/Gpm/InfoCommand.php
@@ -14,6 +14,7 @@ use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\ConfirmationQuestion;
+use function strlen;
/**
* Class InfoCommand
@@ -84,7 +85,7 @@ class InfoCommand extends ConsoleCommand
$this->output->writeln("Found package '{$this->input->getArgument('package')}' under the '" . ucfirst($foundPackage->package_type) . "' section");
$this->output->writeln('');
$this->output->writeln("{$foundPackage->name} [{$foundPackage->slug}]");
- $this->output->writeln(str_repeat('-', \strlen($foundPackage->name) + \strlen($foundPackage->slug) + 3));
+ $this->output->writeln(str_repeat('-', strlen($foundPackage->name) + strlen($foundPackage->slug) + 3));
$this->output->writeln('' . strip_tags($foundPackage->description_plain) . '');
$this->output->writeln('');
@@ -160,7 +161,7 @@ class InfoCommand extends ConsoleCommand
}, $log['content']);
$this->output->writeln("{$title}");
- $this->output->writeln(str_repeat('-', \strlen($title)));
+ $this->output->writeln(str_repeat('-', strlen($title)));
$this->output->writeln($content);
$this->output->writeln('');
diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php
index 31a1af6a1..ef406ac63 100644
--- a/system/src/Grav/Console/Gpm/InstallCommand.php
+++ b/system/src/Grav/Console/Gpm/InstallCommand.php
@@ -23,6 +23,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
+use ZipArchive;
use function array_key_exists;
use function count;
@@ -108,7 +109,7 @@ class InstallCommand extends ConsoleCommand
*/
protected function serve(): int
{
- if (!class_exists(\ZipArchive::class)) {
+ if (!class_exists(ZipArchive::class)) {
$io = new SymfonyStyle($this->input, $this->output);
$io->title('GPM Install');
$io->error('php-zip extension needs to be enabled!');
diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
index 6288bb80b..6bc8420c3 100644
--- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
+++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
@@ -21,6 +21,7 @@ use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
+use ZipArchive;
use function is_callable;
use function strlen;
@@ -96,7 +97,7 @@ class SelfupgradeCommand extends ConsoleCommand
*/
protected function serve(): int
{
- if (!class_exists(\ZipArchive::class)) {
+ if (!class_exists(ZipArchive::class)) {
$io = new SymfonyStyle($this->input, $this->output);
$io->title('GPM Self Upgrade');
$io->error('php-zip extension needs to be enabled!');
diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php
index 2ea5ad467..e8187c5e6 100644
--- a/system/src/Grav/Console/Gpm/UpdateCommand.php
+++ b/system/src/Grav/Console/Gpm/UpdateCommand.php
@@ -18,6 +18,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
+use ZipArchive;
use function array_key_exists;
use function count;
@@ -109,7 +110,7 @@ class UpdateCommand extends ConsoleCommand
*/
protected function serve(): int
{
- if (!class_exists(\ZipArchive::class)) {
+ if (!class_exists(ZipArchive::class)) {
$io = new SymfonyStyle($this->input, $this->output);
$io->title('GPM Update');
$io->error('php-zip extension needs to be enabled!');
diff --git a/system/src/Grav/Framework/Acl/Access.php b/system/src/Grav/Framework/Acl/Access.php
index ff2af3f34..1717daa18 100644
--- a/system/src/Grav/Framework/Acl/Access.php
+++ b/system/src/Grav/Framework/Acl/Access.php
@@ -9,13 +9,24 @@
namespace Grav\Framework\Acl;
+use ArrayIterator;
+use Countable;
use Grav\Common\Utils;
+use IteratorAggregate;
+use JsonSerializable;
+use RuntimeException;
+use Traversable;
+use function count;
+use function is_array;
+use function is_bool;
+use function is_string;
+use function strlen;
/**
* Class Access
* @package Grav\Framework\Acl
*/
-class Access implements \JsonSerializable, \IteratorAggregate, \Countable
+class Access implements JsonSerializable, IteratorAggregate, Countable
{
/** @var string */
private $name;
@@ -69,7 +80,7 @@ class Access implements \JsonSerializable, \IteratorAggregate, \Countable
$this->inherited += $parent->inherited + array_fill_keys(array_keys($inherited), $name ?? $parent->getName());
$acl = array_replace($acl, $inherited);
if (null === $acl) {
- throw new \RuntimeException('Internal error');
+ throw new RuntimeException('Internal error');
}
$this->acl = $acl;
@@ -155,11 +166,11 @@ class Access implements \JsonSerializable, \IteratorAggregate, \Countable
}
/**
- * @return \Traversable
+ * @return Traversable
*/
- public function getIterator(): \Traversable
+ public function getIterator(): Traversable
{
- return new \ArrayIterator($this->acl);
+ return new ArrayIterator($this->acl);
}
/**
diff --git a/system/src/Grav/Framework/Acl/Action.php b/system/src/Grav/Framework/Acl/Action.php
index e37606ef8..4bce7c582 100644
--- a/system/src/Grav/Framework/Acl/Action.php
+++ b/system/src/Grav/Framework/Acl/Action.php
@@ -9,13 +9,20 @@
namespace Grav\Framework\Acl;
+use ArrayIterator;
+use Countable;
use Grav\Common\Inflector;
+use IteratorAggregate;
+use RuntimeException;
+use Traversable;
+use function count;
+use function strlen;
/**
* Class Action
* @package Grav\Framework\Acl
*/
-class Action implements \IteratorAggregate, \Countable
+class Action implements IteratorAggregate, Countable
{
/** @var string */
public $name;
@@ -155,7 +162,7 @@ class Action implements \IteratorAggregate, \Countable
public function addChild(Action $child): void
{
if (strpos($child->name, "{$this->name}.") !== 0) {
- throw new \RuntimeException('Bad child');
+ throw new RuntimeException('Bad child');
}
$child->setParent($this);
@@ -165,11 +172,11 @@ class Action implements \IteratorAggregate, \Countable
}
/**
- * @return \Traversable
+ * @return Traversable
*/
- public function getIterator(): \Traversable
+ public function getIterator(): Traversable
{
- return new \ArrayIterator($this->children);
+ return new ArrayIterator($this->children);
}
/**
diff --git a/system/src/Grav/Framework/Acl/Permissions.php b/system/src/Grav/Framework/Acl/Permissions.php
index 75499ce94..b9aa5e118 100644
--- a/system/src/Grav/Framework/Acl/Permissions.php
+++ b/system/src/Grav/Framework/Acl/Permissions.php
@@ -9,6 +9,11 @@
namespace Grav\Framework\Acl;
+use ArrayIterator;
+use RecursiveIteratorIterator;
+use RuntimeException;
+use Traversable;
+
/**
* Class Permissions
* @package Grav\Framework\Acl
@@ -30,7 +35,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
public function getInstances(): array
{
$iterator = new RecursiveActionIterator($this->actions);
- $recursive = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
+ $recursive = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
return iterator_to_array($recursive);
}
@@ -138,7 +143,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
{
$types = array_replace($this->types, $types);
if (null === $types) {
- throw new \RuntimeException('Internal error');
+ throw new RuntimeException('Internal error');
}
$this->types = $types;
@@ -178,7 +183,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function offsetSet($offset, $value): void
{
- throw new \RuntimeException(__METHOD__ . '(): Not Supported');
+ throw new RuntimeException(__METHOD__ . '(): Not Supported');
}
/**
@@ -187,7 +192,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function offsetUnset($offset): void
{
- throw new \RuntimeException(__METHOD__ . '(): Not Supported');
+ throw new RuntimeException(__METHOD__ . '(): Not Supported');
}
/**
@@ -199,11 +204,11 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
}
/**
- * @return \ArrayIterator|\Traversable
+ * @return ArrayIterator|Traversable
*/
public function getIterator()
{
- return new \ArrayIterator($this->actions);
+ return new ArrayIterator($this->actions);
}
/**
diff --git a/system/src/Grav/Framework/Acl/PermissionsReader.php b/system/src/Grav/Framework/Acl/PermissionsReader.php
index ae3538aa8..8de6df906 100644
--- a/system/src/Grav/Framework/Acl/PermissionsReader.php
+++ b/system/src/Grav/Framework/Acl/PermissionsReader.php
@@ -10,6 +10,9 @@
namespace Grav\Framework\Acl;
use Grav\Common\File\CompiledYamlFile;
+use RuntimeException;
+use stdClass;
+use function is_array;
/**
* Class PermissionsReader
@@ -102,7 +105,7 @@ class PermissionsReader
foreach ($dependencies as $type => $dep) {
foreach (get_object_vars($dep) as $k => &$val) {
if (null === $val) {
- $val = $dependencies[$k] ?? new \stdClass();
+ $val = $dependencies[$k] ?? new stdClass();
}
}
unset($val);
@@ -110,7 +113,7 @@ class PermissionsReader
$encoded = json_encode($dependencies);
if ($encoded === false) {
- throw new \RuntimeException('json_encode(): failed to encode dependencies');
+ throw new RuntimeException('json_encode(): failed to encode dependencies');
}
$dependencies = json_decode($encoded, true);
@@ -170,7 +173,7 @@ class PermissionsReader
$action = array_replace_recursive(...$scopes);
if (null === $action) {
- throw new \RuntimeException('Internal error');
+ throw new RuntimeException('Internal error');
}
$newType = $defaults['type'] ?? null;
diff --git a/system/src/Grav/Framework/Acl/RecursiveActionIterator.php b/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
index 1866a0478..05574db5b 100644
--- a/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
+++ b/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
@@ -9,6 +9,7 @@
namespace Grav\Framework\Acl;
+use RecursiveIterator;
use RocketTheme\Toolbox\ArrayTraits\Constructor;
use RocketTheme\Toolbox\ArrayTraits\Countable;
use RocketTheme\Toolbox\ArrayTraits\Iterator;
@@ -17,7 +18,7 @@ use RocketTheme\Toolbox\ArrayTraits\Iterator;
* Class Action
* @package Grav\Framework\Acl
*/
-class RecursiveActionIterator implements \RecursiveIterator, \Countable
+class RecursiveActionIterator implements RecursiveIterator, \Countable
{
use Constructor, Iterator, Countable;
diff --git a/system/src/Grav/Framework/Cache/AbstractCache.php b/system/src/Grav/Framework/Cache/AbstractCache.php
index 9144f2e0a..177db0b36 100644
--- a/system/src/Grav/Framework/Cache/AbstractCache.php
+++ b/system/src/Grav/Framework/Cache/AbstractCache.php
@@ -9,6 +9,7 @@
namespace Grav\Framework\Cache;
+use DateInterval;
use Psr\SimpleCache\InvalidArgumentException;
/**
@@ -21,7 +22,7 @@ abstract class AbstractCache implements CacheInterface
/**
* @param string $namespace
- * @param null|int|\DateInterval $defaultLifetime
+ * @param null|int|DateInterval $defaultLifetime
* @throws InvalidArgumentException
*/
public function __construct($namespace = '', $defaultLifetime = null)
diff --git a/system/src/Grav/Framework/Cache/Adapter/ChainCache.php b/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
index 0c0e3ef81..0c995f2ab 100644
--- a/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
@@ -9,9 +9,12 @@
namespace Grav\Framework\Cache\Adapter;
+use DateInterval;
use Grav\Framework\Cache\AbstractCache;
use Grav\Framework\Cache\CacheInterface;
use Grav\Framework\Cache\Exception\InvalidArgumentException;
+use function count;
+use function get_class;
/**
* Cache class for PSR-16 compatible "Simple Cache" implementation using chained cache adapters.
@@ -29,7 +32,7 @@ class ChainCache extends AbstractCache
/**
* Chain Cache constructor.
* @param array $caches
- * @param null|int|\DateInterval $defaultLifetime
+ * @param null|int|DateInterval $defaultLifetime
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
*/
public function __construct(array $caches, $defaultLifetime = null)
@@ -45,7 +48,7 @@ class ChainCache extends AbstractCache
throw new InvalidArgumentException(
sprintf(
"The class '%s' does not implement the '%s' interface",
- \get_class($cache),
+ get_class($cache),
CacheInterface::class
)
);
@@ -53,7 +56,7 @@ class ChainCache extends AbstractCache
}
$this->caches = array_values($caches);
- $this->count = \count($caches);
+ $this->count = count($caches);
}
/**
diff --git a/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php b/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
index 933fd6ac3..b6fcd357f 100644
--- a/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
@@ -9,6 +9,7 @@
namespace Grav\Framework\Cache\Adapter;
+use DateInterval;
use Doctrine\Common\Cache\CacheProvider;
use Grav\Framework\Cache\AbstractCache;
use Grav\Framework\Cache\Exception\InvalidArgumentException;
@@ -27,7 +28,7 @@ class DoctrineCache extends AbstractCache
*
* @param CacheProvider $doctrineCache
* @param string $namespace
- * @param null|int|\DateInterval $defaultLifetime
+ * @param null|int|DateInterval $defaultLifetime
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
*/
public function __construct(CacheProvider $doctrineCache, $namespace = '', $defaultLifetime = null)
diff --git a/system/src/Grav/Framework/Cache/Adapter/FileCache.php b/system/src/Grav/Framework/Cache/Adapter/FileCache.php
index e6a0b5f8a..597f4341e 100644
--- a/system/src/Grav/Framework/Cache/Adapter/FileCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/FileCache.php
@@ -9,9 +9,15 @@
namespace Grav\Framework\Cache\Adapter;
+use ErrorException;
+use FilesystemIterator;
use Grav\Framework\Cache\AbstractCache;
use Grav\Framework\Cache\Exception\CacheException;
use Grav\Framework\Cache\Exception\InvalidArgumentException;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+use RuntimeException;
+use function strlen;
/**
* Cache class for PSR-16 compatible "Simple Cache" implementation using file backend.
@@ -32,7 +38,7 @@ class FileCache extends AbstractCache
* @param string $namespace
* @param int|null $defaultLifetime
* @param string|null $folder
- * @throws InvalidArgumentException
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
*/
public function __construct($namespace = '', $defaultLifetime = null, $folder = null)
{
@@ -106,7 +112,7 @@ class FileCache extends AbstractCache
public function doClear()
{
$result = true;
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS));
+ $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->directory, FilesystemIterator::SKIP_DOTS));
foreach ($iterator as $file) {
$result = ($file->isDir() || @unlink($file) || !file_exists($file)) && $result;
@@ -203,7 +209,7 @@ class FileCache extends AbstractCache
/**
* @param string $dir
* @return void
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
private function mkdir($dir)
{
@@ -218,7 +224,7 @@ class FileCache extends AbstractCache
// Take yet another look, make sure that the folder doesn't exist.
clearstatcache(true, $dir);
if (!@is_dir($dir)) {
- throw new \RuntimeException(sprintf('Unable to create directory: %s', $dir));
+ throw new RuntimeException(sprintf('Unable to create directory: %s', $dir));
}
}
}
@@ -230,11 +236,11 @@ class FileCache extends AbstractCache
* @param int $line
* @return bool
* @internal
- * @throws \ErrorException
+ * @throws ErrorException
*/
public static function throwError($type, $message, $file, $line)
{
- throw new \ErrorException($message, 0, $type, $file, $line);
+ throw new ErrorException($message, 0, $type, $file, $line);
}
/**
diff --git a/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php b/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
index 2f416e354..f8bb9bdc4 100644
--- a/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
@@ -10,6 +10,7 @@
namespace Grav\Framework\Cache\Adapter;
use Grav\Framework\Cache\AbstractCache;
+use function array_key_exists;
/**
* Cache class for PSR-16 compatible "Simple Cache" implementation using in memory backend.
diff --git a/system/src/Grav/Framework/Cache/CacheTrait.php b/system/src/Grav/Framework/Cache/CacheTrait.php
index 8dd0407a0..dc00712b3 100644
--- a/system/src/Grav/Framework/Cache/CacheTrait.php
+++ b/system/src/Grav/Framework/Cache/CacheTrait.php
@@ -9,7 +9,19 @@
namespace Grav\Framework\Cache;
+use DateInterval;
+use DateTime;
use Grav\Framework\Cache\Exception\InvalidArgumentException;
+use stdClass;
+use Traversable;
+use function array_key_exists;
+use function get_class;
+use function gettype;
+use function is_array;
+use function is_int;
+use function is_object;
+use function is_string;
+use function strlen;
/**
* Cache trait for PSR-16 compatible "Simple Cache" implementation
@@ -21,7 +33,7 @@ trait CacheTrait
private $namespace = '';
/** @var int|null */
private $defaultLifetime = null;
- /** @var \stdClass */
+ /** @var stdClass */
private $miss;
/** @var bool */
private $validation = true;
@@ -30,7 +42,7 @@ trait CacheTrait
* Always call from constructor.
*
* @param string $namespace
- * @param null|int|\DateInterval $defaultLifetime
+ * @param null|int|DateInterval $defaultLifetime
* @return void
* @throws InvalidArgumentException
*/
@@ -38,7 +50,7 @@ trait CacheTrait
{
$this->namespace = (string) $namespace;
$this->defaultLifetime = $this->convertTtl($defaultLifetime);
- $this->miss = new \stdClass;
+ $this->miss = new stdClass;
}
/**
@@ -84,7 +96,7 @@ trait CacheTrait
/**
* @param string $key
* @param mixed $value
- * @param null|int|\DateInterval $ttl
+ * @param null|int|DateInterval $ttl
* @return bool
* @throws InvalidArgumentException
*/
@@ -126,14 +138,14 @@ trait CacheTrait
*/
public function getMultiple($keys, $default = null)
{
- if ($keys instanceof \Traversable) {
+ if ($keys instanceof Traversable) {
$keys = iterator_to_array($keys, false);
- } elseif (!\is_array($keys)) {
- $isObject = \is_object($keys);
+ } elseif (!is_array($keys)) {
+ $isObject = is_object($keys);
throw new InvalidArgumentException(
sprintf(
'Cache keys must be array or Traversable, "%s" given',
- $isObject ? \get_class($keys) : \gettype($keys)
+ $isObject ? get_class($keys) : gettype($keys)
)
);
}
@@ -166,20 +178,20 @@ trait CacheTrait
/**
* @param iterable $values
- * @param null|int|\DateInterval $ttl
+ * @param null|int|DateInterval $ttl
* @return bool
* @throws InvalidArgumentException
*/
public function setMultiple($values, $ttl = null)
{
- if ($values instanceof \Traversable) {
+ if ($values instanceof Traversable) {
$values = iterator_to_array($values, true);
} elseif (!is_array($values)) {
- $isObject = \is_object($values);
+ $isObject = is_object($values);
throw new InvalidArgumentException(
sprintf(
'Cache values must be array or Traversable, "%s" given',
- $isObject ? \get_class($values) : \gettype($values)
+ $isObject ? get_class($values) : gettype($values)
)
);
}
@@ -205,14 +217,14 @@ trait CacheTrait
*/
public function deleteMultiple($keys)
{
- if ($keys instanceof \Traversable) {
+ if ($keys instanceof Traversable) {
$keys = iterator_to_array($keys, false);
} elseif (!is_array($keys)) {
- $isObject = \is_object($keys);
+ $isObject = is_object($keys);
throw new InvalidArgumentException(
sprintf(
'Cache keys must be array or Traversable, "%s" given',
- $isObject ? \get_class($keys) : \gettype($keys)
+ $isObject ? get_class($keys) : gettype($keys)
)
);
}
@@ -295,20 +307,20 @@ trait CacheTrait
*/
protected function validateKey($key)
{
- if (!\is_string($key)) {
+ if (!is_string($key)) {
throw new InvalidArgumentException(
sprintf(
'Cache key must be string, "%s" given',
- \is_object($key) ? \get_class($key) : \gettype($key)
+ is_object($key) ? get_class($key) : gettype($key)
)
);
}
if (!isset($key[0])) {
throw new InvalidArgumentException('Cache key length must be greater than zero');
}
- if (\strlen($key) > 64) {
+ if (strlen($key) > 64) {
throw new InvalidArgumentException(
- sprintf('Cache key length must be less than 65 characters, key had %d characters', \strlen($key))
+ sprintf('Cache key length must be less than 65 characters, key had %d characters', strlen($key))
);
}
if (strpbrk($key, '{}()/\@:') !== false) {
@@ -335,7 +347,7 @@ trait CacheTrait
}
/**
- * @param null|int|\DateInterval $ttl
+ * @param null|int|DateInterval $ttl
* @return int|null
* @throws InvalidArgumentException
*/
@@ -345,19 +357,19 @@ trait CacheTrait
return $this->getDefaultLifetime();
}
- if (\is_int($ttl)) {
+ if (is_int($ttl)) {
return $ttl;
}
- if ($ttl instanceof \DateInterval) {
- $date = \DateTime::createFromFormat('U', '0');
+ if ($ttl instanceof DateInterval) {
+ $date = DateTime::createFromFormat('U', '0');
$ttl = $date ? (int)$date->add($ttl)->format('U') : 0;
}
throw new InvalidArgumentException(
sprintf(
'Expiration date must be an integer, a DateInterval or null, "%s" given',
- \is_object($ttl) ? \get_class($ttl) : \gettype($ttl)
+ is_object($ttl) ? get_class($ttl) : gettype($ttl)
)
);
}
diff --git a/system/src/Grav/Framework/Cache/Exception/CacheException.php b/system/src/Grav/Framework/Cache/Exception/CacheException.php
index 2124528ad..6a8ab2abe 100644
--- a/system/src/Grav/Framework/Cache/Exception/CacheException.php
+++ b/system/src/Grav/Framework/Cache/Exception/CacheException.php
@@ -9,12 +9,13 @@
namespace Grav\Framework\Cache\Exception;
+use Exception;
use Psr\SimpleCache\CacheException as SimpleCacheException;
/**
* CacheException class for PSR-16 compatible "Simple Cache" implementation.
* @package Grav\Framework\Cache\Exception
*/
-class CacheException extends \Exception implements SimpleCacheException
+class CacheException extends Exception implements SimpleCacheException
{
}
diff --git a/system/src/Grav/Framework/Collection/AbstractFileCollection.php b/system/src/Grav/Framework/Collection/AbstractFileCollection.php
index 440a86a14..82a5c2038 100644
--- a/system/src/Grav/Framework/Collection/AbstractFileCollection.php
+++ b/system/src/Grav/Framework/Collection/AbstractFileCollection.php
@@ -11,9 +11,14 @@ namespace Grav\Framework\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor;
+use FilesystemIterator;
use Grav\Common\Grav;
+use RecursiveDirectoryIterator;
use RocketTheme\Toolbox\ResourceLocator\RecursiveUniformResourceIterator;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
+use RuntimeException;
+use SeekableIterator;
+use function array_slice;
/**
* Collection of objects stored into a filesystem.
@@ -28,7 +33,7 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
{
/** @var string */
protected $path;
- /** @var \RecursiveDirectoryIterator|RecursiveUniformResourceIterator */
+ /** @var RecursiveDirectoryIterator|RecursiveUniformResourceIterator */
protected $iterator;
/** @var callable */
protected $createObjectFunction;
@@ -89,7 +94,7 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
$next = ClosureExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next);
}
if (null === $next) {
- throw new \RuntimeException('Criteria is missing orderings');
+ throw new RuntimeException('Criteria is missing orderings');
}
uasort($filtered, $next);
@@ -101,7 +106,7 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
$length = $criteria->getMaxResults();
if ($offset || $length) {
- $filtered = \array_slice($filtered, (int)$offset, $length);
+ $filtered = array_slice($filtered, (int)$offset, $length);
}
return new ArrayCollection($filtered);
@@ -112,15 +117,15 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
*/
protected function setIterator()
{
- $iteratorFlags = \RecursiveDirectoryIterator::SKIP_DOTS + \FilesystemIterator::UNIX_PATHS
- + \FilesystemIterator::CURRENT_AS_SELF + \FilesystemIterator::FOLLOW_SYMLINKS;
+ $iteratorFlags = RecursiveDirectoryIterator::SKIP_DOTS + FilesystemIterator::UNIX_PATHS
+ + FilesystemIterator::CURRENT_AS_SELF + FilesystemIterator::FOLLOW_SYMLINKS;
if (strpos($this->path, '://')) {
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
$this->iterator = $locator->getRecursiveIterator($this->path, $iteratorFlags);
} else {
- $this->iterator = new \RecursiveDirectoryIterator($this->path, $iteratorFlags);
+ $this->iterator = new RecursiveDirectoryIterator($this->path, $iteratorFlags);
}
}
@@ -154,18 +159,18 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
}
/**
- * @param \SeekableIterator $iterator
+ * @param SeekableIterator $iterator
* @param int $nestingLimit
* @return array
*/
- protected function doInitializeByIterator(\SeekableIterator $iterator, $nestingLimit)
+ protected function doInitializeByIterator(SeekableIterator $iterator, $nestingLimit)
{
$children = [];
$objects = [];
$filter = $this->filterFunction;
$objectFunction = $this->createObjectFunction;
- /** @var \RecursiveDirectoryIterator $file */
+ /** @var RecursiveDirectoryIterator $file */
foreach ($iterator as $file) {
// Skip files if they shouldn't be included.
if (!($this->flags & static::INCLUDE_FILES) && $file->isFile()) {
@@ -215,7 +220,7 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
}
/**
- * @param \RecursiveDirectoryIterator $file
+ * @param RecursiveDirectoryIterator $file
* @return object
*/
protected function createObject($file)
diff --git a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
index 171c49c84..e3900a5da 100644
--- a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
+++ b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
@@ -13,6 +13,10 @@ use ArrayIterator;
use Closure;
use Grav\Framework\Compat\Serializable;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
+use InvalidArgumentException;
+use function array_key_exists;
+use function array_slice;
+use function count;
/**
* Abstract Index Collection.
@@ -248,7 +252,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
*/
public function count()
{
- return \count($this->entries);
+ return count($this->entries);
}
/**
@@ -257,7 +261,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
public function set($key, $value)
{
if (!$this->isAllowedElement($value)) {
- throw new \InvalidArgumentException('Invalid argument $value');
+ throw new InvalidArgumentException('Invalid argument $value');
}
$this->entries[$key] = $this->getElementMeta($value);
@@ -269,7 +273,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
public function add($element)
{
if (!$this->isAllowedElement($element)) {
- throw new \InvalidArgumentException('Invalid argument $element');
+ throw new InvalidArgumentException('Invalid argument $element');
}
$this->entries[$this->getCurrentKey($element)] = $this->getElementMeta($element);
@@ -350,7 +354,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
*/
public function slice($offset, $length = null)
{
- return $this->loadElements(\array_slice($this->entries, $offset, $length, true));
+ return $this->loadElements(array_slice($this->entries, $offset, $length, true));
}
/**
@@ -360,7 +364,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
*/
public function limit($start, $limit = null)
{
- return $this->createFrom(\array_slice($this->entries, $start, $limit, true));
+ return $this->createFrom(array_slice($this->entries, $start, $limit, true));
}
/**
diff --git a/system/src/Grav/Framework/ContentBlock/ContentBlock.php b/system/src/Grav/Framework/ContentBlock/ContentBlock.php
index ef9173ded..bd6a2484b 100644
--- a/system/src/Grav/Framework/ContentBlock/ContentBlock.php
+++ b/system/src/Grav/Framework/ContentBlock/ContentBlock.php
@@ -9,7 +9,11 @@
namespace Grav\Framework\ContentBlock;
+use Exception;
use Grav\Framework\Compat\Serializable;
+use InvalidArgumentException;
+use RuntimeException;
+use function get_class;
/**
* Class to create nested blocks of content.
@@ -54,7 +58,7 @@ class ContentBlock implements ContentBlockInterface
/**
* @param array $serialized
* @return ContentBlockInterface
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public static function fromArray(array $serialized)
{
@@ -63,14 +67,14 @@ class ContentBlock implements ContentBlockInterface
$id = $serialized['id'] ?? null;
if (!$type || !$id || !is_a($type, ContentBlockInterface::class, true)) {
- throw new \InvalidArgumentException('Bad data');
+ throw new InvalidArgumentException('Bad data');
}
/** @var ContentBlockInterface $instance */
$instance = new $type($id);
$instance->build($serialized);
- } catch (\Exception $e) {
- throw new \InvalidArgumentException(sprintf('Cannot unserialize Block: %s', $e->getMessage()), $e->getCode(), $e);
+ } catch (Exception $e) {
+ throw new InvalidArgumentException(sprintf('Cannot unserialize Block: %s', $e->getMessage()), $e->getCode(), $e);
}
return $instance;
@@ -114,7 +118,7 @@ class ContentBlock implements ContentBlockInterface
}
$array = [
- '_type' => \get_class($this),
+ '_type' => get_class($this),
'_version' => $this->version,
'id' => $this->id,
'cached' => $this->cached
@@ -161,7 +165,7 @@ class ContentBlock implements ContentBlockInterface
{
try {
return $this->toString();
- } catch (\Exception $e) {
+ } catch (Exception $e) {
return sprintf('Error while rendering block: %s', $e->getMessage());
}
}
@@ -169,7 +173,7 @@ class ContentBlock implements ContentBlockInterface
/**
* @param array $serialized
* @return void
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function build(array $serialized)
{
@@ -286,13 +290,13 @@ class ContentBlock implements ContentBlockInterface
/**
* @param array $serialized
* @return void
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
protected function checkVersion(array $serialized)
{
$version = isset($serialized['_version']) ? (int) $serialized['_version'] : 1;
if ($version !== $this->version) {
- throw new \RuntimeException(sprintf('Unsupported version %s', $version));
+ throw new RuntimeException(sprintf('Unsupported version %s', $version));
}
}
}
diff --git a/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php b/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
index 6eff141e6..6af9aa23b 100644
--- a/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
+++ b/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
@@ -9,11 +9,13 @@
namespace Grav\Framework\ContentBlock;
+use Serializable;
+
/**
* ContentBlock Interface
* @package Grav\Framework\ContentBlock
*/
-interface ContentBlockInterface extends \Serializable
+interface ContentBlockInterface extends Serializable
{
/**
* @param string|null $id
diff --git a/system/src/Grav/Framework/ContentBlock/HtmlBlock.php b/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
index 3aaf80631..1853e7c7e 100644
--- a/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
+++ b/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
@@ -9,6 +9,10 @@
namespace Grav\Framework\ContentBlock;
+use RuntimeException;
+use function is_array;
+use function is_string;
+
/**
* HtmlBlock
*
@@ -104,7 +108,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
/**
* @param array $serialized
* @return void
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function build(array $serialized)
{
@@ -138,7 +142,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
*/
public function addStyle($element, $priority = 0, $location = 'head')
{
- if (!\is_array($element)) {
+ if (!is_array($element)) {
$element = ['href' => (string) $element];
}
if (empty($element['href'])) {
@@ -182,7 +186,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
*/
public function addInlineStyle($element, $priority = 0, $location = 'head')
{
- if (!\is_array($element)) {
+ if (!is_array($element)) {
$element = ['content' => (string) $element];
}
if (empty($element['content'])) {
@@ -213,7 +217,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
*/
public function addScript($element, $priority = 0, $location = 'head')
{
- if (!\is_array($element)) {
+ if (!is_array($element)) {
$element = ['src' => (string) $element];
}
if (empty($element['src'])) {
@@ -225,8 +229,8 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
$src = $element['src'];
$type = !empty($element['type']) ? (string) $element['type'] : 'text/javascript';
- $defer = isset($element['defer']) ? true : false;
- $async = isset($element['async']) ? true : false;
+ $defer = isset($element['defer']);
+ $async = isset($element['async']);
$handle = !empty($element['handle']) ? (string) $element['handle'] : '';
$this->scripts[$location][md5($src) . sha1($src)] = [
@@ -250,7 +254,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
*/
public function addInlineScript($element, $priority = 0, $location = 'head')
{
- if (!\is_array($element)) {
+ if (!is_array($element)) {
$element = ['content' => (string) $element];
}
if (empty($element['content'])) {
@@ -281,7 +285,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
*/
public function addHtml($html, $priority = 0, $location = 'bottom')
{
- if (empty($html) || !\is_string($html)) {
+ if (empty($html) || !is_string($html)) {
return false;
}
if (!isset($this->html[$location])) {
diff --git a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
index c20af838f..551301c90 100644
--- a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
+++ b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
@@ -19,6 +19,9 @@ use Grav\Framework\RequestHandler\Exception\RequestException;
use Grav\Framework\Route\Route;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
+use Throwable;
+use function get_class;
+use function in_array;
/**
* Trait ControllerResponseTrait
@@ -94,10 +97,10 @@ trait ControllerResponseTrait
}
/**
- * @param \Throwable $e
+ * @param Throwable $e
* @return ResponseInterface
*/
- protected function createErrorResponse(\Throwable $e): ResponseInterface
+ protected function createErrorResponse(Throwable $e): ResponseInterface
{
$response = $this->getErrorJson($e);
$message = $response['message'];
@@ -130,10 +133,10 @@ trait ControllerResponseTrait
}
/**
- * @param \Throwable $e
+ * @param Throwable $e
* @return ResponseInterface
*/
- protected function createJsonErrorResponse(\Throwable $e): ResponseInterface
+ protected function createJsonErrorResponse(Throwable $e): ResponseInterface
{
$response = $this->getErrorJson($e);
$reason = $e instanceof RequestException ? $e->getHttpReason() : null;
@@ -142,10 +145,10 @@ trait ControllerResponseTrait
}
/**
- * @param \Throwable $e
+ * @param Throwable $e
* @return array
*/
- protected function getErrorJson(\Throwable $e): array
+ protected function getErrorJson(Throwable $e): array
{
$code = $this->getErrorCode($e instanceof RequestException ? $e->getHttpCode() : $e->getCode());
$message = $e->getMessage();
@@ -163,7 +166,7 @@ trait ControllerResponseTrait
$debugger = Grav::instance()['debugger'];
if ($debugger->enabled()) {
$response['error'] += [
- 'type' => \get_class($e),
+ 'type' => get_class($e),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => explode("\n", $e->getTraceAsString())
diff --git a/system/src/Grav/Framework/File/AbstractFile.php b/system/src/Grav/Framework/File/AbstractFile.php
index 452a3e976..6b53d12c5 100644
--- a/system/src/Grav/Framework/File/AbstractFile.php
+++ b/system/src/Grav/Framework/File/AbstractFile.php
@@ -11,9 +11,11 @@ declare(strict_types=1);
namespace Grav\Framework\File;
+use Exception;
use Grav\Framework\Compat\Serializable;
use Grav\Framework\File\Interfaces\FileInterface;
use Grav\Framework\Filesystem\Filesystem;
+use RuntimeException;
/**
* Class AbstractFile
@@ -184,13 +186,13 @@ class AbstractFile implements FileInterface
{
if (!$this->handle) {
if (!$this->mkdir($this->getPath())) {
- throw new \RuntimeException('Creating directory failed for ' . $this->filepath);
+ throw new RuntimeException('Creating directory failed for ' . $this->filepath);
}
$this->handle = @fopen($this->filepath, 'cb+') ?: null;
if (!$this->handle) {
$error = error_get_last();
- throw new \RuntimeException("Opening file for writing failed on error {$error['message']}");
+ throw new RuntimeException("Opening file for writing failed on error {$error['message']}");
}
}
@@ -273,7 +275,7 @@ class AbstractFile implements FileInterface
$dir = $this->getPath();
if (!$this->mkdir($dir)) {
- throw new \RuntimeException('Creating directory failed for ' . $filepath);
+ throw new RuntimeException('Creating directory failed for ' . $filepath);
}
try {
@@ -288,7 +290,7 @@ class AbstractFile implements FileInterface
// Support for symlinks.
$realpath = is_link($filepath) ? realpath($filepath) : $filepath;
if ($realpath === false) {
- throw new \RuntimeException('Failed to save file ' . $filepath);
+ throw new RuntimeException('Failed to save file ' . $filepath);
}
// Create file with a temporary name and rename it to make the save action atomic.
@@ -300,12 +302,12 @@ class AbstractFile implements FileInterface
$tmp = false;
}
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$tmp = false;
}
if ($tmp === false) {
- throw new \RuntimeException('Failed to save file ' . $filepath);
+ throw new RuntimeException('Failed to save file ' . $filepath);
}
// Touch the directory as well, thus marking it modified.
@@ -339,7 +341,7 @@ class AbstractFile implements FileInterface
/**
* @param string $dir
* @return bool
- * @throws \RuntimeException
+ * @throws RuntimeException
* @internal
*/
protected function mkdir(string $dir): bool
diff --git a/system/src/Grav/Framework/File/DataFile.php b/system/src/Grav/Framework/File/DataFile.php
index 108e4da32..8bf4ad500 100644
--- a/system/src/Grav/Framework/File/DataFile.php
+++ b/system/src/Grav/Framework/File/DataFile.php
@@ -13,6 +13,7 @@ namespace Grav\Framework\File;
use Grav\Framework\File\Interfaces\FileFormatterInterface;
use RuntimeException;
+use function is_string;
/**
* Class DataFile
@@ -60,7 +61,7 @@ class DataFile extends AbstractFile
*/
public function save($data): void
{
- if (\is_string($data)) {
+ if (is_string($data)) {
// Make sure that the string is valid data.
try {
$this->formatter->decode($data);
diff --git a/system/src/Grav/Framework/File/File.php b/system/src/Grav/Framework/File/File.php
index d9417044f..ce431c41c 100644
--- a/system/src/Grav/Framework/File/File.php
+++ b/system/src/Grav/Framework/File/File.php
@@ -11,6 +11,9 @@ declare(strict_types=1);
namespace Grav\Framework\File;
+use RuntimeException;
+use function is_string;
+
/**
* Class File
* @package Grav\Framework\File
@@ -32,8 +35,8 @@ class File extends AbstractFile
*/
public function save($data): void
{
- if (!\is_string($data)) {
- throw new \RuntimeException('Cannot save data, string required');
+ if (!is_string($data)) {
+ throw new RuntimeException('Cannot save data, string required');
}
parent::save($data);
diff --git a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
index 185e5e4a6..49ec9bb92 100644
--- a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
@@ -13,6 +13,7 @@ namespace Grav\Framework\File\Formatter;
use Grav\Framework\Compat\Serializable;
use Grav\Framework\File\Interfaces\FileFormatterInterface;
+use function is_string;
/**
* Abstract file formatter.
@@ -42,7 +43,7 @@ abstract class AbstractFormatter implements FileFormatterInterface
{
$mime = $this->getConfig('mime');
- return \is_string($mime) ? $mime : 'application/octet-stream';
+ return is_string($mime) ? $mime : 'application/octet-stream';
}
/**
@@ -66,7 +67,7 @@ abstract class AbstractFormatter implements FileFormatterInterface
$extensions = $this->getConfig('file_extension');
// Call fails on bad configuration.
- return \is_string($extensions) ? [$extensions] : $extensions;
+ return is_string($extensions) ? [$extensions] : $extensions;
}
/**
diff --git a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
index ed104adc9..1f7158abb 100644
--- a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
@@ -11,7 +11,14 @@ declare(strict_types=1);
namespace Grav\Framework\File\Formatter;
+use Exception;
use Grav\Framework\File\Interfaces\FileFormatterInterface;
+use JsonSerializable;
+use RuntimeException;
+use stdClass;
+use function is_array;
+use function is_object;
+use function is_scalar;
/**
* Class CsvFormatter
@@ -81,13 +88,13 @@ class CsvFormatter extends AbstractFormatter
$delimiter = $delimiter ?? $this->getDelimiter();
$lines = preg_split('/\r\n|\r|\n/', $data);
if ($lines === false) {
- throw new \RuntimeException('Decoding CSV failed');
+ throw new RuntimeException('Decoding CSV failed');
}
// Get the field names
$headerStr = array_shift($lines);
if (!$headerStr) {
- throw new \RuntimeException('CSV header missing');
+ throw new RuntimeException('CSV header missing');
}
$header = str_getcsv($headerStr, $delimiter);
@@ -112,8 +119,8 @@ class CsvFormatter extends AbstractFormatter
$list[] = array_combine($header, $csv_line);
}
}
- } catch (\Exception $e) {
- throw new \RuntimeException('Badly formatted CSV line: ' . $line);
+ } catch (Exception $e) {
+ throw new RuntimeException('Badly formatted CSV line: ' . $line);
}
return $list;
@@ -128,8 +135,8 @@ class CsvFormatter extends AbstractFormatter
{
foreach ($line as $key => &$value) {
// Oops, we need to convert the line to a string.
- if (!\is_scalar($value)) {
- if (is_array($value) || $value instanceof \JsonSerializable || $value instanceof \stdClass) {
+ if (!is_scalar($value)) {
+ if (is_array($value) || $value instanceof JsonSerializable || $value instanceof stdClass) {
$value = json_encode($value);
} elseif (is_object($value)) {
if (method_exists($value, 'toJson')) {
diff --git a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
index 86df07c45..88899fe07 100644
--- a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Grav\Framework\File\Formatter;
use Grav\Framework\File\Interfaces\FileFormatterInterface;
+use RuntimeException;
use function is_int;
use function is_string;
@@ -141,7 +142,7 @@ class JsonFormatter extends AbstractFormatter
$encoded = @json_encode($data, $this->getEncodeOptions());
if ($encoded === false && json_last_error() !== JSON_ERROR_NONE) {
- throw new \RuntimeException('Encoding JSON failed: ' . json_last_error_msg());
+ throw new RuntimeException('Encoding JSON failed: ' . json_last_error_msg());
}
return $encoded ?: '';
@@ -156,7 +157,7 @@ class JsonFormatter extends AbstractFormatter
$decoded = @json_decode($data, $this->getDecodeAssoc(), $this->getDecodeDepth(), $this->getDecodeOptions());
if (null === $decoded && json_last_error() !== JSON_ERROR_NONE) {
- throw new \RuntimeException('Decoding JSON failed: ' . json_last_error_msg());
+ throw new RuntimeException('Decoding JSON failed: ' . json_last_error_msg());
}
return $decoded;
diff --git a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
index 28483aaa8..f22eed442 100644
--- a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
@@ -12,6 +12,10 @@ declare(strict_types=1);
namespace Grav\Framework\File\Formatter;
use Grav\Framework\File\Interfaces\FileFormatterInterface;
+use RuntimeException;
+use stdClass;
+use function is_array;
+use function is_string;
/**
* Class SerializeFormatter
@@ -27,7 +31,7 @@ class SerializeFormatter extends AbstractFormatter
{
$config += [
'file_extension' => '.ser',
- 'decode_options' => ['allowed_classes' => [\stdClass::class]]
+ 'decode_options' => ['allowed_classes' => [stdClass::class]]
];
parent::__construct($config);
@@ -64,7 +68,7 @@ class SerializeFormatter extends AbstractFormatter
$decoded = @unserialize($data, ['allowed_classes' => $classes]);
if ($decoded === false && $data !== serialize(false)) {
- throw new \RuntimeException('Decoding serialized data failed');
+ throw new RuntimeException('Decoding serialized data failed');
}
return $this->preserveLines($decoded, ['\\n', '\\r'], ["\n", "\r"]);
@@ -80,9 +84,9 @@ class SerializeFormatter extends AbstractFormatter
*/
protected function preserveLines($data, array $search, array $replace)
{
- if (\is_string($data)) {
+ if (is_string($data)) {
$data = str_replace($search, $replace, $data);
- } elseif (\is_array($data)) {
+ } elseif (is_array($data)) {
foreach ($data as &$value) {
$value = $this->preserveLines($value, $search, $replace);
}
diff --git a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
index ad07a4bc5..316e7c44e 100644
--- a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
@@ -12,10 +12,12 @@ declare(strict_types=1);
namespace Grav\Framework\File\Formatter;
use Grav\Framework\File\Interfaces\FileFormatterInterface;
+use RuntimeException;
use Symfony\Component\Yaml\Exception\DumpException;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml as YamlParser;
use RocketTheme\Toolbox\Compat\Yaml\Yaml as FallbackYamlParser;
+use function function_exists;
/**
* Class YamlFormatter
@@ -89,7 +91,7 @@ class YamlFormatter extends AbstractFormatter
YamlParser::DUMP_EXCEPTION_ON_INVALID_TYPE
);
} catch (DumpException $e) {
- throw new \RuntimeException('Encoding YAML failed: ' . $e->getMessage(), 0, $e);
+ throw new RuntimeException('Encoding YAML failed: ' . $e->getMessage(), 0, $e);
}
}
@@ -100,7 +102,7 @@ class YamlFormatter extends AbstractFormatter
public function decode($data): array
{
// Try native PECL YAML PHP extension first if available.
- if (\function_exists('yaml_parse') && $this->useNativeDecoder()) {
+ if (function_exists('yaml_parse') && $this->useNativeDecoder()) {
// Safely decode YAML.
$saved = @ini_get('yaml.decode_php');
@ini_set('yaml.decode_php', '0');
@@ -119,7 +121,7 @@ class YamlFormatter extends AbstractFormatter
return (array) FallbackYamlParser::parse($data);
}
- throw new \RuntimeException('Decoding YAML failed: ' . $e->getMessage(), 0, $e);
+ throw new RuntimeException('Decoding YAML failed: ' . $e->getMessage(), 0, $e);
}
}
}
diff --git a/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php b/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
index eba66a8bd..cce51b288 100644
--- a/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
+++ b/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
@@ -11,6 +11,8 @@ declare(strict_types=1);
namespace Grav\Framework\File\Interfaces;
+use Serializable;
+
/**
* Defines common interface for all file formatters.
*
@@ -24,7 +26,7 @@ namespace Grav\Framework\File\Interfaces;
*
* @since 1.6
*/
-interface FileFormatterInterface extends \Serializable
+interface FileFormatterInterface extends Serializable
{
/**
* @return string
diff --git a/system/src/Grav/Framework/File/Interfaces/FileInterface.php b/system/src/Grav/Framework/File/Interfaces/FileInterface.php
index 6c3589811..fb63cee04 100644
--- a/system/src/Grav/Framework/File/Interfaces/FileInterface.php
+++ b/system/src/Grav/Framework/File/Interfaces/FileInterface.php
@@ -11,6 +11,9 @@ declare(strict_types=1);
namespace Grav\Framework\File\Interfaces;
+use RuntimeException;
+use Serializable;
+
/**
* Defines common interface for all file readers.
*
@@ -24,7 +27,7 @@ namespace Grav\Framework\File\Interfaces;
*
* @since 1.6
*/
-interface FileInterface extends \Serializable
+interface FileInterface extends Serializable
{
/**
* Get both path and filename of the file.
@@ -98,7 +101,7 @@ interface FileInterface extends \Serializable
* @param bool $block For non-blocking lock, set the parameter to `false`.
*
* @return bool Returns `true` if the file was successfully locked, `false` otherwise.
- * @throws \RuntimeException
+ * @throws RuntimeException
* @api
*/
public function lock(bool $block = true): bool;
@@ -150,7 +153,7 @@ interface FileInterface extends \Serializable
*
* @param mixed $data Data to be saved.
*
- * @throws \RuntimeException
+ * @throws RuntimeException
* @api
*/
public function save($data): void;
diff --git a/system/src/Grav/Framework/Filesystem/Filesystem.php b/system/src/Grav/Framework/Filesystem/Filesystem.php
index e65c3f307..ca826390c 100644
--- a/system/src/Grav/Framework/Filesystem/Filesystem.php
+++ b/system/src/Grav/Framework/Filesystem/Filesystem.php
@@ -12,6 +12,10 @@ declare(strict_types=1);
namespace Grav\Framework\Filesystem;
use Grav\Framework\Filesystem\Interfaces\FilesystemInterface;
+use RuntimeException;
+use function count;
+use function dirname;
+use function pathinfo;
/**
* Class Filesystem
@@ -203,7 +207,7 @@ class Filesystem implements FilesystemInterface
*/
protected function dirnameInternal(?string $scheme, string $path, int $levels = 1): array
{
- $path = \dirname($path, $levels);
+ $path = dirname($path, $levels);
if (null !== $scheme && $path === '.') {
return [$scheme, ''];
@@ -226,10 +230,10 @@ class Filesystem implements FilesystemInterface
protected function pathinfoInternal(?string $scheme, string $path, ?int $options = null)
{
if ($options) {
- return \pathinfo($path, $options);
+ return pathinfo($path, $options);
}
- $info = \pathinfo($path);
+ $info = pathinfo($path);
if (null !== $scheme) {
$info['scheme'] = $scheme;
@@ -260,7 +264,7 @@ class Filesystem implements FilesystemInterface
{
$components = explode('://', $filename, 2);
- return 2 === \count($components) ? $components : [null, $components[0]];
+ return 2 === count($components) ? $components : [null, $components[0]];
}
/**
@@ -280,7 +284,7 @@ class Filesystem implements FilesystemInterface
/**
* @param string $path
* @return string
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
protected function normalizePathPart(string $path): string
{
@@ -323,7 +327,7 @@ class Filesystem implements FilesystemInterface
$test = array_pop($list);
if ($test === null) {
// Oops, user tried to access something outside of our root folder.
- throw new \RuntimeException("Bad path {$path}");
+ throw new RuntimeException("Bad path {$path}");
}
} else {
$list[] = $part;
diff --git a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
index dab8c53fd..130f69628 100644
--- a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
+++ b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Grav\Framework\Filesystem\Interfaces;
use Grav\Framework\Filesystem\Filesystem;
+use RuntimeException;
/**
* Defines several stream-save filesystem actions.
@@ -29,7 +30,7 @@ interface FilesystemInterface
* @param string $path A filename or path, does not need to exist as a file.
* @param int $levels The number of parent directories to go up (>= 1).
* @return string Returns parent path.
- * @throws \RuntimeException
+ * @throws RuntimeException
* @api
*/
public function parent(string $path, int $levels = 1): string;
@@ -39,7 +40,7 @@ interface FilesystemInterface
*
* @param string $path A filename or path, does not need to exist as a file.
* @return string Returns normalized path.
- * @throws \RuntimeException
+ * @throws RuntimeException
* @api
*/
public function normalize(string $path): string;
@@ -62,7 +63,7 @@ interface FilesystemInterface
* @param string $path A filename or path, does not need to exist as a file.
* @param int $levels The number of parent directories to go up (>= 1).
* @return string Returns path to the directory.
- * @throws \RuntimeException
+ * @throws RuntimeException
* @api
*/
public function dirname(string $path, int $levels = 1): string;
diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php
index 32ac89aae..b1ca46a7a 100644
--- a/system/src/Grav/Framework/Flex/Flex.php
+++ b/system/src/Grav/Framework/Flex/Flex.php
@@ -18,6 +18,7 @@ use Grav\Framework\Flex\Interfaces\FlexInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use Grav\Framework\Object\ObjectCollection;
use RuntimeException;
+use function count;
use function is_array;
/**
@@ -292,7 +293,7 @@ class Flex implements FlexInterface
*/
public function count(): int
{
- return \count($this->types);
+ return count($this->types);
}
/**
diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php
index 9b7dae2de..3c956794c 100644
--- a/system/src/Grav/Framework/Flex/FlexCollection.php
+++ b/system/src/Grav/Framework/Flex/FlexCollection.php
@@ -32,6 +32,7 @@ use function array_filter;
use function get_class;
use function in_array;
use function is_array;
+use function is_scalar;
/**
* Class FlexCollection
@@ -370,7 +371,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
$key = null;
foreach ($context as $value) {
- if (!\is_scalar($value)) {
+ if (!is_scalar($value)) {
$key = false;
break;
}
diff --git a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
index 031cda293..4339124e2 100644
--- a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
+++ b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
@@ -10,6 +10,7 @@
namespace Grav\Framework\Flex;
use ArrayAccess;
+use Exception;
use Grav\Common\Data\Blueprint;
use Grav\Common\Data\Data;
use Grav\Common\Grav;
@@ -19,6 +20,7 @@ use Grav\Framework\Flex\Interfaces\FlexFormInterface;
use Grav\Framework\Form\Interfaces\FormFlashInterface;
use Grav\Framework\Form\Traits\FormTrait;
use Grav\Framework\Route\Route;
+use JsonSerializable;
use RocketTheme\Toolbox\ArrayTraits\NestedArrayAccessWithGetters;
use RuntimeException;
use Twig\Error\LoaderError;
@@ -30,7 +32,7 @@ use Twig\TemplateWrapper;
* Class FlexForm
* @package Grav\Framework\Flex
*/
-class FlexDirectoryForm implements FlexDirectoryFormInterface, \JsonSerializable
+class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable
{
use NestedArrayAccessWithGetters {
NestedArrayAccessWithGetters::get as private traitGet;
@@ -436,7 +438,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, \JsonSerializable
* @param array $data
* @param array $files
* @return void
- * @throws \Exception
+ * @throws Exception
*/
protected function doSubmit(array $data, array $files)
{
diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php
index a7b785475..08eced0b2 100644
--- a/system/src/Grav/Framework/Flex/FlexForm.php
+++ b/system/src/Grav/Framework/Flex/FlexForm.php
@@ -9,6 +9,8 @@
namespace Grav\Framework\Flex;
+use ArrayAccess;
+use Exception;
use Grav\Common\Data\Blueprint;
use Grav\Common\Data\Data;
use Grav\Common\Grav;
@@ -19,6 +21,7 @@ use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use Grav\Framework\Form\Interfaces\FormFlashInterface;
use Grav\Framework\Form\Traits\FormTrait;
use Grav\Framework\Route\Route;
+use JsonSerializable;
use RocketTheme\Toolbox\ArrayTraits\NestedArrayAccessWithGetters;
use RuntimeException;
use Twig\Error\LoaderError;
@@ -30,7 +33,7 @@ use Twig\TemplateWrapper;
* Class FlexForm
* @package Grav\Framework\Flex
*/
-class FlexForm implements FlexObjectFormInterface, \JsonSerializable
+class FlexForm implements FlexObjectFormInterface, JsonSerializable
{
use NestedArrayAccessWithGetters {
NestedArrayAccessWithGetters::get as private traitGet;
@@ -494,7 +497,7 @@ class FlexForm implements FlexObjectFormInterface, \JsonSerializable
* @param array $data
* @param array $files
* @return void
- * @throws \Exception
+ * @throws Exception
*/
protected function doSubmit(array $data, array $files)
{
@@ -532,7 +535,7 @@ class FlexForm implements FlexObjectFormInterface, \JsonSerializable
/**
* Filter validated data.
*
- * @param \ArrayAccess|Data|null $data
+ * @param ArrayAccess|Data|null $data
* @return void
*/
protected function filterData($data = null): void
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
index 233dcf182..45d5b3349 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
@@ -11,6 +11,7 @@ namespace Grav\Framework\Flex\Interfaces;
use Grav\Framework\Form\Interfaces\FormInterface;
use Grav\Framework\Route\Route;
+use Serializable;
/**
* Defines Forms for Flex Objects.
@@ -18,7 +19,7 @@ use Grav\Framework\Route\Route;
* @used-by \Grav\Framework\Flex\FlexForm
* @since 1.6
*/
-interface FlexFormInterface extends \Serializable, FormInterface
+interface FlexFormInterface extends Serializable, FormInterface
{
/**
* Get media task route.
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
index 4c04e802c..b87bf0854 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
@@ -13,6 +13,7 @@ namespace Grav\Framework\Flex\Interfaces;
use Countable;
use Grav\Framework\Flex\FlexDirectory;
+use RuntimeException;
/**
* Interface FlexInterface
@@ -66,7 +67,7 @@ interface FlexInterface extends Countable
* @param array $options In addition to the options in getObjects(), following options can be passed:
* collection_class: Class to be used to create the collection. Defaults to ObjectCollection.
* @return FlexCollectionInterface
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function getMixedCollection(array $keys, array $options = []): FlexCollectionInterface;
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
index 8bc1633d0..74fb4e165 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Grav\Framework\Flex\Interfaces;
+use ArrayAccess;
use Grav\Common\Data\Blueprint;
use Grav\Framework\Flex\Flex;
use Grav\Framework\Object\Interfaces\NestedObjectInterface;
@@ -25,7 +26,7 @@ use RuntimeException;
* @used-by \Grav\Framework\Flex\FlexObject
* @since 1.6
*/
-interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface, \ArrayAccess
+interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface, ArrayAccess
{
/**
* Construct a new Flex Object instance.
diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
index a459a87ec..326e8292d 100644
--- a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
+++ b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
@@ -169,7 +169,7 @@ class FlexPageCollection extends FlexCollection
*/
public function currentPosition($path): ?int
{
- $pos = \array_search($path, $this->getKeys(), true);
+ $pos = array_search($path, $this->getKeys(), true);
return $pos !== false ? $pos : null;
}
diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php b/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
index d71d1d74e..d3a8330be 100644
--- a/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
+++ b/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
@@ -28,6 +28,7 @@ use Grav\Framework\Flex\Pages\Traits\PageTranslateTrait;
use Grav\Framework\Flex\Traits\FlexMediaTrait;
use RuntimeException;
use stdClass;
+use function array_key_exists;
use function is_array;
/**
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
index 9b02572d2..26b3b607c 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
@@ -17,6 +17,7 @@ use Grav\Common\Page\Pages;
use Grav\Common\Uri;
use Grav\Framework\Filesystem\Filesystem;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
+use RuntimeException;
use function is_string;
/**
@@ -228,7 +229,7 @@ trait PageRoutableTrait
public function unsetRouteSlug(): void
{
// TODO:
- throw new \RuntimeException(__METHOD__ . '(): Not Implemented');
+ throw new RuntimeException(__METHOD__ . '(): Not Implemented');
}
/**
@@ -241,7 +242,7 @@ trait PageRoutableTrait
{
if (null !== $var) {
// TODO:
- throw new \RuntimeException(__METHOD__ . '(string): Not Implemented');
+ throw new RuntimeException(__METHOD__ . '(string): Not Implemented');
}
if ($this->root()) {
@@ -337,7 +338,7 @@ trait PageRoutableTrait
{
if (null !== $var) {
// TODO:
- throw new \RuntimeException(__METHOD__ . '(string): Not Implemented');
+ throw new RuntimeException(__METHOD__ . '(string): Not Implemented');
}
$path = $this->_path;
@@ -414,7 +415,7 @@ trait PageRoutableTrait
{
if (null !== $var) {
// TODO:
- throw new \RuntimeException(__METHOD__ . '(PageInterface): Not Implemented');
+ throw new RuntimeException(__METHOD__ . '(PageInterface): Not Implemented');
}
if ($this->root()) {
diff --git a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
index 8e77c5e63..f6da141db 100644
--- a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
@@ -23,6 +23,7 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use RuntimeException;
use SplFileInfo;
use function array_key_exists;
+use function basename;
use function count;
use function is_scalar;
use function is_string;
@@ -670,7 +671,7 @@ class FolderStorage extends AbstractFilesystemStorage
$pattern .= '/{FILE}{EXT}';
} else {
$filesystem = Filesystem::getInstance(true);
- $this->dataFile = \basename($pattern, $extension);
+ $this->dataFile = basename($pattern, $extension);
$pattern = $filesystem->dirname($pattern) . '/{FILE}{EXT}';
}
}
diff --git a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
index a3de076b1..ee4393f39 100644
--- a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
@@ -17,6 +17,7 @@ use Grav\Framework\Filesystem\Filesystem;
use InvalidArgumentException;
use LogicException;
use RuntimeException;
+use function is_scalar;
use function is_string;
/**
@@ -154,7 +155,7 @@ class SimpleStorage extends AbstractFilesystemStorage
$list = [];
foreach ($rows as $key => $row) {
- if (null === $row || \is_scalar($row)) {
+ if (null === $row || is_scalar($row)) {
// Only load rows which haven't been loaded before.
$key = (string)$key;
$list[$key] = $this->hasKey($key) ? $this->loadRow($key) : null;
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
index 9a8048529..4277471ab 100644
--- a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
+++ b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
@@ -23,9 +23,11 @@ use Grav\Framework\Form\FormFlashFile;
use Psr\Http\Message\UploadedFileInterface;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use RuntimeException;
+use function in_array;
use function is_array;
use function is_object;
use function is_string;
+use function strpos;
/**
* Implements Grav Page content and header manipulation methods.
@@ -81,10 +83,10 @@ trait FlexMediaTrait
$schema = $this->getBlueprint()->schema();
$settings = $field && is_object($schema) ? (array)$schema->getProperty($field) : null;
- if (isset($settings['type']) && (\in_array($settings['type'], ['avatar', 'file', 'pagemedia']) || !empty($settings['destination']))) {
+ if (isset($settings['type']) && (in_array($settings['type'], ['avatar', 'file', 'pagemedia']) || !empty($settings['destination']))) {
// Set destination folder.
$settings['media_field'] = true;
- if (empty($settings['destination']) || \in_array($settings['destination'], ['@self', 'self@', '@self@'], true)) {
+ if (empty($settings['destination']) || in_array($settings['destination'], ['@self', 'self@', '@self@'], true)) {
$settings['destination'] = $this->getMediaFolder();
$settings['self'] = true;
} else {
@@ -187,7 +189,7 @@ trait FlexMediaTrait
foreach ($files as $field => $group) {
$field = (string)$field;
// Ignore files without a field and resized images.
- if ($field === '' || \strpos($field, '/')) {
+ if ($field === '' || strpos($field, '/')) {
continue;
}
diff --git a/system/src/Grav/Framework/Form/FormFlash.php b/system/src/Grav/Framework/Form/FormFlash.php
index b33e44ded..def7e5eaf 100644
--- a/system/src/Grav/Framework/Form/FormFlash.php
+++ b/system/src/Grav/Framework/Form/FormFlash.php
@@ -9,6 +9,7 @@
namespace Grav\Framework\Form;
+use Exception;
use Grav\Common\Filesystem\Folder;
use Grav\Common\Grav;
use Grav\Common\User\Interfaces\UserInterface;
@@ -17,6 +18,9 @@ use Grav\Framework\Form\Interfaces\FormFlashInterface;
use Psr\Http\Message\UploadedFileInterface;
use RocketTheme\Toolbox\File\YamlFile;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
+use RuntimeException;
+use function func_get_args;
+use function is_array;
/**
* Class FormFlash
@@ -122,7 +126,7 @@ class FormFlash implements FormFlashInterface
if ($exists) {
try {
$data = (array)$file->content();
- } catch (\Exception $e) {
+ } catch (Exception $e) {
}
}
@@ -307,7 +311,7 @@ class FormFlash implements FormFlashInterface
$tmp_name = Utils::generateRandomString(12);
$name = $upload->getClientFilename();
if (!$name) {
- throw new \RuntimeException('Uploaded file has no filename');
+ throw new RuntimeException('Uploaded file has no filename');
}
// Prepare upload data for later save
@@ -332,7 +336,7 @@ class FormFlash implements FormFlashInterface
public function addFile(string $filename, string $field, array $crop = null): bool
{
if (!file_exists($filename)) {
- throw new \RuntimeException("File not found: {$filename}");
+ throw new RuntimeException("File not found: {$filename}");
}
// Prepare upload data for later save
@@ -517,7 +521,7 @@ class FormFlash implements FormFlashInterface
protected function addFileInternal(?string $field, string $name, array $data, array $crop = null): void
{
if (!($this->folder && $this->uniqueId)) {
- throw new \RuntimeException('Cannot upload files: form flash folder not defined');
+ throw new RuntimeException('Cannot upload files: form flash folder not defined');
}
$field = $field ?: 'undefined';
diff --git a/system/src/Grav/Framework/Form/FormFlashFile.php b/system/src/Grav/Framework/Form/FormFlashFile.php
index 2a13be927..108852c89 100644
--- a/system/src/Grav/Framework/Form/FormFlashFile.php
+++ b/system/src/Grav/Framework/Form/FormFlashFile.php
@@ -10,8 +10,14 @@
namespace Grav\Framework\Form;
use Grav\Framework\Psr7\Stream;
+use InvalidArgumentException;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;
+use RuntimeException;
+use function copy;
+use function fopen;
+use function is_string;
+use function sprintf;
/**
* Class FormFlashFile
@@ -59,12 +65,12 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
$tmpFile = $this->getTmpFile();
if (null === $tmpFile) {
- throw new \RuntimeException('No temporary file');
+ throw new RuntimeException('No temporary file');
}
- $resource = \fopen($tmpFile, 'rb');
+ $resource = fopen($tmpFile, 'rb');
if (false === $resource) {
- throw new \RuntimeException('No temporary file');
+ throw new RuntimeException('No temporary file');
}
return Stream::create($resource);
@@ -78,18 +84,18 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
{
$this->validateActive();
- if (!\is_string($targetPath) || empty($targetPath)) {
- throw new \InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string');
+ if (!is_string($targetPath) || empty($targetPath)) {
+ throw new InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string');
}
$tmpFile = $this->getTmpFile();
if (null === $tmpFile) {
- throw new \RuntimeException('No temporary file');
+ throw new RuntimeException('No temporary file');
}
- $this->moved = \copy($tmpFile, $targetPath);
+ $this->moved = copy($tmpFile, $targetPath);
if (false === $this->moved) {
- throw new \RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath));
+ throw new RuntimeException(sprintf('Uploaded file could not be moved to %s', $targetPath));
}
$filename = $this->getClientFilename();
@@ -204,20 +210,20 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
/**
* @return void
- * @throws \RuntimeException if is moved or not ok
+ * @throws RuntimeException if is moved or not ok
*/
private function validateActive(): void
{
if (!$this->isOk()) {
- throw new \RuntimeException('Cannot retrieve stream due to upload error');
+ throw new RuntimeException('Cannot retrieve stream due to upload error');
}
if ($this->moved) {
- throw new \RuntimeException('Cannot retrieve stream after it has already been moved');
+ throw new RuntimeException('Cannot retrieve stream after it has already been moved');
}
if (!$this->getTmpFile()) {
- throw new \RuntimeException('Cannot retrieve stream as the file is missing');
+ throw new RuntimeException('Cannot retrieve stream as the file is missing');
}
}
diff --git a/system/src/Grav/Framework/Form/Traits/FormTrait.php b/system/src/Grav/Framework/Form/Traits/FormTrait.php
index 0d93f8a44..b5256f8e1 100644
--- a/system/src/Grav/Framework/Form/Traits/FormTrait.php
+++ b/system/src/Grav/Framework/Form/Traits/FormTrait.php
@@ -9,6 +9,9 @@
namespace Grav\Framework\Form\Traits;
+use ArrayAccess;
+use Exception;
+use FilesystemIterator;
use Grav\Common\Data\Blueprint;
use Grav\Common\Data\Data;
use Grav\Common\Data\ValidationException;
@@ -25,10 +28,15 @@ use Grav\Framework\Form\Interfaces\FormInterface;
use Grav\Framework\Session\SessionInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UploadedFileInterface;
+use RuntimeException;
+use SplFileInfo;
use Twig\Error\LoaderError;
use Twig\Error\SyntaxError;
use Twig\Template;
use Twig\TemplateWrapper;
+use function in_array;
+use function is_array;
+use function is_object;
/**
* Trait FormTrait
@@ -55,7 +63,7 @@ trait FormTrait
private $sessionid;
/** @var bool */
private $submitted;
- /** @var \ArrayAccess|Data|null */
+ /** @var ArrayAccess|Data|null */
private $data;
/** @var array|UploadedFileInterface[] */
private $files;
@@ -201,9 +209,9 @@ trait FormTrait
while ($path) {
$offset = array_shift($path);
- if ((\is_array($current) || $current instanceof \ArrayAccess) && isset($current[$offset])) {
+ if ((is_array($current) || $current instanceof ArrayAccess) && isset($current[$offset])) {
$current = $current[$offset];
- } elseif (\is_object($current) && isset($current->{$offset})) {
+ } elseif (is_object($current) && isset($current->{$offset})) {
$current = $current->{$offset};
} else {
return null;
@@ -242,7 +250,7 @@ trait FormTrait
[$data, $files] = $this->parseRequest($request);
$this->submit($data, $files);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
/** @var Debugger $debugger */
$debugger = $grav['debugger'];
$debugger->addException($e);
@@ -313,7 +321,7 @@ trait FormTrait
$this->validateUploads($this->getFiles());
} catch (ValidationException $e) {
$this->setErrors($e->getMessages());
- } catch (\Exception $e) {
+ } catch (Exception $e) {
/** @var Debugger $debugger */
$debugger = Grav::instance()['debugger'];
$debugger->addException($e);
@@ -335,7 +343,7 @@ trait FormTrait
{
try {
if ($this->isSubmitted()) {
- throw new \RuntimeException('Form has already been submitted');
+ throw new RuntimeException('Form has already been submitted');
}
$this->data = new Data($data, $this->getBlueprint());
@@ -348,7 +356,7 @@ trait FormTrait
$this->doSubmit($this->data->toArray(), $this->files);
$this->submitted = true;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
/** @var Debugger $debugger */
$debugger = Grav::instance()['debugger'];
$debugger->addException($e);
@@ -444,8 +452,8 @@ trait FormTrait
$name = $this->getName();
$list = [];
- /** @var \SplFileInfo $file */
- foreach (new \FilesystemIterator($folder) as $file) {
+ /** @var SplFileInfo $file */
+ foreach (new FilesystemIterator($folder) as $file) {
$uniqueId = $file->getFilename();
$config = [
'session_id' => $this->getSessionId(),
@@ -654,8 +662,8 @@ trait FormTrait
protected function parseRequest(ServerRequestInterface $request): array
{
$method = $request->getMethod();
- if (!\in_array($method, ['PUT', 'POST', 'PATCH'])) {
- throw new \RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
+ if (!in_array($method, ['PUT', 'POST', 'PATCH'])) {
+ throw new RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
}
$body = $request->getParsedBody();
@@ -684,10 +692,10 @@ trait FormTrait
/**
* Validate data and throw validation exceptions if validation fails.
*
- * @param \ArrayAccess|Data|null $data
+ * @param ArrayAccess|Data|null $data
* @return void
* @throws ValidationException
- * @throws \Exception
+ * @throws Exception
*/
protected function validateData($data = null): void
{
@@ -699,7 +707,7 @@ trait FormTrait
/**
* Filter validated data.
*
- * @param \ArrayAccess|Data|null $data
+ * @param ArrayAccess|Data|null $data
* @return void
*/
protected function filterData($data = null): void
@@ -742,7 +750,7 @@ trait FormTrait
if ($filename && !Utils::checkFilename($filename)) {
$grav = Grav::instance();
- throw new \RuntimeException(
+ throw new RuntimeException(
sprintf($grav['language']->translate('PLUGIN_FORM.FILEUPLOAD_UNABLE_TO_UPLOAD', null, true), $filename, 'Bad filename')
);
}
@@ -756,7 +764,7 @@ trait FormTrait
*/
protected function decodeData($data): array
{
- if (!\is_array($data)) {
+ if (!is_array($data)) {
return [];
}
@@ -764,7 +772,7 @@ trait FormTrait
if (isset($data['_json'])) {
$data = array_replace_recursive($data, $this->jsonDecode($data['_json']));
if (null === $data) {
- throw new \RuntimeException(__METHOD__ . '(): Unexpected error');
+ throw new RuntimeException(__METHOD__ . '(): Unexpected error');
}
unset($data['_json']);
}
@@ -781,7 +789,7 @@ trait FormTrait
protected function jsonDecode(array $data): array
{
foreach ($data as $key => &$value) {
- if (\is_array($value)) {
+ if (is_array($value)) {
$value = $this->jsonDecode($value);
} elseif (trim($value) === '') {
unset($data[$key]);
diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
index 8f9860668..707359a92 100644
--- a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
@@ -10,6 +10,10 @@
namespace Grav\Framework\Object\Access;
use Grav\Framework\Object\Interfaces\ObjectInterface;
+use RuntimeException;
+use stdClass;
+use function is_array;
+use function is_object;
/**
* Nested Property Object Trait
@@ -24,7 +28,7 @@ trait NestedPropertyTrait
*/
public function hasNestedProperty($property, $separator = null)
{
- $test = new \stdClass;
+ $test = new stdClass;
return $this->getNestedProperty($property, $test, $separator) !== $test;
}
@@ -58,9 +62,9 @@ trait NestedPropertyTrait
$offset = array_shift($path);
- if ((\is_array($current) || is_a($current, 'ArrayAccess')) && isset($current[$offset])) {
+ if ((is_array($current) || is_a($current, 'ArrayAccess')) && isset($current[$offset])) {
$current = $current[$offset];
- } elseif (\is_object($current) && isset($current->{$offset})) {
+ } elseif (is_object($current) && isset($current->{$offset})) {
$current = $current->{$offset};
} else {
return $default;
@@ -76,7 +80,7 @@ trait NestedPropertyTrait
* @param mixed $value New value.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function setNestedProperty($property, $value, $separator = null)
{
@@ -98,12 +102,12 @@ trait NestedPropertyTrait
// Handle arrays and scalars.
if ($current === null) {
$current = [$offset => []];
- } elseif (\is_array($current)) {
+ } elseif (is_array($current)) {
if (!isset($current[$offset])) {
$current[$offset] = [];
}
} else {
- throw new \RuntimeException("Cannot set nested property {$property} on non-array value");
+ throw new RuntimeException("Cannot set nested property {$property} on non-array value");
}
$current = &$current[$offset];
@@ -118,7 +122,7 @@ trait NestedPropertyTrait
* @param string $property Object property to be updated.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function unsetNestedProperty($property, $separator = null)
{
@@ -142,12 +146,12 @@ trait NestedPropertyTrait
if ($current === null) {
return $this;
}
- if (\is_array($current)) {
+ if (is_array($current)) {
if (!isset($current[$offset])) {
return $this;
}
} else {
- throw new \RuntimeException("Cannot unset nested property {$property} on non-array value");
+ throw new RuntimeException("Cannot unset nested property {$property} on non-array value");
}
$current = &$current[$offset];
@@ -163,7 +167,7 @@ trait NestedPropertyTrait
* @param mixed $default Default value.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function defNestedProperty($property, $default, $separator = null)
{
diff --git a/system/src/Grav/Framework/Object/ArrayObject.php b/system/src/Grav/Framework/Object/ArrayObject.php
index b7f1b25f7..216421f92 100644
--- a/system/src/Grav/Framework/Object/ArrayObject.php
+++ b/system/src/Grav/Framework/Object/ArrayObject.php
@@ -9,6 +9,7 @@
namespace Grav\Framework\Object;
+use ArrayAccess;
use Grav\Framework\Object\Access\NestedArrayAccessTrait;
use Grav\Framework\Object\Access\NestedPropertyTrait;
use Grav\Framework\Object\Access\OverloadedPropertyTrait;
@@ -19,7 +20,7 @@ use Grav\Framework\Object\Property\ArrayPropertyTrait;
/**
* Array Objects keep the data in private array property.
*/
-class ArrayObject implements NestedObjectInterface, \ArrayAccess
+class ArrayObject implements NestedObjectInterface, ArrayAccess
{
use ObjectTrait;
use ArrayPropertyTrait;
diff --git a/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php b/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
index 5841a6bcf..81a3a259e 100644
--- a/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
+++ b/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
@@ -11,6 +11,10 @@ namespace Grav\Framework\Object\Base;
use Grav\Framework\Compat\Serializable;
use Grav\Framework\Object\Interfaces\ObjectInterface;
+use function call_user_func_array;
+use function get_class;
+use function is_callable;
+use function is_object;
/**
* ObjectCollection Trait
@@ -46,7 +50,7 @@ trait ObjectCollectionTrait
return $type . static::$type;
}
- $class = \get_class($this);
+ $class = get_class($this);
return $type . strtolower(substr($class, strrpos($class, '\\') + 1));
}
@@ -210,7 +214,7 @@ trait ObjectCollectionTrait
{
$list = [];
foreach ($this->getIterator() as $key => $value) {
- $list[$key] = \is_object($value) ? clone $value : $value;
+ $list[$key] = is_object($value) ? clone $value : $value;
}
return $this->createFrom($list);
@@ -317,7 +321,7 @@ trait ObjectCollectionTrait
*/
foreach ($this->getIterator() as $id => $element) {
$callable = [$element, $method];
- $list[$id] = is_callable($callable) ? \call_user_func_array($callable, $arguments) : null;
+ $list[$id] = is_callable($callable) ? call_user_func_array($callable, $arguments) : null;
}
return $list;
diff --git a/system/src/Grav/Framework/Object/Base/ObjectTrait.php b/system/src/Grav/Framework/Object/Base/ObjectTrait.php
index 4af4c2f1a..be2957992 100644
--- a/system/src/Grav/Framework/Object/Base/ObjectTrait.php
+++ b/system/src/Grav/Framework/Object/Base/ObjectTrait.php
@@ -10,6 +10,8 @@
namespace Grav\Framework\Object\Base;
use Grav\Framework\Compat\Serializable;
+use InvalidArgumentException;
+use function get_class;
/**
* Object trait.
@@ -46,7 +48,7 @@ trait ObjectTrait
return $type . static::$type;
}
- $class = \get_class($this);
+ $class = get_class($this);
return $type . strtolower(substr($class, strrpos($class, '\\') + 1));
}
@@ -158,7 +160,7 @@ trait ObjectTrait
protected function doUnserialize(array $serialized)
{
if (!isset($serialized['key'], $serialized['type'], $serialized['elements']) || $serialized['type'] !== $this->getType()) {
- throw new \InvalidArgumentException("Cannot unserialize '{$this->getType()}': Bad data");
+ throw new InvalidArgumentException("Cannot unserialize '{$this->getType()}': Bad data");
}
$this->setKey($serialized['key']);
diff --git a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
index c2c12e444..be733b290 100644
--- a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
+++ b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
@@ -9,9 +9,15 @@
namespace Grav\Framework\Object\Collection;
+use Closure;
use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor;
use Doctrine\Common\Collections\Expr\Comparison;
+use RuntimeException;
+use function in_array;
+use function is_array;
use function is_callable;
+use function is_string;
+use function strlen;
/**
* Class ObjectExpressionVisitor
@@ -124,11 +130,11 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
*
* @param string $name
* @param int $orientation
- * @param \Closure|null $next
+ * @param Closure|null $next
*
- * @return \Closure
+ * @return Closure
*/
- public static function sortByField($name, $orientation = 1, \Closure $next = null)
+ public static function sortByField($name, $orientation = 1, Closure $next = null)
{
if (!$next) {
$next = function ($a, $b) {
@@ -145,7 +151,7 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
}
// For strings we use natural case insensitive sorting.
- if (\is_string($aValue) && \is_string($bValue)) {
+ if (is_string($aValue) && is_string($bValue)) {
return strnatcasecmp($aValue, $bValue) * $orientation;
}
@@ -194,12 +200,12 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
case Comparison::IN:
return function ($object) use ($field, $value) {
- return \in_array(static::getObjectFieldValue($object, $field), $value, true);
+ return in_array(static::getObjectFieldValue($object, $field), $value, true);
};
case Comparison::NIN:
return function ($object) use ($field, $value) {
- return !\in_array(static::getObjectFieldValue($object, $field), $value, true);
+ return !in_array(static::getObjectFieldValue($object, $field), $value, true);
};
case Comparison::CONTAINS:
@@ -210,10 +216,10 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
case Comparison::MEMBER_OF:
return function ($object) use ($field, $value) {
$fieldValues = static::getObjectFieldValue($object, $field);
- if (!\is_array($fieldValues)) {
+ if (!is_array($fieldValues)) {
$fieldValues = iterator_to_array($fieldValues);
}
- return \in_array($value, $fieldValues, true);
+ return in_array($value, $fieldValues, true);
};
case Comparison::STARTS_WITH:
@@ -227,7 +233,7 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
};
default:
- throw new \RuntimeException("Unknown comparison operator: " . $comparison->getOperator());
+ throw new RuntimeException("Unknown comparison operator: " . $comparison->getOperator());
}
}
}
diff --git a/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php b/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
index a27fc71cc..3071d8e51 100644
--- a/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
@@ -9,6 +9,8 @@
namespace Grav\Framework\Object\Interfaces;
+use RuntimeException;
+
/**
* Common Interface for both Objects and Collections
* @package Grav\Framework\Object
@@ -39,7 +41,7 @@ interface NestedObjectCollectionInterface extends ObjectCollectionInterface
* @param mixed $value New value.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function setNestedProperty($property, $value, $separator = null);
@@ -48,7 +50,7 @@ interface NestedObjectCollectionInterface extends ObjectCollectionInterface
* @param mixed $default Default value.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function defNestedProperty($property, $default, $separator = null);
@@ -56,7 +58,7 @@ interface NestedObjectCollectionInterface extends ObjectCollectionInterface
* @param string $property Object property to be unset.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function unsetNestedProperty($property, $separator = null);
}
diff --git a/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php b/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
index b688c9746..bc008a2f6 100644
--- a/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
@@ -9,6 +9,8 @@
namespace Grav\Framework\Object\Interfaces;
+use RuntimeException;
+
/**
* Common Interface for both Objects and Collections
* @package Grav\Framework\Object
@@ -35,7 +37,7 @@ interface NestedObjectInterface extends ObjectInterface
* @param mixed $value New value.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function setNestedProperty($property, $value, $separator = null);
@@ -44,7 +46,7 @@ interface NestedObjectInterface extends ObjectInterface
* @param mixed $default Default value.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function defNestedProperty($property, $default, $separator = null);
@@ -52,7 +54,7 @@ interface NestedObjectInterface extends ObjectInterface
* @param string $property Object property to be unset.
* @param string|null $separator Separator, defaults to '.'
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function unsetNestedProperty($property, $separator = null);
}
diff --git a/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php b/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
index ab9168704..8768826eb 100644
--- a/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
@@ -11,6 +11,7 @@ namespace Grav\Framework\Object\Interfaces;
use Doctrine\Common\Collections\Selectable;
use Grav\Framework\Collection\CollectionInterface;
+use Serializable;
/**
* ObjectCollection Interface
@@ -20,7 +21,7 @@ use Grav\Framework\Collection\CollectionInterface;
* @extends CollectionInterface
* @extends Selectable
*/
-interface ObjectCollectionInterface extends CollectionInterface, Selectable, \Serializable
+interface ObjectCollectionInterface extends CollectionInterface, Selectable, Serializable
{
/**
* @return string
diff --git a/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php b/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
index 3e669bdca..be8173169 100644
--- a/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
@@ -9,11 +9,14 @@
namespace Grav\Framework\Object\Interfaces;
+use JsonSerializable;
+use Serializable;
+
/**
* Object Interface
* @package Grav\Framework\Object
*/
-interface ObjectInterface extends \Serializable, \JsonSerializable
+interface ObjectInterface extends Serializable, JsonSerializable
{
/**
* @return string
diff --git a/system/src/Grav/Framework/Object/LazyObject.php b/system/src/Grav/Framework/Object/LazyObject.php
index f124f43c2..47a105a47 100644
--- a/system/src/Grav/Framework/Object/LazyObject.php
+++ b/system/src/Grav/Framework/Object/LazyObject.php
@@ -9,6 +9,7 @@
namespace Grav\Framework\Object;
+use ArrayAccess;
use Grav\Framework\Object\Access\NestedArrayAccessTrait;
use Grav\Framework\Object\Access\NestedPropertyTrait;
use Grav\Framework\Object\Access\OverloadedPropertyTrait;
@@ -22,7 +23,7 @@ use Grav\Framework\Object\Property\LazyPropertyTrait;
*
* @package Grav\Framework\Object
*/
-class LazyObject implements NestedObjectInterface, \ArrayAccess
+class LazyObject implements NestedObjectInterface, ArrayAccess
{
use ObjectTrait;
use LazyPropertyTrait;
diff --git a/system/src/Grav/Framework/Object/ObjectCollection.php b/system/src/Grav/Framework/Object/ObjectCollection.php
index 8859f8a23..5e3468402 100644
--- a/system/src/Grav/Framework/Object/ObjectCollection.php
+++ b/system/src/Grav/Framework/Object/ObjectCollection.php
@@ -16,6 +16,8 @@ use Grav\Framework\Object\Access\NestedPropertyCollectionTrait;
use Grav\Framework\Object\Base\ObjectCollectionTrait;
use Grav\Framework\Object\Collection\ObjectExpressionVisitor;
use Grav\Framework\Object\Interfaces\NestedObjectCollectionInterface;
+use InvalidArgumentException;
+use function array_slice;
/**
* Class contains a collection of objects.
@@ -35,7 +37,7 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
/**
* @param array $elements
* @param string|null $key
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function __construct(array $elements = [], $key = null)
{
@@ -102,7 +104,7 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
$length = $criteria->getMaxResults();
if ($offset || $length) {
- $filtered = \array_slice($filtered, (int)$offset, $length);
+ $filtered = array_slice($filtered, (int)$offset, $length);
}
return $this->createFrom($filtered);
diff --git a/system/src/Grav/Framework/Object/ObjectIndex.php b/system/src/Grav/Framework/Object/ObjectIndex.php
index 3ead3bb8e..3d4423900 100644
--- a/system/src/Grav/Framework/Object/ObjectIndex.php
+++ b/system/src/Grav/Framework/Object/ObjectIndex.php
@@ -13,6 +13,8 @@ use Doctrine\Common\Collections\Criteria;
use Grav\Framework\Collection\AbstractIndexCollection;
use Grav\Framework\Object\Interfaces\NestedObjectCollectionInterface;
use Grav\Framework\Object\Interfaces\ObjectCollectionInterface;
+use function get_class;
+use function is_object;
/**
* Keeps index of objects instead of collection of objects. This class allows you to keep a list of objects and load
@@ -46,7 +48,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
return $type . static::$type;
}
- $class = \get_class($this);
+ $class = get_class($this);
return $type . strtolower(substr($class, strrpos($class, '\\') + 1));
}
@@ -179,7 +181,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
{
$list = [];
foreach ($this->getIterator() as $key => $value) {
- $list[$key] = \is_object($value) ? clone $value : $value;
+ $list[$key] = is_object($value) ? clone $value : $value;
}
return $this->createFrom($list);
diff --git a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
index a17792daf..df8e3c713 100644
--- a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
@@ -9,6 +9,9 @@
namespace Grav\Framework\Object\Property;
+use InvalidArgumentException;
+use function array_key_exists;
+
/**
* Array Property Trait
*
@@ -24,7 +27,7 @@ trait ArrayPropertyTrait
/**
* @param array $elements
* @param string|null $key
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function __construct(array $elements = [], $key = null)
{
diff --git a/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
index cb07c7fda..a397392e0 100644
--- a/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
@@ -9,6 +9,11 @@
namespace Grav\Framework\Object\Property;
+use InvalidArgumentException;
+use function array_key_exists;
+use function get_object_vars;
+use function is_callable;
+
/**
* Object Property Trait
*
@@ -30,7 +35,7 @@ trait ObjectPropertyTrait
/**
* @param array $elements
* @param string|null $key
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function __construct(array $elements = [], $key = null)
{
@@ -102,14 +107,14 @@ trait ObjectPropertyTrait
protected function &doGetProperty($property, $default = null, $doCreate = false)
{
if (!array_key_exists($property, $this->_definedProperties)) {
- throw new \InvalidArgumentException("Property '{$property}' does not exist in the object!");
+ throw new InvalidArgumentException("Property '{$property}' does not exist in the object!");
}
if (empty($this->_definedProperties[$property])) {
if ($doCreate === true) {
$this->_definedProperties[$property] = true;
$this->{$property} = null;
- } elseif (\is_callable($doCreate)) {
+ } elseif (is_callable($doCreate)) {
$this->_definedProperties[$property] = true;
$this->{$property} = $this->offsetLoad($property, $doCreate());
} else {
@@ -124,12 +129,12 @@ trait ObjectPropertyTrait
* @param string $property Object property to be updated.
* @param mixed $value New value.
* @return void
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
protected function doSetProperty($property, $value)
{
if (!array_key_exists($property, $this->_definedProperties)) {
- throw new \InvalidArgumentException("Property '{$property}' does not exist in the object!");
+ throw new InvalidArgumentException("Property '{$property}' does not exist in the object!");
}
$this->_definedProperties[$property] = true;
@@ -156,7 +161,7 @@ trait ObjectPropertyTrait
protected function initObjectProperties()
{
$this->_definedProperties = [];
- foreach (\get_object_vars($this) as $property => $value) {
+ foreach (get_object_vars($this) as $property => $value) {
if ($property[0] !== '_') {
$this->_definedProperties[$property] = ($value !== null);
}
diff --git a/system/src/Grav/Framework/Object/PropertyObject.php b/system/src/Grav/Framework/Object/PropertyObject.php
index e0125ea2d..c05414dac 100644
--- a/system/src/Grav/Framework/Object/PropertyObject.php
+++ b/system/src/Grav/Framework/Object/PropertyObject.php
@@ -9,6 +9,7 @@
namespace Grav\Framework\Object;
+use ArrayAccess;
use Grav\Framework\Object\Access\NestedArrayAccessTrait;
use Grav\Framework\Object\Access\NestedPropertyTrait;
use Grav\Framework\Object\Access\OverloadedPropertyTrait;
@@ -19,7 +20,7 @@ use Grav\Framework\Object\Property\ObjectPropertyTrait;
/**
* Property Objects keep their data in protected object properties.
*/
-class PropertyObject implements NestedObjectInterface, \ArrayAccess
+class PropertyObject implements NestedObjectInterface, ArrayAccess
{
use ObjectTrait;
use ObjectPropertyTrait;
diff --git a/system/src/Grav/Framework/Pagination/AbstractPagination.php b/system/src/Grav/Framework/Pagination/AbstractPagination.php
index a576bd5c9..e98027ecd 100644
--- a/system/src/Grav/Framework/Pagination/AbstractPagination.php
+++ b/system/src/Grav/Framework/Pagination/AbstractPagination.php
@@ -9,8 +9,10 @@
namespace Grav\Framework\Pagination;
+use ArrayIterator;
use Grav\Framework\Pagination\Interfaces\PaginationInterface;
use Grav\Framework\Route\Route;
+use function count;
/**
* Class AbstractPagination
@@ -216,17 +218,17 @@ class AbstractPagination implements PaginationInterface
{
$this->loadItems();
- return \count($this->items);
+ return count($this->items);
}
/**
- * @return \ArrayIterator
+ * @return ArrayIterator
*/
public function getIterator()
{
$this->loadItems();
- return new \ArrayIterator($this->items);
+ return new ArrayIterator($this->items);
}
/**
diff --git a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
index 0f42aa70b..184ec4b7f 100644
--- a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
+++ b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
@@ -9,9 +9,15 @@
namespace Grav\Framework\Pagination\Interfaces;
+use Countable;
use Grav\Framework\Pagination\PaginationPage;
+use IteratorAggregate;
-interface PaginationInterface extends \Countable, \IteratorAggregate
+/**
+ * Interface PaginationInterface
+ * @package Grav\Framework\Pagination\Interfaces
+ */
+interface PaginationInterface extends Countable, IteratorAggregate
{
/**
* @return int
diff --git a/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php b/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
index 8883375f0..ca9014315 100644
--- a/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
+++ b/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
@@ -9,6 +9,10 @@
namespace Grav\Framework\Pagination\Interfaces;
+/**
+ * Interface PaginationPageInterface
+ * @package Grav\Framework\Pagination\Interfaces
+ */
interface PaginationPageInterface
{
/**
diff --git a/system/src/Grav/Framework/Psr7/AbstractUri.php b/system/src/Grav/Framework/Psr7/AbstractUri.php
index b3bb143cd..5e8797c61 100644
--- a/system/src/Grav/Framework/Psr7/AbstractUri.php
+++ b/system/src/Grav/Framework/Psr7/AbstractUri.php
@@ -10,6 +10,7 @@
namespace Grav\Framework\Psr7;
use Grav\Framework\Uri\UriPartsFilter;
+use InvalidArgumentException;
use Psr\Http\Message\UriInterface;
/**
@@ -150,7 +151,7 @@ abstract class AbstractUri implements UriInterface
/**
* @inheritdoc
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function withUserInfo($user, $password = null)
{
@@ -243,7 +244,7 @@ abstract class AbstractUri implements UriInterface
/**
* @inheritdoc
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function withFragment($fragment)
{
@@ -347,7 +348,7 @@ abstract class AbstractUri implements UriInterface
/**
* @param array $parts
* @return void
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
protected function initParts(array $parts)
{
@@ -366,23 +367,23 @@ abstract class AbstractUri implements UriInterface
/**
* @return void
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
private function validate()
{
if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
- throw new \InvalidArgumentException('Uri with a scheme must have a host');
+ throw new InvalidArgumentException('Uri with a scheme must have a host');
}
if ($this->getAuthority() === '') {
if (0 === strpos($this->path, '//')) {
- throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes \'//\'');
+ throw new InvalidArgumentException('The path of a URI without an authority must not start with two slashes \'//\'');
}
if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
- throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
+ throw new InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
}
} elseif (isset($this->path[0]) && $this->path[0] !== '/') {
- throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash \'/\' or be empty');
+ throw new InvalidArgumentException('The path of a URI with an authority must start with a slash \'/\' or be empty');
}
}
diff --git a/system/src/Grav/Framework/Psr7/Response.php b/system/src/Grav/Framework/Psr7/Response.php
index 32f641122..737fe788c 100644
--- a/system/src/Grav/Framework/Psr7/Response.php
+++ b/system/src/Grav/Framework/Psr7/Response.php
@@ -15,6 +15,7 @@ use Grav\Framework\Psr7\Traits\ResponseDecoratorTrait;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use RuntimeException;
+use function in_array;
/**
* Class Response
@@ -110,7 +111,7 @@ class Response implements ResponseInterface
*/
public function isEmpty(): bool
{
- return \in_array($this->getResponse()->getStatusCode(), [204, 205, 304], true);
+ return in_array($this->getResponse()->getStatusCode(), [204, 205, 304], true);
}
@@ -135,7 +136,7 @@ class Response implements ResponseInterface
*/
public function isRedirect(): bool
{
- return \in_array($this->getResponse()->getStatusCode(), [301, 302, 303, 307, 308], true);
+ return in_array($this->getResponse()->getStatusCode(), [301, 302, 303, 307, 308], true);
}
/**
diff --git a/system/src/Grav/Framework/Psr7/ServerRequest.php b/system/src/Grav/Framework/Psr7/ServerRequest.php
index 7ef6ba481..de29a150c 100644
--- a/system/src/Grav/Framework/Psr7/ServerRequest.php
+++ b/system/src/Grav/Framework/Psr7/ServerRequest.php
@@ -15,6 +15,8 @@ use Grav\Framework\Psr7\Traits\ServerRequestDecoratorTrait;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;
+use function is_array;
+use function is_object;
/**
* Class ServerRequest
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
index 4736a0aec..42eaa0ed1 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
@@ -12,6 +12,8 @@ declare(strict_types=1);
namespace Grav\Framework\RequestHandler\Exception;
use Psr\Http\Message\ServerRequestInterface;
+use Throwable;
+use function in_array;
/**
* Class NotFoundException
@@ -25,11 +27,11 @@ class NotFoundException extends RequestException
/**
* NotFoundException constructor.
* @param ServerRequestInterface $request
- * @param \Throwable|null $previous
+ * @param Throwable|null $previous
*/
- public function __construct(ServerRequestInterface $request, \Throwable $previous = null)
+ public function __construct(ServerRequestInterface $request, Throwable $previous = null)
{
- if (\in_array(strtoupper($request->getMethod()), ['PUT', 'PATCH', 'DELETE'])) {
+ if (in_array(strtoupper($request->getMethod()), ['PUT', 'PATCH', 'DELETE'])) {
parent::__construct($request, 'Method Not Allowed', 405, $previous);
} else {
parent::__construct($request, 'Not Found', 404, $previous);
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php b/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
index 3d29379f1..ab56ba1b7 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Grav\Framework\RequestHandler\Exception;
use Psr\Http\Message\ServerRequestInterface;
+use Throwable;
/**
* Class PageExpiredException
@@ -22,9 +23,9 @@ class PageExpiredException extends RequestException
/**
* PageExpiredException constructor.
* @param ServerRequestInterface $request
- * @param \Throwable|null $previous
+ * @param Throwable|null $previous
*/
- public function __construct(ServerRequestInterface $request, \Throwable $previous = null)
+ public function __construct(ServerRequestInterface $request, Throwable $previous = null)
{
parent::__construct($request, 'Page Expired', 400, $previous); // 419
}
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php b/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
index 6ec1ed90e..2ae31010f 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Grav\Framework\RequestHandler\Exception;
use Psr\Http\Message\ServerRequestInterface;
+use Throwable;
/**
* Class RequestException
@@ -70,9 +71,9 @@ class RequestException extends \RuntimeException
* @param ServerRequestInterface $request
* @param string $message
* @param int $code
- * @param \Throwable|null $previous
+ * @param Throwable|null $previous
*/
- public function __construct(ServerRequestInterface $request, string $message, int $code = 500, \Throwable $previous = null)
+ public function __construct(ServerRequestInterface $request, string $message, int $code = 500, Throwable $previous = null)
{
$this->request = $request;
diff --git a/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php b/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
index c759ca7e3..dba0b4315 100644
--- a/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
+++ b/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
@@ -18,6 +18,8 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
+use Throwable;
+use function get_class;
/**
* Class Exceptions
@@ -29,7 +31,7 @@ class Exceptions implements MiddlewareInterface
{
try {
return $handler->handle($request);
- } catch (\Throwable $exception) {
+ } catch (Throwable $exception) {
$response = [
'error' => [
'code' => $exception->getCode(),
@@ -41,7 +43,7 @@ class Exceptions implements MiddlewareInterface
$debugger = Grav::instance()['debugger'];
if ($debugger->enabled()) {
$response['error'] += [
- 'type' => \get_class($exception),
+ 'type' => get_class($exception),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'trace' => explode("\n", $exception->getTraceAsString()),
diff --git a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
index 9d67e609e..e8905859e 100644
--- a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
+++ b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
@@ -16,6 +16,7 @@ use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
+use function call_user_func;
/**
* Trait RequestHandlerTrait
@@ -42,7 +43,7 @@ trait RequestHandlerTrait
// Use default callable if there is no middleware.
if ($middleware === null) {
- return \call_user_func($this->handler, $request);
+ return call_user_func($this->handler, $request);
}
if ($middleware instanceof MiddlewareInterface) {
diff --git a/system/src/Grav/Framework/Route/Route.php b/system/src/Grav/Framework/Route/Route.php
index 24791ebca..d7554b73e 100644
--- a/system/src/Grav/Framework/Route/Route.php
+++ b/system/src/Grav/Framework/Route/Route.php
@@ -10,6 +10,8 @@
namespace Grav\Framework\Route;
use Grav\Framework\Uri\UriFactory;
+use InvalidArgumentException;
+use function array_slice;
/**
* Implements Grav Route.
@@ -35,7 +37,7 @@ class Route
* You can use `RouteFactory` functions to create new `Route` objects.
*
* @param array $parts
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function __construct(array $parts = [])
{
@@ -136,7 +138,7 @@ class Route
$parts = explode('/', $this->route);
if ($offset !== 0 || $length !== null) {
- $parts = \array_slice($parts, $offset, $length);
+ $parts = array_slice($parts, $offset, $length);
}
return $parts;
diff --git a/system/src/Grav/Framework/Route/RouteFactory.php b/system/src/Grav/Framework/Route/RouteFactory.php
index c0ff2edca..9d8213c77 100644
--- a/system/src/Grav/Framework/Route/RouteFactory.php
+++ b/system/src/Grav/Framework/Route/RouteFactory.php
@@ -10,6 +10,8 @@
namespace Grav\Framework\Route;
use Grav\Common\Uri;
+use function dirname;
+use function strlen;
/**
* Class RouteFactory
@@ -161,7 +163,7 @@ class RouteFactory
return $path;
}
- $path = \dirname(substr($path, 0, $pos));
+ $path = dirname(substr($path, 0, $pos));
if ($path === '.') {
return '';
}
@@ -175,7 +177,7 @@ class RouteFactory
*/
public static function getParams(string $path): array
{
- $params = ltrim(substr($path, \strlen(static::stripParams($path))), '/');
+ $params = ltrim(substr($path, strlen(static::stripParams($path))), '/');
return $params !== '' ? static::parseParams($params) : [];
}
diff --git a/system/src/Grav/Framework/Session/Exceptions/SessionException.php b/system/src/Grav/Framework/Session/Exceptions/SessionException.php
index a946f1d53..f24df0a79 100644
--- a/system/src/Grav/Framework/Session/Exceptions/SessionException.php
+++ b/system/src/Grav/Framework/Session/Exceptions/SessionException.php
@@ -9,10 +9,12 @@
namespace Grav\Framework\Session\Exceptions;
+use RuntimeException;
+
/**
* Class SessionException
* @package Grav\Framework\Session\Exceptions
*/
-class SessionException extends \RuntimeException
+class SessionException extends RuntimeException
{
}
diff --git a/system/src/Grav/Framework/Session/Messages.php b/system/src/Grav/Framework/Session/Messages.php
index 124cb543c..83d8c8f18 100644
--- a/system/src/Grav/Framework/Session/Messages.php
+++ b/system/src/Grav/Framework/Session/Messages.php
@@ -10,6 +10,7 @@
namespace Grav\Framework\Session;
use Grav\Framework\Compat\Serializable;
+use function array_key_exists;
/**
* Implements session messages.
diff --git a/system/src/Grav/Framework/Session/Session.php b/system/src/Grav/Framework/Session/Session.php
index d1550fda4..5b656e9ce 100644
--- a/system/src/Grav/Framework/Session/Session.php
+++ b/system/src/Grav/Framework/Session/Session.php
@@ -9,8 +9,14 @@
namespace Grav\Framework\Session;
+use ArrayIterator;
+use Exception;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Framework\Session\Exceptions\SessionException;
+use RuntimeException;
+use function is_array;
+use function is_bool;
+use function is_string;
/**
* Class Session
@@ -31,7 +37,7 @@ class Session implements SessionInterface
public static function getInstance()
{
if (null === self::$instance) {
- throw new \RuntimeException("Session hasn't been initialized.", 500);
+ throw new RuntimeException("Session hasn't been initialized.", 500);
}
return self::$instance;
@@ -52,7 +58,7 @@ class Session implements SessionInterface
}
if (null !== self::$instance) {
- throw new \RuntimeException('Session has already been initialized.', 500);
+ throw new RuntimeException('Session has already been initialized.', 500);
}
// Destroy any existing sessions started with session.auto_start
@@ -157,7 +163,7 @@ class Session implements SessionInterface
];
foreach ($options as $key => $value) {
- if (\is_array($value)) {
+ if (is_array($value)) {
// Allow nested options.
foreach ($value as $key2 => $value2) {
$ckey = "{$key}.{$key2}";
@@ -200,7 +206,7 @@ class Session implements SessionInterface
$last = error_get_last();
$error = $last ? $last['message'] : 'Unknown error';
- throw new \RuntimeException($error);
+ throw new RuntimeException($error);
}
// Handle changing session id.
@@ -210,7 +216,7 @@ class Session implements SessionInterface
// Should not happen usually. This could be attack or due to unstable network. Destroy this session.
$this->invalidate();
- throw new \RuntimeException('Your session was destroyed.', 500);
+ throw new RuntimeException('Your session was destroyed.', 500);
}
// Not fully expired yet. Could be lost cookie by unstable network. Start session with new session id.
@@ -221,10 +227,10 @@ class Session implements SessionInterface
$last = error_get_last();
$error = $last ? $last['message'] : 'Unknown error';
- throw new \RuntimeException($error);
+ throw new RuntimeException($error);
}
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
throw new SessionException('Failed to start session: ' . $e->getMessage(), 500);
}
@@ -379,7 +385,7 @@ class Session implements SessionInterface
*/
public function getIterator()
{
- return new \ArrayIterator($_SESSION);
+ return new ArrayIterator($_SESSION);
}
/**
@@ -443,8 +449,8 @@ class Session implements SessionInterface
*/
protected function setOption($key, $value)
{
- if (!\is_string($value)) {
- if (\is_bool($value)) {
+ if (!is_string($value)) {
+ if (is_bool($value)) {
$value = $value ? '1' : '0';
} else {
$value = (string)$value;
diff --git a/system/src/Grav/Framework/Session/SessionInterface.php b/system/src/Grav/Framework/Session/SessionInterface.php
index 83595e1d5..91ca9ce28 100644
--- a/system/src/Grav/Framework/Session/SessionInterface.php
+++ b/system/src/Grav/Framework/Session/SessionInterface.php
@@ -9,17 +9,21 @@
namespace Grav\Framework\Session;
+use ArrayIterator;
+use IteratorAggregate;
+use RuntimeException;
+
/**
* Class Session
* @package Grav\Framework\Session
*/
-interface SessionInterface extends \IteratorAggregate
+interface SessionInterface extends IteratorAggregate
{
/**
* Get current session instance.
*
* @return Session
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public static function getInstance();
@@ -67,7 +71,7 @@ interface SessionInterface extends \IteratorAggregate
*
* @param bool $readonly
* @return $this
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
public function start($readonly = false);
@@ -102,7 +106,7 @@ interface SessionInterface extends \IteratorAggregate
/**
* Retrieve an external iterator
*
- * @return \ArrayIterator Return an ArrayIterator of $_SESSION
+ * @return ArrayIterator Return an ArrayIterator of $_SESSION
*/
public function getIterator();
diff --git a/system/src/Grav/Framework/Uri/Uri.php b/system/src/Grav/Framework/Uri/Uri.php
index 8b3c72c82..1ec86c6f1 100644
--- a/system/src/Grav/Framework/Uri/Uri.php
+++ b/system/src/Grav/Framework/Uri/Uri.php
@@ -11,6 +11,7 @@ namespace Grav\Framework\Uri;
use Grav\Framework\Psr7\AbstractUri;
use GuzzleHttp\Psr7\Uri as GuzzleUri;
+use InvalidArgumentException;
use Psr\Http\Message\UriInterface;
/**
@@ -28,7 +29,7 @@ class Uri extends AbstractUri
*
* @param array $parts
* @return void
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function __construct(array $parts = [])
{
diff --git a/system/src/Grav/Framework/Uri/UriFactory.php b/system/src/Grav/Framework/Uri/UriFactory.php
index e3eca5c8f..237aa0aa6 100644
--- a/system/src/Grav/Framework/Uri/UriFactory.php
+++ b/system/src/Grav/Framework/Uri/UriFactory.php
@@ -9,6 +9,9 @@
namespace Grav\Framework\Uri;
+use InvalidArgumentException;
+use function is_string;
+
/**
* Class Uri
* @package Grav\Framework\Uri
@@ -18,7 +21,7 @@ class UriFactory
/**
* @param array $env
* @return Uri
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public static function createFromEnvironment(array $env)
{
@@ -28,7 +31,7 @@ class UriFactory
/**
* @param string $uri
* @return Uri
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public static function createFromString($uri)
{
@@ -40,7 +43,7 @@ class UriFactory
*
* @param array $parts
* @return Uri
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public static function createFromParts(array $parts)
{
@@ -50,7 +53,7 @@ class UriFactory
/**
* @param array $env
* @return array
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public static function parseUrlFromEnvironment(array $env)
{
@@ -112,12 +115,12 @@ class UriFactory
*
* @param string $url
* @return array
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public static function parseUrl($url)
{
- if (!\is_string($url)) {
- throw new \InvalidArgumentException('URL must be a string');
+ if (!is_string($url)) {
+ throw new InvalidArgumentException('URL must be a string');
}
$encodedUrl = preg_replace_callback(
@@ -128,9 +131,9 @@ class UriFactory
$url
);
- $parts = \is_string($encodedUrl) ? parse_url($encodedUrl) : false;
+ $parts = is_string($encodedUrl) ? parse_url($encodedUrl) : false;
if ($parts === false) {
- throw new \InvalidArgumentException("Malformed URL: {$url}");
+ throw new InvalidArgumentException("Malformed URL: {$url}");
}
return $parts;
diff --git a/system/src/Grav/Framework/Uri/UriPartsFilter.php b/system/src/Grav/Framework/Uri/UriPartsFilter.php
index 6211eb25d..4761f2da7 100644
--- a/system/src/Grav/Framework/Uri/UriPartsFilter.php
+++ b/system/src/Grav/Framework/Uri/UriPartsFilter.php
@@ -9,6 +9,10 @@
namespace Grav\Framework\Uri;
+use InvalidArgumentException;
+use function is_int;
+use function is_string;
+
/**
* Class Uri
* @package Grav\Framework\Uri
@@ -20,12 +24,12 @@ class UriPartsFilter
/**
* @param string $scheme
* @return string
- * @throws \InvalidArgumentException If the scheme is invalid.
+ * @throws InvalidArgumentException If the scheme is invalid.
*/
public static function filterScheme($scheme)
{
- if (!\is_string($scheme)) {
- throw new \InvalidArgumentException('Uri scheme must be a string');
+ if (!is_string($scheme)) {
+ throw new InvalidArgumentException('Uri scheme must be a string');
}
return strtolower($scheme);
@@ -36,12 +40,12 @@ class UriPartsFilter
*
* @param string $info The raw user or password.
* @return string The percent-encoded user or password string.
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public static function filterUserInfo($info)
{
- if (!\is_string($info)) {
- throw new \InvalidArgumentException('Uri user info must be a string');
+ if (!is_string($info)) {
+ throw new InvalidArgumentException('Uri user info must be a string');
}
return preg_replace_callback(
@@ -56,18 +60,18 @@ class UriPartsFilter
/**
* @param string $host
* @return string
- * @throws \InvalidArgumentException If the host is invalid.
+ * @throws InvalidArgumentException If the host is invalid.
*/
public static function filterHost($host)
{
- if (!\is_string($host)) {
- throw new \InvalidArgumentException('Uri host must be a string');
+ if (!is_string($host)) {
+ throw new InvalidArgumentException('Uri host must be a string');
}
if (filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$host = '[' . $host . ']';
} elseif ($host && preg_match(static::HOSTNAME_REGEX, $host) !== 1) {
- throw new \InvalidArgumentException('Uri host name validation failed');
+ throw new InvalidArgumentException('Uri host name validation failed');
}
return strtolower($host);
@@ -80,15 +84,15 @@ class UriPartsFilter
*
* @param int|null $port
* @return int|null
- * @throws \InvalidArgumentException If the port is invalid.
+ * @throws InvalidArgumentException If the port is invalid.
*/
public static function filterPort($port = null)
{
- if (null === $port || (\is_int($port) && ($port >= 0 && $port <= 65535))) {
+ if (null === $port || (is_int($port) && ($port >= 0 && $port <= 65535))) {
return $port;
}
- throw new \InvalidArgumentException('Uri port must be null or an integer between 0 and 65535');
+ throw new InvalidArgumentException('Uri port must be null or an integer between 0 and 65535');
}
/**
@@ -99,13 +103,13 @@ class UriPartsFilter
*
* @param string $path The raw uri path.
* @return string The RFC 3986 percent-encoded uri path.
- * @throws \InvalidArgumentException If the path is invalid.
+ * @throws InvalidArgumentException If the path is invalid.
* @link http://www.faqs.org/rfcs/rfc3986.html
*/
public static function filterPath($path)
{
- if (!\is_string($path)) {
- throw new \InvalidArgumentException('Uri path must be a string');
+ if (!is_string($path)) {
+ throw new InvalidArgumentException('Uri path must be a string');
}
return preg_replace_callback(
@@ -122,12 +126,12 @@ class UriPartsFilter
*
* @param string $query The raw uri query string.
* @return string The percent-encoded query string.
- * @throws \InvalidArgumentException If the query is invalid.
+ * @throws InvalidArgumentException If the query is invalid.
*/
public static function filterQueryOrFragment($query)
{
- if (!\is_string($query)) {
- throw new \InvalidArgumentException('Uri query string and fragment must be a string');
+ if (!is_string($query)) {
+ throw new InvalidArgumentException('Uri query string and fragment must be a string');
}
return preg_replace_callback(