diff --git a/system/src/Grav/Common/Assets/Pipeline.php b/system/src/Grav/Common/Assets/Pipeline.php index 0933d18e3..a01797152 100644 --- a/system/src/Grav/Common/Assets/Pipeline.php +++ b/system/src/Grav/Common/Assets/Pipeline.php @@ -55,20 +55,6 @@ class Pipeline extends PropertyObject /** @var string */ protected $asset; - /** - * Closure used by the pipeline to fetch assets. - * - * Useful when file_get_contents() function is not available in your PHP - * installation or when you want to apply any kind of preprocessing to - * your assets before they get pipelined. - * - * The closure will receive as the only parameter a string with the path/URL of the asset and - * it should return the content of the asset file as a string. - * - * @var \Closure|null - */ - protected $fetch_command; - public function __construct(array $elements = [], ?string $key = null) { parent::__construct($elements, $key); @@ -249,9 +235,7 @@ class Pipeline extends PropertyObject $new_url = ($local ? $this->base_url: '') . $old_url; - $fixed = str_replace($matches[2], $new_url, $matches[0]); - - return $fixed; + return str_replace($matches[2], $new_url, $matches[0]); }, $file); return $file; diff --git a/system/src/Grav/Common/Flex/Pages/PageStorage.php b/system/src/Grav/Common/Flex/Pages/PageStorage.php index 25b8ad1e0..8841e6da1 100644 --- a/system/src/Grav/Common/Flex/Pages/PageStorage.php +++ b/system/src/Grav/Common/Flex/Pages/PageStorage.php @@ -55,8 +55,8 @@ class PageStorage extends FolderStorage $this->ignore_hidden = (bool)$config->get('system.pages.ignore_hidden'); $this->ignore_files = (array)$config->get('system.pages.ignore_files'); $this->ignore_folders = (array)$config->get('system.pages.ignore_folders'); - $this->include_default_lang_file_extension = $config->get('system.languages.include_default_lang_file_extension', true); - $this->recurse = $options['recurse'] ?? true; + $this->include_default_lang_file_extension = (bool)$config->get('system.languages.include_default_lang_file_extension', true); + $this->recurse = (bool)($options['recurse'] ?? true); $this->regex = '/(\.([\w\d_-]+))?\.md$/D'; } diff --git a/system/src/Grav/Common/GPM/Local/Package.php b/system/src/Grav/Common/GPM/Local/Package.php index b6b341291..ee57b9b9c 100644 --- a/system/src/Grav/Common/GPM/Local/Package.php +++ b/system/src/Grav/Common/GPM/Local/Package.php @@ -36,6 +36,6 @@ class Package extends BasePackage */ public function isEnabled() { - return $this->settings['enabled']; + return (bool)$this->settings['enabled']; } } diff --git a/system/src/Grav/Common/GravTrait.php b/system/src/Grav/Common/GravTrait.php index 5c7105b6b..73ecf47b9 100644 --- a/system/src/Grav/Common/GravTrait.php +++ b/system/src/Grav/Common/GravTrait.php @@ -25,7 +25,7 @@ trait GravTrait { user_error(__TRAIT__ . ' is deprecated since Grav 1.4, use Grav::instance() instead', E_USER_DEPRECATED); - if (!self::$grav) { + if (null === self::$grav) { self::$grav = Grav::instance(); } diff --git a/system/src/Grav/Common/Helpers/Exif.php b/system/src/Grav/Common/Helpers/Exif.php index 66087be19..a1297fb82 100644 --- a/system/src/Grav/Common/Helpers/Exif.php +++ b/system/src/Grav/Common/Helpers/Exif.php @@ -24,8 +24,8 @@ class Exif public function __construct() { if (Grav::instance()['config']->get('system.media.auto_metadata_exif')) { - if (function_exists('exif_read_data') && class_exists('\PHPExif\Reader\Reader')) { - $this->reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_NATIVE); + if (function_exists('exif_read_data') && class_exists(Reader::class)) { + $this->reader = Reader::factory(Reader::TYPE_NATIVE); } else { throw new \RuntimeException('Please enable the Exif extension for PHP or disable Exif support in Grav system configuration'); } @@ -37,10 +37,6 @@ class Exif */ public function getReader() { - if ($this->reader) { - return $this->reader; - } - - return false; + return $this->reader; } } diff --git a/system/src/Grav/Common/Page/Types.php b/system/src/Grav/Common/Page/Types.php index 3dd185b67..f52addaae 100644 --- a/system/src/Grav/Common/Page/Types.php +++ b/system/src/Grav/Common/Page/Types.php @@ -50,7 +50,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable throw new \InvalidArgumentException('First parameter must be URI'); } - if (!$this->systemBlueprints) { + if (null === $this->systemBlueprints) { $this->systemBlueprints = $this->findBlueprints('blueprints://pages'); // Register default by default. diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 1981f0801..4848dbd68 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -191,8 +191,8 @@ class Twig $this->twig->addExtension(new DeferredExtension()); $this->twig->addExtension(new StringLoaderExtension()); - $this->profile = new \Twig\Profiler\Profile(); - $this->twig->addExtension(new \Twig\Extension\ProfilerExtension($this->profile)); + $this->profile = new Profile(); + $this->twig->addExtension(new ProfilerExtension($this->profile)); $this->grav->fireEvent('onTwigExtensions'); diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index d93edce31..24bf7d633 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -156,6 +156,9 @@ class Uri if ($custom_base) { $custom_parts = parse_url($custom_base); + if ($custom_parts === false) { + throw new \RuntimeException('Bad configuration: system.custom_base_url'); + } $orig_root_path = $this->root_path; $this->root_path = isset($custom_parts['path']) ? rtrim($custom_parts['path'], '/') : ''; if (isset($custom_parts['scheme'])) { diff --git a/system/src/Grav/Console/Cli/SandboxCommand.php b/system/src/Grav/Console/Cli/SandboxCommand.php index 73dd1e1bd..dba7c7f01 100644 --- a/system/src/Grav/Console/Cli/SandboxCommand.php +++ b/system/src/Grav/Console/Cli/SandboxCommand.php @@ -78,7 +78,12 @@ class SandboxCommand extends ConsoleCommand 'Symlink the base grav system' ) ->setHelp("The sandbox command help create a development environment that can optionally use symbolic links to link the core of grav to the git cloned repository.\nGood for development, playing around or starting fresh"); - $this->source = getcwd(); + + $source = getcwd(); + if ($source === false) { + throw new \RuntimeException('Internal Error'); + } + $this->source = $source; } protected function serve()