diff --git a/system/assets/debugger/clockwork.js b/system/assets/debugger/clockwork.js index 2f2afd439..bb1b69dac 100644 --- a/system/assets/debugger/clockwork.js +++ b/system/assets/debugger/clockwork.js @@ -1,2 +1,3 @@ /** Clockwork Debugger JS **/ -document.addEventListener("DOMContentLoaded",function(){var e=document.createElement("div");e.appendChild(document.createElement("i")),e.className="clockwork-badge",document.body.appendChild(e)}); +document.addEventListener("DOMContentLoaded",function () { + var e=document.createElement("div");e.appendChild(document.createElement("i")),e.className="clockwork-badge",document.body.appendChild(e)}); diff --git a/system/install.php b/system/install.php index 15c3f8b87..07c00eccf 100644 --- a/system/install.php +++ b/system/install.php @@ -14,4 +14,4 @@ use Grav\Installer\Install; require_once __DIR__ . '/src/Grav/Installer/Install.php'; -return Install::instance(); \ No newline at end of file +return Install::instance(); diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 74ba296d0..06804a4bb 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -202,7 +202,6 @@ class Assets extends PropertyObject } return $this; - } /** @@ -212,7 +211,7 @@ class Assets extends PropertyObject */ public function addCss($asset) { - return $this->addType(Assets::CSS_COLLECTION,Assets::CSS_TYPE, $asset, $this->unifyLegacyArguments(\func_get_args(), Assets::CSS_TYPE)); + return $this->addType(Assets::CSS_COLLECTION, Assets::CSS_TYPE, $asset, $this->unifyLegacyArguments(\func_get_args(), Assets::CSS_TYPE)); } /** @@ -266,13 +265,12 @@ class Assets extends PropertyObject protected function filterAssets($assets, $key, $value, $sort = false) { - $results = array_filter($assets, function($asset) use ($key, $value) { + $results = array_filter($assets, function ($asset) use ($key, $value) { if ($key === 'position' && $value === 'pipeline') { - $type = $asset->getType(); - if ($asset->getRemote() && $this->{$type . '_pipeline_include_externals'} === false && $asset['position'] === 'pipeline' ) { + if ($asset->getRemote() && $this->{$type . '_pipeline_include_externals'} === false && $asset['position'] === 'pipeline') { if ($this->{$type . '_pipeline_before_excludes'}) { $asset->setPosition('after'); } else { @@ -280,10 +278,11 @@ class Assets extends PropertyObject } return false; } - } - if ($asset[$key] === $value) return true; + if ($asset[$key] === $value) { + return true; + } return false; }); @@ -297,7 +296,7 @@ class Assets extends PropertyObject protected function sortAssets($assets) { - uasort ($assets, function($a, $b) { + uasort($assets, function ($a, $b) { if ($a['priority'] == $b['priority']) { return $a['order'] - $b['order']; } diff --git a/system/src/Grav/Common/Assets/BaseAsset.php b/system/src/Grav/Common/Assets/BaseAsset.php index 49e38642e..d2de003a8 100644 --- a/system/src/Grav/Common/Assets/BaseAsset.php +++ b/system/src/Grav/Common/Assets/BaseAsset.php @@ -88,7 +88,6 @@ abstract class BaseAsset extends PropertyObject // Move this to render? if (!$this->remote) { - $asset_parts = parse_url($asset); if (isset($asset_parts['query'])) { $this->query = $asset_parts['query']; diff --git a/system/src/Grav/Common/Assets/Css.php b/system/src/Grav/Common/Assets/Css.php index 405d8a347..69f5cf66e 100644 --- a/system/src/Grav/Common/Assets/Css.php +++ b/system/src/Grav/Common/Assets/Css.php @@ -31,7 +31,7 @@ class Css extends BaseAsset public function render() { if (isset($this->attributes['loading']) && $this->attributes['loading'] === 'inline') { - $buffer = $this->gatherLinks( [$this], self::CSS_ASSET); + $buffer = $this->gatherLinks([$this], self::CSS_ASSET); return "\n"; } diff --git a/system/src/Grav/Common/Assets/Js.php b/system/src/Grav/Common/Assets/Js.php index cce86d9ea..e4866f704 100644 --- a/system/src/Grav/Common/Assets/Js.php +++ b/system/src/Grav/Common/Assets/Js.php @@ -27,7 +27,7 @@ class Js extends BaseAsset public function render() { if (isset($this->attributes['loading']) && $this->attributes['loading'] === 'inline') { - $buffer = $this->gatherLinks( [$this], self::JS_ASSET); + $buffer = $this->gatherLinks([$this], self::JS_ASSET); return 'renderAttributes() . ">\n" . trim($buffer) . "\n\n"; } diff --git a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php index 229c2abae..c233cb4a7 100644 --- a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php +++ b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php @@ -39,12 +39,12 @@ trait LegacyAssetsTrait } switch ($type) { - case(Assets::JS_TYPE): + case (Assets::JS_TYPE): $defaults = ['priority' => null, 'pipeline' => true, 'loading' => null, 'group' => null]; $arguments = $this->createArgumentsFromLegacy($args, $defaults); break; - case(Assets::INLINE_JS_TYPE): + case (Assets::INLINE_JS_TYPE): $defaults = ['priority' => null, 'group' => null, 'attributes' => null]; $arguments = $this->createArgumentsFromLegacy($args, $defaults); @@ -57,13 +57,13 @@ trait LegacyAssetsTrait break; - case(Assets::INLINE_CSS_TYPE): + case (Assets::INLINE_CSS_TYPE): $defaults = ['priority' => null, 'group' => null]; $arguments = $this->createArgumentsFromLegacy($args, $defaults); break; default: - case(Assets::CSS_TYPE): + case (Assets::CSS_TYPE): $defaults = ['priority' => null, 'pipeline' => true, 'group' => null, 'loading' => null]; $arguments = $this->createArgumentsFromLegacy($args, $defaults); } @@ -121,5 +121,4 @@ trait LegacyAssetsTrait return $this->addJs($asset, $priority, $pipeline, 'defer', $group); } - } diff --git a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php index 84b83e304..7c054e834 100644 --- a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php +++ b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php @@ -327,8 +327,10 @@ trait TestingAssetsTrait */ protected function rglob($directory, $pattern, $ltrim = null) { - $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, - \FilesystemIterator::SKIP_DOTS)), $pattern); + $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( + $directory, + \FilesystemIterator::SKIP_DOTS + )), $pattern); $offset = \strlen($ltrim); $files = []; @@ -338,6 +340,4 @@ trait TestingAssetsTrait return $files; } - - } diff --git a/system/src/Grav/Common/Backup/Backups.php b/system/src/Grav/Common/Backup/Backups.php index 9582b9e62..054901f6c 100644 --- a/system/src/Grav/Common/Backup/Backups.php +++ b/system/src/Grav/Common/Backup/Backups.php @@ -60,7 +60,7 @@ class Backups $name = $inflector::hyphenize($profile['name']); $logs = 'logs/backup-' . $name . '.out'; /** @var Job $job */ - $job = $scheduler->addFunction('Grav\Common\Backup\Backups::backup', [$id], $name ); + $job = $scheduler->addFunction('Grav\Common\Backup\Backups::backup', [$id], $name); $job->at($at); $job->output($logs); $job->backlink('/tools/backups'); @@ -71,8 +71,10 @@ class Backups { $param_sep = $param_sep = Grav::instance()['config']->get('system.param_sep', ':'); $download = urlencode(base64_encode($backup)); - $url = rtrim(Grav::instance()['uri']->rootUrl(true), '/') . '/' . trim($base_url, - '/') . '/task' . $param_sep . 'backup/download' . $param_sep . $download . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form'); + $url = rtrim(Grav::instance()['uri']->rootUrl(true), '/') . '/' . trim( + $base_url, + '/' + ) . '/task' . $param_sep . 'backup/download' . $param_sep . $download . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form'); return $url; } @@ -113,7 +115,6 @@ class Backups * @var \SplFileInfo $file */ foreach ($backups_itr as $name => $file) { - if (preg_match(static::BACKUP_FILENAME_REGEXZ, $name, $matches)) { $date = \DateTime::createFromFormat(static::BACKUP_DATE_FORMAT, $matches[2]); $timestamp = $date->getTimestamp(); @@ -220,13 +221,12 @@ class Backups $trigger = $purge_config['trigger']; $backups = static::getAvailableBackups(true); - switch ($trigger) - { + switch ($trigger) { case 'number': $backups_count = count($backups); if ($backups_count > $purge_config['max_backups_count']) { $last = end($backups); - unlink ($last->path); + unlink($last->path); static::purge(); } break; diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 5bf3f7608..6530ebd74 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -260,8 +260,10 @@ class Cache extends Getters case 'memcache': if (extension_loaded('memcache')) { $memcache = new \Memcache(); - $memcache->connect($this->config->get('system.cache.memcache.server', 'localhost'), - $this->config->get('system.cache.memcache.port', 11211)); + $memcache->connect( + $this->config->get('system.cache.memcache.server', 'localhost'), + $this->config->get('system.cache.memcache.port', 11211) + ); $driver = new DoctrineCache\MemcacheCache(); $driver->setMemcache($memcache); } else { @@ -272,8 +274,10 @@ class Cache extends Getters case 'memcached': if (extension_loaded('memcached')) { $memcached = new \Memcached(); - $memcached->addServer($this->config->get('system.cache.memcached.server', 'localhost'), - $this->config->get('system.cache.memcached.port', 11211)); + $memcached->addServer( + $this->config->get('system.cache.memcached.server', 'localhost'), + $this->config->get('system.cache.memcached.port', 11211) + ); $driver = new DoctrineCache\MemcachedCache(); $driver->setMemcached($memcached); } else { @@ -290,8 +294,10 @@ class Cache extends Getters if ($socket) { $redis->connect($socket); } else { - $redis->connect($this->config->get('system.cache.redis.server', 'localhost'), - $this->config->get('system.cache.redis.port', 6379)); + $redis->connect( + $this->config->get('system.cache.redis.server', 'localhost'), + $this->config->get('system.cache.redis.port', 6379) + ); } // Authenticate with password if set @@ -446,7 +452,6 @@ class Cache extends Getters } else { $remove_paths = self::$standard_remove_no_images; } - } // Delete entries in the doctrine cache if required @@ -459,11 +464,12 @@ class Cache extends Getters Grav::instance()->fireEvent('onBeforeCacheClear', new Event(['remove' => $remove, 'paths' => &$remove_paths])); foreach ($remove_paths as $stream) { - // Convert stream to a real path try { $path = $locator->findResource($stream, true, true); - if($path === false) continue; + if ($path === false) { + continue; + } $anything = false; $files = glob($path . '/*'); @@ -528,7 +534,6 @@ class Cache extends Getters if (function_exists('opcache_reset')) { @opcache_reset(); } - } /** @@ -634,7 +639,7 @@ class Cache extends Getters $name = 'cache-purge'; $logs = 'logs/' . $name . '.out'; - $job = $scheduler->addFunction('Grav\Common\Cache::purgeJob', [], $name ); + $job = $scheduler->addFunction('Grav\Common\Cache::purgeJob', [], $name); $job->at($at); $job->output($logs); $job->backlink('/config/system#caching'); @@ -645,12 +650,9 @@ class Cache extends Getters $name = 'cache-clear'; $logs = 'logs/' . $name . '.out'; - $job = $scheduler->addFunction('Grav\Common\Cache::clearJob', [$clear_type], $name ); + $job = $scheduler->addFunction('Grav\Common\Cache::clearJob', [$clear_type], $name); $job->at($at); $job->output($logs); $job->backlink('/config/system#caching'); - } - - } diff --git a/system/src/Grav/Common/Config/CompiledBase.php b/system/src/Grav/Common/Config/CompiledBase.php index 3e2022f0d..708a292ca 100644 --- a/system/src/Grav/Common/Config/CompiledBase.php +++ b/system/src/Grav/Common/Config/CompiledBase.php @@ -89,7 +89,9 @@ abstract class CompiledBase /** * Function gets called when cached configuration is saved. */ - public function modified() {} + public function modified() + { + } /** * Get timestamp of compiled configuration @@ -197,8 +199,7 @@ abstract class CompiledBase } $cache = include $filename; - if ( - !\is_array($cache) + if (!\is_array($cache) || !isset($cache['checksum'], $cache['data'], $cache['@class']) || $cache['@class'] !== \get_class($this) ) { diff --git a/system/src/Grav/Common/Data/BlueprintSchema.php b/system/src/Grav/Common/Data/BlueprintSchema.php index 0fa2ca8e1..bd81d0f5c 100644 --- a/system/src/Grav/Common/Data/BlueprintSchema.php +++ b/system/src/Grav/Common/Data/BlueprintSchema.php @@ -54,7 +54,6 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface { try { $messages = $this->validateArray($data, $this->nested); - } catch (\RuntimeException $e) { throw (new ValidationException($e->getMessage(), $e->getCode(), $e))->setMessages(); } @@ -201,7 +200,6 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface } elseif (\is_array($field) && \is_array($val)) { // Array has been defined in blueprints. $field = $this->filterArray($field, $val, $missingValuesAsNull, $keepEmptyValues); - } elseif (isset($rules['validation']) && $rules['validation'] === 'strict') { // Skip any extra data. continue; @@ -288,7 +286,6 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface // Check if required. if (isset($field['validate']['required']) && $field['validate']['required'] === true) { - if (isset($data[$name])) { continue; } diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php index bfae2dae8..496fd2e2e 100644 --- a/system/src/Grav/Common/Data/Data.php +++ b/system/src/Grav/Common/Data/Data.php @@ -227,7 +227,7 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable */ public function blueprints() { - if (!$this->blueprints){ + if (!$this->blueprints) { $this->blueprints = new Blueprint; } elseif (\is_callable($this->blueprints)) { // Lazy load blueprints. diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index 7779b1c27..903cd73c8 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -674,7 +674,6 @@ class Validation } return (array) Yaml::parse($value); - } /** @@ -794,7 +793,9 @@ class Validation public static function filterItem_List($value, $params) { - return array_values(array_filter($value, function($v) { return !empty($v); } )); + return array_values(array_filter($value, function ($v) { + return !empty($v); + })); } public static function validateJson($value, $params) diff --git a/system/src/Grav/Common/Data/ValidationException.php b/system/src/Grav/Common/Data/ValidationException.php index 8bdb0572d..4cf805e57 100644 --- a/system/src/Grav/Common/Data/ValidationException.php +++ b/system/src/Grav/Common/Data/ValidationException.php @@ -15,7 +15,8 @@ class ValidationException extends \RuntimeException { protected $messages = []; - public function setMessages(array $messages = []) { + public function setMessages(array $messages = []) + { $this->messages = $messages; $language = Grav::instance()['language']; diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php index 841611ae4..ffcefef69 100644 --- a/system/src/Grav/Common/Debugger.php +++ b/system/src/Grav/Common/Debugger.php @@ -188,7 +188,7 @@ class Debugger if ($this->currentTime !== GRAV_REQUEST_TIME) { $debugbar['time']->addMeasure('Loading', GRAV_REQUEST_TIME, $this->currentTime); } - $debugbar['time']->addMeasure('Site Setup', $this->currentTime, microtime(true)); + $debugbar['time']->addMeasure('Site Setup', $this->currentTime, microtime(true)); } $this->addMessage('Grav v' . GRAV_VERSION . ' - PHP ' . PHP_VERSION); @@ -320,7 +320,9 @@ class Debugger return new Response(404, $headers, json_encode($response)); } - $data = is_array($data) ? array_map(function ($item) { return $item->toArray(); }, $data) : $data->toArray(); + $data = is_array($data) ? array_map(function ($item) { + return $item->toArray(); + }, $data) : $data->toArray(); return new Response(200, $headers, json_encode($data)); } @@ -347,7 +349,7 @@ class Debugger } if ($debTimeLine) { - $debTimeLine->addMeasure($description ?? $name, $startTime, $endTime); + $debTimeLine->addMeasure($description ?? $name, $startTime, $endTime); } } $this->timers = []; @@ -377,8 +379,6 @@ class Debugger public function addAssets() { if ($this->enabled) { - - // Only add assets if Page is HTML $page = $this->grav['page']; if ($page->templateFormat() !== 'html') { @@ -397,7 +397,6 @@ class Debugger // Debugbar specific assets if ($this->debugbar) { - // Add jquery library $assets->add('jquery', 101); @@ -416,7 +415,6 @@ class Debugger $assets->addJs($js); } } - } return $this; @@ -589,7 +587,7 @@ class Debugger }); uasort($timings, function (array $a, array $b) { - return $b['wt'] <=> $a['wt']; + return $b['wt'] <=> $a['wt']; }); $table = []; diff --git a/system/src/Grav/Common/Errors/BareHandler.php b/system/src/Grav/Common/Errors/BareHandler.php index 52effc6d4..49595c98f 100644 --- a/system/src/Grav/Common/Errors/BareHandler.php +++ b/system/src/Grav/Common/Errors/BareHandler.php @@ -21,12 +21,10 @@ class BareHandler extends Handler { $inspector = $this->getInspector(); $code = $inspector->getException()->getCode(); - if ( ($code >= 400) && ($code < 600) ) - { - $this->getRun()->sendHttpCode($code); + if (($code >= 400) && ($code < 600)) { + $this->getRun()->sendHttpCode($code); } return Handler::QUIT; } - } diff --git a/system/src/Grav/Common/Errors/Errors.php b/system/src/Grav/Common/Errors/Errors.php index 2f71be5a1..19d449363 100644 --- a/system/src/Grav/Common/Errors/Errors.php +++ b/system/src/Grav/Common/Errors/Errors.php @@ -56,7 +56,7 @@ class Errors if (isset($config['log']) && $config['log']) { $logger = $grav['log']; - $whoops->prependHandler(function($exception, $inspector, $run) use ($logger) { + $whoops->prependHandler(function ($exception, $inspector, $run) use ($logger) { try { $logger->addCritical($exception->getMessage() . ' - Trace: ' . $exception->getTraceAsString()); } catch (\Exception $e) { diff --git a/system/src/Grav/Common/Errors/SimplePageHandler.php b/system/src/Grav/Common/Errors/SimplePageHandler.php index 311d72244..b5ca4d5fa 100644 --- a/system/src/Grav/Common/Errors/SimplePageHandler.php +++ b/system/src/Grav/Common/Errors/SimplePageHandler.php @@ -36,9 +36,8 @@ class SimplePageHandler extends Handler $cssFile = $this->getResource('error.css'); $code = $inspector->getException()->getCode(); - if ( ($code >= 400) && ($code < 600) ) - { - $this->getRun()->sendHttpCode($code); + if (($code >= 400) && ($code < 600)) { + $this->getRun()->sendHttpCode($code); } $message = $inspector->getException()->getMessage(); diff --git a/system/src/Grav/Common/File/CompiledFile.php b/system/src/Grav/Common/File/CompiledFile.php index f4b1e8d4d..45ffb8fde 100644 --- a/system/src/Grav/Common/File/CompiledFile.php +++ b/system/src/Grav/Common/File/CompiledFile.php @@ -38,8 +38,7 @@ trait CompiledFile $cache = $file->exists() ? $file->content() : null; // Load real file if cache isn't up to date (or is invalid). - if ( - !isset($cache['@class']) + if (!isset($cache['@class']) || $cache['@class'] !== $class || $cache['modified'] !== $modified || $cache['filename'] !== $this->filename @@ -76,7 +75,6 @@ trait CompiledFile $this->content = $cache['data']; } - } catch (\Exception $e) { throw new \RuntimeException(sprintf('Failed to read %s: %s', basename($this->filename), $e->getMessage()), 500, $e); } diff --git a/system/src/Grav/Common/Filesystem/Archiver.php b/system/src/Grav/Common/Filesystem/Archiver.php index 50e40fbea..58e4a421a 100644 --- a/system/src/Grav/Common/Filesystem/Archiver.php +++ b/system/src/Grav/Common/Filesystem/Archiver.php @@ -46,11 +46,11 @@ abstract class Archiver return $this; } - public abstract function compress($folder, callable $status = null); + abstract public function compress($folder, callable $status = null); - public abstract function extract($destination, callable $status = null); + abstract public function extract($destination, callable $status = null); - public abstract function addEmptyFolders($folders, callable $status = null); + abstract public function addEmptyFolders($folders, callable $status = null); protected function getArchiveFiles($rootPath) { @@ -62,5 +62,4 @@ abstract class Archiver return $files; } - } diff --git a/system/src/Grav/Common/Filesystem/ZipArchiver.php b/system/src/Grav/Common/Filesystem/ZipArchiver.php index 91212f770..d1fffb31a 100644 --- a/system/src/Grav/Common/Filesystem/ZipArchiver.php +++ b/system/src/Grav/Common/Filesystem/ZipArchiver.php @@ -97,7 +97,7 @@ class ZipArchiver extends Archiver 'message' => 'Adding empty folders...' ]); - foreach($folders as $folder) { + foreach ($folders as $folder) { $zip->addEmptyDir($folder); $status && $status([ 'type' => 'progress', diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index 6c9e7b0e4..0cb6486ce 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -561,8 +561,7 @@ class GPM extends Iterator $plugin_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Plugin/m'; $theme_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Theme/m'; - if ( - file_exists($source . 'system/defines.php') && + if (file_exists($source . 'system/defines.php') && file_exists($source . 'system/config/system.yaml') ) { return 'grav'; @@ -784,18 +783,24 @@ class GPM extends Iterator if (count($dependent_packages)) { foreach ($dependent_packages as $dependent_package) { - $other_dependency_version_with_operator = $this->getVersionOfDependencyRequiredByPackage($dependent_package, - $slug); + $other_dependency_version_with_operator = $this->getVersionOfDependencyRequiredByPackage( + $dependent_package, + $slug + ); $other_dependency_version = $this->calculateVersionNumberFromDependencyVersion($other_dependency_version_with_operator); // check version is compatible with the one needed by the current package if ($this->versionFormatIsNextSignificantRelease($other_dependency_version_with_operator)) { - $compatible = $this->checkNextSignificantReleasesAreCompatible($version, - $other_dependency_version); + $compatible = $this->checkNextSignificantReleasesAreCompatible( + $version, + $other_dependency_version + ); if (!$compatible) { if (!in_array($dependent_package, $ignore_packages_list, true)) { - throw new \RuntimeException("Package $slug is required in an older version by package $dependent_package. This package needs a newer version, and because of this it cannot be installed. The $dependent_package package must be updated to use a newer release of $slug.", - 2); + throw new \RuntimeException( + "Package $slug is required in an older version by package $dependent_package. This package needs a newer version, and because of this it cannot be installed. The $dependent_package package must be updated to use a newer release of $slug.", + 2 + ); } } } @@ -815,8 +820,11 @@ class GPM extends Iterator public function checkPackagesCanBeInstalled($packages_names_list) { foreach ($packages_names_list as $package_name) { - $this->checkNoOtherPackageNeedsThisDependencyInALowerVersion($package_name, - $this->getLatestVersionOfPackage($package_name), $packages_names_list); + $this->checkNoOtherPackageNeedsThisDependencyInALowerVersion( + $package_name, + $this->getLatestVersionOfPackage($package_name), + $packages_names_list + ); } } @@ -845,8 +853,10 @@ class GPM extends Iterator // Check PHP version if ($dependency_slug === 'php') { $current_php_version = phpversion(); - if (version_compare($this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator), - $current_php_version) === 1 + if (version_compare( + $this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator), + $current_php_version + ) === 1 ) { //Needs a Grav update first throw new \RuntimeException("One of the packages require PHP {$dependencies['php']}. Please update PHP to resolve this"); @@ -858,8 +868,10 @@ class GPM extends Iterator //First, check for Grav dependency. If a dependency requires Grav > the current version, abort and tell. if ($dependency_slug === 'grav') { - if (version_compare($this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator), - GRAV_VERSION) === 1 + if (version_compare( + $this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator), + GRAV_VERSION + ) === 1 ) { //Needs a Grav update first throw new \RuntimeException("One of the packages require Grav {$dependencies['grav']}. Please update Grav to the latest release."); @@ -888,12 +900,16 @@ class GPM extends Iterator // if requirement is next significant release, check is compatible with currently installed version, might not be if ($this->versionFormatIsNextSignificantRelease($dependencyVersionWithOperator)) { if ($this->firstVersionIsLower($dependencyVersion, $currentlyInstalledVersion)) { - $compatible = $this->checkNextSignificantReleasesAreCompatible($dependencyVersion, - $currentlyInstalledVersion); + $compatible = $this->checkNextSignificantReleasesAreCompatible( + $dependencyVersion, + $currentlyInstalledVersion + ); if (!$compatible) { - throw new \RuntimeException('Dependency ' . $dependency_slug . ' is required in an older version than the one installed. This package must be updated. Please get in touch with its developer.', - 2); + throw new \RuntimeException( + 'Dependency ' . $dependency_slug . ' is required in an older version than the one installed. This package must be updated. Please get in touch with its developer.', + 2 + ); } } } @@ -903,8 +919,10 @@ class GPM extends Iterator if ($this->firstVersionIsLower($latestRelease, $dependencyVersion)) { //throw an exception if a required version cannot be found in the GPM yet - throw new \RuntimeException('Dependency ' . $package_yaml['name'] . ' is required in version ' . $dependencyVersion . ' which is higher than the latest release, ' . $latestRelease . '. Try running `bin/gpm -f index` to force a refresh of the GPM cache', - 1); + throw new \RuntimeException( + 'Dependency ' . $package_yaml['name'] . ' is required in version ' . $dependencyVersion . ' which is higher than the latest release, ' . $latestRelease . '. Try running `bin/gpm -f index` to force a refresh of the GPM cache', + 1 + ); } if ($this->firstVersionIsLower($currentlyInstalledVersion, $dependencyVersion)) { @@ -924,12 +942,16 @@ class GPM extends Iterator if ($this->versionFormatIsNextSignificantRelease($dependencyVersionWithOperator)) { $latestVersionOfPackage = $this->getLatestVersionOfPackage($dependency_slug); if ($this->firstVersionIsLower($dependencyVersion, $latestVersionOfPackage)) { - $compatible = $this->checkNextSignificantReleasesAreCompatible($dependencyVersion, - $latestVersionOfPackage); + $compatible = $this->checkNextSignificantReleasesAreCompatible( + $dependencyVersion, + $latestVersionOfPackage + ); if (!$compatible) { - throw new \Exception('Dependency ' . $dependency_slug . ' is required in an older version than the latest release available, and it cannot be installed. This package must be updated. Please get in touch with its developer.', - 2); + throw new \Exception( + 'Dependency ' . $dependency_slug . ' is required in an older version than the latest release available, and it cannot be installed. This package must be updated. Please get in touch with its developer.', + 2 + ); } } } @@ -947,8 +969,11 @@ class GPM extends Iterator public function checkNoOtherPackageNeedsTheseDependenciesInALowerVersion($dependencies_slugs) { foreach ($dependencies_slugs as $dependency_slug) { - $this->checkNoOtherPackageNeedsThisDependencyInALowerVersion($dependency_slug, - $this->getLatestVersionOfPackage($dependency_slug), $dependencies_slugs); + $this->checkNoOtherPackageNeedsThisDependencyInALowerVersion( + $dependency_slug, + $this->getLatestVersionOfPackage($dependency_slug), + $dependencies_slugs + ); } } @@ -994,7 +1019,6 @@ class GPM extends Iterator // Dependency already added by another package //if this package requires a version higher than the currently stored one, store this requirement instead if (isset($current_package_version_information) && $current_package_version_information !== '*') { - $currently_stored_version_information = $dependencies[$current_package_name]; $currently_stored_version_number = $this->calculateVersionNumberFromDependencyVersion($currently_stored_version_information); @@ -1009,8 +1033,10 @@ class GPM extends Iterator $current_package_version_number = $this->calculateVersionNumberFromDependencyVersion($current_package_version_information); if (!$current_package_version_number) { - throw new \RuntimeException('Bad format for version of dependency ' . $current_package_name . ' for package ' . $packageName, - 1); + throw new \RuntimeException( + 'Bad format for version of dependency ' . $current_package_name . ' for package ' . $packageName, + 1 + ); } $current_package_version_is_in_next_significant_release_format = false; @@ -1024,17 +1050,23 @@ class GPM extends Iterator } else { if (!$currently_stored_version_is_in_next_significant_release_format && !$current_package_version_is_in_next_significant_release_format) { //Comparing versions equals or higher, a simple version_compare is enough - if (version_compare($currently_stored_version_number, - $current_package_version_number) === -1 + if (version_compare( + $currently_stored_version_number, + $current_package_version_number + ) === -1 ) { //Current package version is higher $dependencies[$current_package_name] = $current_package_version_information; } } else { - $compatible = $this->checkNextSignificantReleasesAreCompatible($currently_stored_version_number, - $current_package_version_number); + $compatible = $this->checkNextSignificantReleasesAreCompatible( + $currently_stored_version_number, + $current_package_version_number + ); if (!$compatible) { - throw new \RuntimeException('Dependency ' . $current_package_name . ' is required in two incompatible versions', - 2); + throw new \RuntimeException( + 'Dependency ' . $current_package_name . ' is required in two incompatible versions', + 2 + ); } } } @@ -1156,5 +1188,4 @@ class GPM extends Iterator return true; } - } diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php index cd5116383..62ef3b3d5 100644 --- a/system/src/Grav/Common/GPM/Installer.php +++ b/system/src/Grav/Common/GPM/Installer.php @@ -84,8 +84,10 @@ class Installer $options = array_merge(self::$options, $options); $install_path = rtrim($destination . DS . ltrim($options['install_path'], DS), DS); - if (!self::isGravInstance($destination) || !self::isValidDestination($install_path, - $options['exclude_checks']) + if (!self::isGravInstance($destination) || !self::isValidDestination( + $install_path, + $options['exclude_checks'] + ) ) { return false; } @@ -160,7 +162,6 @@ class Installer self::$error = self::OK; return true; - } /** @@ -297,7 +298,6 @@ class Installer public static function sophisticatedInstall($source_path, $install_path, $ignores = [], $keep_source = false) { foreach (new \DirectoryIterator($source_path) as $file) { - if ($file->isLink() || $file->isDot() || \in_array($file->getFilename(), $ignores, true)) { continue; } @@ -410,8 +410,7 @@ class Installer self::$error = 0; self::$target = $target; - if ( - !file_exists($target . DS . 'index.php') || + if (!file_exists($target . DS . 'index.php') || !file_exists($target . DS . 'bin') || !file_exists($target . DS . 'user') || !file_exists($target . DS . 'system' . DS . 'config' . DS . 'system.yaml') @@ -473,7 +472,7 @@ class Installer case self::ZIP_EXTRACT_ERROR: $msg = 'Unable to extract the package. '; if (self::$error_zip) { - switch(self::$error_zip) { + switch (self::$error_zip) { case \ZipArchive::ER_EXISTS: $msg .= 'File already exists.'; break; diff --git a/system/src/Grav/Common/GPM/Licenses.php b/system/src/Grav/Common/GPM/Licenses.php index 14c925832..4b9bc8143 100644 --- a/system/src/Grav/Common/GPM/Licenses.php +++ b/system/src/Grav/Common/GPM/Licenses.php @@ -108,7 +108,6 @@ class Licenses * @return \RocketTheme\Toolbox\File\FileInterface */ public static function getLicenseFile() - { if (!isset(self::$file)) { $path = Grav::instance()['locator']->findResource('user-data://') . '/licenses.yaml'; diff --git a/system/src/Grav/Common/GPM/Response.php b/system/src/Grav/Common/GPM/Response.php index fead16899..5c203fa87 100644 --- a/system/src/Grav/Common/GPM/Response.php +++ b/system/src/Grav/Common/GPM/Response.php @@ -234,7 +234,6 @@ class Response if ($bytes_transferred > 0) { if ($notification_code == STREAM_NOTIFY_PROGRESS | STREAM_NOTIFY_COMPLETED || $isCurlResource) { - $progress = [ 'code' => $notification_code, 'filesize' => $filesize, diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 8b6531038..b685a58f5 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -421,7 +421,6 @@ class Grav extends Container if ($this['config']->get('system.cache.gzip')) { // Flush gzhandler buffer if gzip setting was enabled. ob_end_flush(); - } else { // Without gzip we have no other choice than to prevent server from compressing the output. // This action turns off mod_deflate which would prevent us from closing the connection. @@ -430,7 +429,6 @@ class Grav extends Container } else { header('Content-Encoding: none'); } - } diff --git a/system/src/Grav/Common/Helpers/Base32.php b/system/src/Grav/Common/Helpers/Base32.php index f13855702..c0828c059 100644 --- a/system/src/Grav/Common/Helpers/Base32.php +++ b/system/src/Grav/Common/Helpers/Base32.php @@ -33,7 +33,8 @@ class Base32 */ public static function encode($bytes) { - $i = 0; $index = 0; + $i = 0; + $index = 0; $base32 = ''; $bytesLen = \strlen($bytes); diff --git a/system/src/Grav/Common/Helpers/Excerpts.php b/system/src/Grav/Common/Helpers/Excerpts.php index f07c3aa5a..bd6166288 100644 --- a/system/src/Grav/Common/Helpers/Excerpts.php +++ b/system/src/Grav/Common/Helpers/Excerpts.php @@ -32,7 +32,7 @@ class Excerpts $excerpt = static::processLinkExcerpt($excerpt, $page, 'image'); $excerpt['element']['attributes']['src'] = $excerpt['element']['attributes']['href']; - unset ($excerpt['element']['attributes']['href']); + unset($excerpt['element']['attributes']['href']); $excerpt = static::processImageExcerpt($excerpt, $page); diff --git a/system/src/Grav/Common/Helpers/LogViewer.php b/system/src/Grav/Common/Helpers/LogViewer.php index 397fb1754..db9a4fc9e 100644 --- a/system/src/Grav/Common/Helpers/LogViewer.php +++ b/system/src/Grav/Common/Helpers/LogViewer.php @@ -41,15 +41,20 @@ class LogViewer * @param int $lines * @return bool|string */ - public function tail($filepath, $lines = 1) { + public function tail($filepath, $lines = 1) + { $f = @fopen($filepath, "rb"); - if ($f === false) return false; - - else $buffer = ($lines < 2 ? 64 : ($lines < 10 ? 512 : 4096)); + if ($f === false) { + return false; + } else { + $buffer = ($lines < 2 ? 64 : ($lines < 10 ? 512 : 4096)); + } fseek($f, -1, SEEK_END); - if (fread($f, 1) != "\n") $lines -= 1; + if (fread($f, 1) != "\n") { + $lines -= 1; + } // Start reading $output = ''; @@ -108,7 +113,7 @@ class LogViewer */ public function parse($line) { - if( !is_string($line) || strlen($line) === 0) { + if (!is_string($line) || strlen($line) === 0) { return array(); } preg_match($this->pattern, $line, $data); @@ -145,5 +150,4 @@ class LogViewer $lines = array_filter(preg_split('/#\d*/m', $trace)); return array_slice($lines, 0, $rows); } - } diff --git a/system/src/Grav/Common/Helpers/Truncator.php b/system/src/Grav/Common/Helpers/Truncator.php index 6827865d5..015a47dd6 100644 --- a/system/src/Grav/Common/Helpers/Truncator.php +++ b/system/src/Grav/Common/Helpers/Truncator.php @@ -26,7 +26,8 @@ use DOMLettersIterator; * file that was distributed with this source code. */ -class Truncator { +class Truncator +{ /** * Safely truncates HTML by a given number of words. @@ -49,10 +50,8 @@ class Truncator { $words = new DOMWordsIterator($container); $truncated = false; foreach ($words as $word) { - // If we have exceeded the limit, we delete the remainder of the content. if ($words->key() >= $limit) { - // Grab current position. $currentWordPosition = $words->currentWordPosition(); $curNode = $currentWordPosition[0]; @@ -75,7 +74,6 @@ class Truncator { break; } - } // Return original HTML if not truncated. @@ -107,10 +105,8 @@ class Truncator { $letters = new DOMLettersIterator($container); $truncated = false; foreach ($letters as $letter) { - // If we have exceeded the limit, we want to delete the remainder of this document. if ($letters->key() >= $limit) { - $currentText = $letters->currentTextPosition(); $currentText[0]->nodeValue = mb_substr($currentText[0]->nodeValue, 0, $currentText[1] + 1); self::removeProceedingNodes($currentText[0], $container); @@ -199,7 +195,7 @@ class Truncator { $doc->removeChild($doc->firstChild); } - while ($container->firstChild ) { + while ($container->firstChild) { $doc->appendChild($container->firstChild); } @@ -225,7 +221,6 @@ class Truncator { } else { $domNode->parentNode->parentNode->appendChild($textNode); } - } else { // Append to current node $domNode->nodeValue = rtrim($domNode->nodeValue) . $ellipsis; @@ -241,8 +236,7 @@ class Truncator { $ending = '...', $exact = false, $considerHtml = true - ) - { + ) { if ($considerHtml) { // if the plain text is shorter than the maximum length, return the whole text if (strlen(preg_replace('/<.*?>/', '', $text)) <= $length) { @@ -262,14 +256,14 @@ class Truncator { if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { // do nothing // if tag is a closing tag - } else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { + } elseif (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { // delete tag from $open_tags list $pos = array_search($tag_matchings[1], $open_tags); if ($pos !== false) { unset($open_tags[$pos]); } // if tag is an opening tag - } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) { + } elseif (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) { // add tag to the beginning of $open_tags list array_unshift($open_tags, strtolower($tag_matchings[1])); } @@ -303,7 +297,7 @@ class Truncator { $total_length += $content_length; } // if the maximum length is reached, get off the loop - if($total_length>= $length) { + if ($total_length>= $length) { break; } } @@ -333,5 +327,4 @@ class Truncator { } return $truncate; } - } diff --git a/system/src/Grav/Common/Helpers/YamlLinter.php b/system/src/Grav/Common/Helpers/YamlLinter.php index 3844859fe..ec56ff798 100644 --- a/system/src/Grav/Common/Helpers/YamlLinter.php +++ b/system/src/Grav/Common/Helpers/YamlLinter.php @@ -87,5 +87,4 @@ class YamlLinter } return $contents; } - } diff --git a/system/src/Grav/Common/Inflector.php b/system/src/Grav/Common/Inflector.php index cc6643e93..1d7cc2546 100644 --- a/system/src/Grav/Common/Inflector.php +++ b/system/src/Grav/Common/Inflector.php @@ -73,7 +73,6 @@ class Inflector } return false; - } /** diff --git a/system/src/Grav/Common/Iterator.php b/system/src/Grav/Common/Iterator.php index 5f6dc7ea0..cfb5e6c63 100644 --- a/system/src/Grav/Common/Iterator.php +++ b/system/src/Grav/Common/Iterator.php @@ -228,8 +228,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable public function filter(callable $callback = null) { foreach ($this->items as $key => $value) { - if ( - (!$callback && !(bool)$value) || + if ((!$callback && !(bool)$value) || ($callback && !$callback($value, $key)) ) { unset($this->items[$key]); diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php index dddd0d524..a10b15cdc 100644 --- a/system/src/Grav/Common/Language/Language.php +++ b/system/src/Grav/Common/Language/Language.php @@ -115,7 +115,7 @@ class Language { $languagesArray = $this->languages; //Make local copy - $languagesArray = array_map(function($value) use ($delimiter) { + $languagesArray = array_map(function ($value) use ($delimiter) { return preg_quote($value, $delimiter); }, $languagesArray); @@ -232,7 +232,6 @@ class Language if ($this->active === null && $this->config->get('system.languages.http_accept_language') && $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? false) { - $negotiator = new LanguageNegotiator(); $best_language = $negotiator->getBest($accept, $this->languages); @@ -241,7 +240,6 @@ class Language } else { $this->setActive($this->getDefault()); } - } } } @@ -404,7 +402,6 @@ class Language } } $fallback_languages = array_reverse($fallback_languages); - } else { if (null === $fallback) { $fallback = [$default]; diff --git a/system/src/Grav/Common/Markdown/Parsedown.php b/system/src/Grav/Common/Markdown/Parsedown.php index 32033ddff..6072907ba 100644 --- a/system/src/Grav/Common/Markdown/Parsedown.php +++ b/system/src/Grav/Common/Markdown/Parsedown.php @@ -35,5 +35,4 @@ class Parsedown extends \Parsedown $this->init($excerpts, $defaults); } - } diff --git a/system/src/Grav/Common/Media/Traits/MediaTrait.php b/system/src/Grav/Common/Media/Traits/MediaTrait.php index 9558dfa74..a90672169 100644 --- a/system/src/Grav/Common/Media/Traits/MediaTrait.php +++ b/system/src/Grav/Common/Media/Traits/MediaTrait.php @@ -45,23 +45,23 @@ trait MediaTrait */ public function getMediaUri() { - $folder = $this->getMediaFolder(); - if (!$folder) { - return null; - } + $folder = $this->getMediaFolder(); + if (!$folder) { + return null; + } - if (strpos($folder, '://')) { - return $folder; - } + if (strpos($folder, '://')) { + return $folder; + } /** @var UniformResourceLocator $locator */ - $locator = Grav::instance()['locator']; - $user = $locator->findResource('user://'); - if (strpos($folder, $user) === 0) { - return 'user://' . substr($folder, \strlen($user)+1); - } + $locator = Grav::instance()['locator']; + $user = $locator->findResource('user://'); + if (strpos($folder, $user) === 0) { + return 'user://' . substr($folder, \strlen($user)+1); + } - return null; + return null; } /** diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php index 69ca7f8b0..36f00e66a 100644 --- a/system/src/Grav/Common/Page/Collection.php +++ b/system/src/Grav/Common/Page/Collection.php @@ -114,7 +114,7 @@ class Collection extends Iterator implements PageCollectionInterface */ public function merge(PageCollectionInterface $collection) { - foreach($collection as $page) { + foreach ($collection as $page) { $this->addPage($page); } @@ -132,7 +132,7 @@ class Collection extends Iterator implements PageCollectionInterface $array1 = $this->items; $array2 = $collection->toArray(); - $this->items = array_uintersect($array1, $array2, function($val1, $val2) { + $this->items = array_uintersect($array1, $array2, function ($val1, $val2) { return strcmp($val1['slug'], $val2['slug']); }); @@ -602,7 +602,6 @@ class Collection extends Iterator implements PageCollectionInterface $items[$path] = $slug; } } - } } diff --git a/system/src/Grav/Common/Page/Flex/PageCollection.php b/system/src/Grav/Common/Page/Flex/PageCollection.php index b0daa571a..ef11e0bef 100644 --- a/system/src/Grav/Common/Page/Flex/PageCollection.php +++ b/system/src/Grav/Common/Page/Flex/PageCollection.php @@ -439,7 +439,6 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa $entries[$key] = $object; } } - } } diff --git a/system/src/Grav/Common/Page/Flex/PageObject.php b/system/src/Grav/Common/Page/Flex/PageObject.php index 48f90d9dc..b18677d23 100644 --- a/system/src/Grav/Common/Page/Flex/PageObject.php +++ b/system/src/Grav/Common/Page/Flex/PageObject.php @@ -376,7 +376,9 @@ class PageObject extends FlexPageObject 'tags' => $tags, 'actions' => null, ]; - $extras = array_filter($extras, static function($v) { return $v !== null; }); + $extras = array_filter($extras, static function ($v) { + return $v !== null; + }); $payload = [ 'item-key' => basename($child->rawRoute()), 'icon' => $icon, @@ -389,7 +391,9 @@ class PageObject extends FlexPageObject 'child_count' => count($child->children()) ?: null, 'extras' => $extras ]; - $payload = array_filter($payload, static function($v) { return $v !== null; }); + $payload = array_filter($payload, static function ($v) { + return $v !== null; + }); } // Add children if any diff --git a/system/src/Grav/Common/Page/Flex/Traits/PageContentTrait.php b/system/src/Grav/Common/Page/Flex/Traits/PageContentTrait.php index 4f3384c2a..bcf31b915 100644 --- a/system/src/Grav/Common/Page/Flex/Traits/PageContentTrait.php +++ b/system/src/Grav/Common/Page/Flex/Traits/PageContentTrait.php @@ -46,7 +46,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'date', $var, - function($value) { + function ($value) { $value = $value ? Utils::date2timestamp($value, $this->getProperty('dateformat')) : false; if (!$value) { diff --git a/system/src/Grav/Common/Page/Flex/Traits/PageTranslateTrait.php b/system/src/Grav/Common/Page/Flex/Traits/PageTranslateTrait.php index 7e45986cf..e6e18577d 100644 --- a/system/src/Grav/Common/Page/Flex/Traits/PageTranslateTrait.php +++ b/system/src/Grav/Common/Page/Flex/Traits/PageTranslateTrait.php @@ -89,6 +89,8 @@ trait PageTranslateTrait $list[$languageCode ?: $defaultCode] = $route ?? ''; } - return array_filter($list, static function($var) { return null !== $var; }); + return array_filter($list, static function ($var) { + return null !== $var; + }); } } diff --git a/system/src/Grav/Common/Page/Markdown/Excerpts.php b/system/src/Grav/Common/Page/Markdown/Excerpts.php index 1cbd93803..8b35dc380 100644 --- a/system/src/Grav/Common/Page/Markdown/Excerpts.php +++ b/system/src/Grav/Common/Page/Markdown/Excerpts.php @@ -113,7 +113,7 @@ class Excerpts // If no query elements left, unset query. if (empty($url_parts['query'])) { - unset ($url_parts['query']); + unset($url_parts['query']); } // Set path to / if not set. @@ -162,7 +162,6 @@ class Excerpts $filename = $url_parts['scheme'] . '://' . ($url_parts['path'] ?? ''); $media = $this->page->getMedia(); - } else { $grav = Grav::instance(); @@ -211,7 +210,6 @@ class Excerpts $id = $element_excerpt['id'] ?? ''; $excerpt['element'] = $medium->parsedownElement($title, $alt, $class, $id, true); - } else { // Not a current page media file, see if it needs converting to relative. $excerpt['element']['attributes']['src'] = Uri::buildUrl($url_parts); diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index 8a84ac818..3dae3c906 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -155,7 +155,6 @@ class Media extends AbstractMedia if (file_exists($meta_path)) { $types['meta']['file'] = $meta_path; } elseif ($file_path && $exif_reader && $medium->get('mime') === 'image/jpeg' && empty($types['meta']) && $config->get('system.media.auto_metadata_exif')) { - $meta = $exif_reader->read($file_path); if ($meta) { diff --git a/system/src/Grav/Common/Page/Medium/AudioMedium.php b/system/src/Grav/Common/Page/Medium/AudioMedium.php index 74ef746ab..e62be4cbf 100644 --- a/system/src/Grav/Common/Page/Medium/AudioMedium.php +++ b/system/src/Grav/Common/Page/Medium/AudioMedium.php @@ -39,7 +39,7 @@ class AudioMedium extends Medium */ public function controls($display = true) { - if($display) { + if ($display) { $this->attributes['controls'] = true; } else { unset($this->attributes['controls']); @@ -88,7 +88,7 @@ class AudioMedium extends Medium */ public function muted($status = false) { - if($status) { + if ($status) { $this->attributes['muted'] = true; } else { unset($this->attributes['muted']); @@ -105,7 +105,7 @@ class AudioMedium extends Medium */ public function loop($status = false) { - if($status) { + if ($status) { $this->attributes['loop'] = true; } else { unset($this->attributes['loop']); @@ -122,7 +122,7 @@ class AudioMedium extends Medium */ public function autoplay($status = false) { - if($status) { + if ($status) { $this->attributes['autoplay'] = true; } else { unset($this->attributes['autoplay']); diff --git a/system/src/Grav/Common/Page/Medium/ImageFile.php b/system/src/Grav/Common/Page/Medium/ImageFile.php index 82c61d216..854e4b0ce 100644 --- a/system/src/Grav/Common/Page/Medium/ImageFile.php +++ b/system/src/Grav/Common/Page/Medium/ImageFile.php @@ -141,5 +141,4 @@ class ImageFile extends Image $this->hash = sha1(serialize($datas)); } - } diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index 1925bef81..78a517611 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -646,10 +646,8 @@ class ImageMedium extends Medium { if ($this->alternatives) { $max = reset($this->alternatives); - foreach($this->alternatives as $alternative) - { - if($alternative->quality() > $max->quality()) - { + foreach ($this->alternatives as $alternative) { + if ($alternative->quality() > $max->quality()) { $max = $alternative; } } @@ -659,5 +657,4 @@ class ImageMedium extends Medium return $this; } - } diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index bf0bb1fab..75c300008 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -358,10 +358,11 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface $style = ''; foreach ($this->styleAttributes as $key => $value) { - if (is_numeric($key)) // Special case for inline style attributes, refer to style() method + if (is_numeric($key)) { // Special case for inline style attributes, refer to style() method $style .= $value; - else + } else { $style .= $key . ': ' . $value . ';'; + } } if ($style) { $attributes['style'] = $style; @@ -675,5 +676,4 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface return $this->_thumbnail; } - } diff --git a/system/src/Grav/Common/Page/Medium/VideoMedium.php b/system/src/Grav/Common/Page/Medium/VideoMedium.php index c0b488aa0..dff4bd34e 100644 --- a/system/src/Grav/Common/Page/Medium/VideoMedium.php +++ b/system/src/Grav/Common/Page/Medium/VideoMedium.php @@ -39,7 +39,7 @@ class VideoMedium extends Medium */ public function controls($display = true) { - if($display) { + if ($display) { $this->attributes['controls'] = true; } else { unset($this->attributes['controls']); @@ -69,7 +69,7 @@ class VideoMedium extends Medium */ public function loop($status = false) { - if($status) { + if ($status) { $this->attributes['loop'] = true; } else { unset($this->attributes['loop']); @@ -120,7 +120,7 @@ class VideoMedium extends Medium */ public function playsinline($status = false) { - if($status) { + if ($status) { $this->attributes['playsinline'] = true; } else { unset($this->attributes['playsinline']); @@ -137,7 +137,7 @@ class VideoMedium extends Medium */ public function muted($status = false) { - if($status) { + if ($status) { $this->attributes['muted'] = true; } else { unset($this->attributes['muted']); diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 5e6e254df..7c89e7179 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -342,8 +342,10 @@ class Page implements PageInterface $frontmatterFile = CompiledYamlFile::instance($this->path . '/' . $this->folder . '/frontmatter.yaml'); if ($frontmatterFile->exists()) { $frontmatter_data = (array)$frontmatterFile->content(); - $this->header = (object)array_replace_recursive($frontmatter_data, - (array)$this->header); + $this->header = (object)array_replace_recursive( + $frontmatter_data, + (array)$this->header + ); $frontmatterFile->free(); } // Process frontmatter with Twig if enabled @@ -365,8 +367,6 @@ class Page implements PageInterface } $var = true; } - - } if ($var) { @@ -677,14 +677,20 @@ class Page implements PageInterface $process_markdown = $this->shouldProcess('markdown'); $process_twig = $this->shouldProcess('twig') || $this->modularTwig(); - $cache_enable = $this->header->cache_enable ?? $config->get('system.cache.enabled', - true); - $twig_first = $this->header->twig_first ?? $config->get('system.pages.twig_first', - true); + $cache_enable = $this->header->cache_enable ?? $config->get( + 'system.cache.enabled', + true + ); + $twig_first = $this->header->twig_first ?? $config->get( + 'system.pages.twig_first', + true + ); // never cache twig means it's always run after content - $never_cache_twig = $this->header->never_cache_twig ?? $config->get('system.pages.never_cache_twig', - false); + $never_cache_twig = $this->header->never_cache_twig ?? $config->get( + 'system.pages.never_cache_twig', + false + ); // if no cached-content run everything if ($never_cache_twig) { @@ -707,7 +713,6 @@ class Page implements PageInterface if ($process_twig) { $this->processTwig(); } - } else { if ($this->content === false || $cache_enable === false) { $this->content = $this->raw_content; @@ -723,7 +728,6 @@ class Page implements PageInterface // Content Processed but not cached yet Grav::instance()->fireEvent('onPageContentProcessed', new Event(['page' => $this])); - } else { if ($process_markdown) { $this->processMarkdown(); @@ -2190,11 +2194,11 @@ class Page implements PageInterface { if ($var !== null) { // make sure first level are arrays - array_walk($var, function(&$value) { + array_walk($var, function (&$value) { $value = (array) $value; }); // make sure all values are strings - array_walk_recursive($var, function(&$value) { + array_walk_recursive($var, function (&$value) { $value = (string) $value; }); $this->taxonomy = $var; @@ -2740,7 +2744,6 @@ class Page implements PageInterface rename($path . '/' . $this->_original->name(), $path . '/' . $this->name()); } } - } protected function setPublishState() @@ -2778,7 +2781,7 @@ class Page implements PageInterface */ public function getOriginal() { - return $this->_original; + return $this->_original; } /** @@ -2788,6 +2791,6 @@ class Page implements PageInterface */ public function getAction() { - return $this->_action; + return $this->_action; } } diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 9010afab2..9061a9e37 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -85,10 +85,10 @@ class Pages protected $initialized = false; /** @var Types */ - static protected $types; + protected static $types; /** @var string|null */ - static protected $home_route; + protected static $home_route; /** * Constructor @@ -543,7 +543,6 @@ class Pages } else { $result = $result + $this->evaluate([$key => $val], $self)->toArray(); } - } return new Collection($result); @@ -689,7 +688,6 @@ class Pages } return $sort; - } /** @@ -767,7 +765,6 @@ class Pages public function inherited($route, $field = null) { if ($field !== null) { - $page = $this->find($route, true); $parent = $page ? $page->parent() : null; @@ -821,7 +818,6 @@ class Pages // If the page cannot be reached, look into site wide redirects, routes + wildcards if (!$all && $not_admin) { - // If the page is a simple redirect, just do it. if ($redirect && $page && $page->redirect()) { $this->grav->redirectLangSafe($page->redirect()); @@ -990,7 +986,6 @@ class Pages if (isset($parents[$page_route])) { unset($parents[$page_route]); } - } return $parents; @@ -1089,7 +1084,6 @@ class Pages $scanBlueprintsAndTemplates(); $cache->save($types_cache_id, self::$types); } - } else { self::$types = new Types(); $scanBlueprintsAndTemplates(); @@ -1237,7 +1231,6 @@ class Pages } catch (ErrorException $e) { $home = $home_aliases[$default]; } - } } @@ -1275,8 +1268,7 @@ class Pages $dispatcher = $this->grav['events']; $dispatcher->addListener( 'onFlexInit', - static function (Event $event) use ($directory) - { + static function (Event $event) use ($directory) { /** @var Flex $flex */ $flex = $event['flex']; $flex->addDirectory($directory); @@ -1303,7 +1295,8 @@ class Pages $menu = $directory->getConfig('admin.menu.list'); $header->access = $menu['authorize'] ?? ['admin.pages', 'admin.super']; }, - 100000); + 100000 + ); $this->directory = $directory; } @@ -1827,7 +1820,7 @@ class Pages } $header_value = $child_header->get($header_query[0]); if (is_array($header_value)) { - $list[$key] = implode(',',$header_value); + $list[$key] = implode(',', $header_value); } elseif ($header_value) { $list[$key] = $header_value; } else { @@ -1857,7 +1850,7 @@ class Pages $col = Collator::create($locale); if ($col) { if (($sort_flags & SORT_NATURAL) === SORT_NATURAL) { - $list = preg_replace_callback('~([0-9]+)\.~', function($number) { + $list = preg_replace_callback('~([0-9]+)\.~', function ($number) { return sprintf('%032d.', $number[0]); }, $list); diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php index 8729a519f..cc29dff3d 100644 --- a/system/src/Grav/Common/Plugin.php +++ b/system/src/Grav/Common/Plugin.php @@ -168,8 +168,7 @@ class Plugin implements EventSubscriberInterface, \ArrayAccess { $grav = Grav::instance(); $override = implode('.', ["priorities", $this->name, $eventName, $params[0]]); - if ($grav['config']->get($override) !== null) - { + if ($grav['config']->get($override) !== null) { return $grav['config']->get($override); } elseif (isset($params[1])) { return $params[1]; @@ -305,7 +304,7 @@ class Plugin implements EventSubscriberInterface, \ArrayAccess // Create new config object and set it on the page object so it's cached for next time $page->modifyHeader($class_name_merged, new Data($header)); - } else if (isset($page_header->{$class_name_merged})) { + } elseif (isset($page_header->{$class_name_merged})) { $merged = $page_header->{$class_name_merged}; $header = $merged->toArray(); } diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php index 358727f33..0142d6131 100644 --- a/system/src/Grav/Common/Plugins.php +++ b/system/src/Grav/Common/Plugins.php @@ -30,7 +30,7 @@ class Plugins extends Iterator $iterator = $locator->getIterator('plugins://'); $plugins = []; - foreach($iterator as $directory) { + foreach ($iterator as $directory) { if (!$directory->isDir()) { continue; } @@ -224,5 +224,4 @@ class Plugins extends Iterator return $class; } - } diff --git a/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php b/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php index 49ed05546..3f6ad33fd 100644 --- a/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php +++ b/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php @@ -26,6 +26,5 @@ class DebuggerAssetsProcessor extends ProcessorBase $this->stopTimer(); return $handler->handle($request); - } } diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index 8d9352f1d..008ff1316 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -146,7 +146,6 @@ class InitializeProcessor extends ProcessorBase if ($path !== '/' && $config->get('system.pages.redirect_trailing_slash', false) && Utils::endsWith($path, '/')) { - $redirect = (string) $uri::getCurrentRoute()->toString(); $this->container->redirect($redirect); } diff --git a/system/src/Grav/Common/Processors/PagesProcessor.php b/system/src/Grav/Common/Processors/PagesProcessor.php index eaed61993..aec1602f6 100644 --- a/system/src/Grav/Common/Processors/PagesProcessor.php +++ b/system/src/Grav/Common/Processors/PagesProcessor.php @@ -41,7 +41,7 @@ class PagesProcessor extends ProcessorBase $event = $this->container->fireEvent('onPageNotFound', $event); if (isset($event->page)) { - unset ($this->container['page']); + unset($this->container['page']); $this->container['page'] = $page = $event->page; } else { throw new \RuntimeException('Page Not Found', 404); diff --git a/system/src/Grav/Common/Processors/TasksProcessor.php b/system/src/Grav/Common/Processors/TasksProcessor.php index a7d2b0431..9c3e3c54a 100644 --- a/system/src/Grav/Common/Processors/TasksProcessor.php +++ b/system/src/Grav/Common/Processors/TasksProcessor.php @@ -42,7 +42,6 @@ class TasksProcessor extends ProcessorBase $this->stopTimer(); return $response; - } catch (NotFoundException $e) { // Task not found: Let it pass through. } diff --git a/system/src/Grav/Common/Scheduler/Cron.php b/system/src/Grav/Common/Scheduler/Cron.php index 3a42b29ea..93dad28c0 100644 --- a/system/src/Grav/Common/Scheduler/Cron.php +++ b/system/src/Grav/Common/Scheduler/Cron.php @@ -439,8 +439,7 @@ class Cron { if (is_numeric($date) && (int)$date == $date) { $date = new \DateTime('@' . $date); - } - elseif (is_string($date)) { + } elseif (is_string($date)) { $date = new \DateTime('@' . strtotime($date)); } if ($date instanceof \DateTime) { @@ -449,8 +448,7 @@ class Cron $day = (int)$date->format('d'); $month = (int)$date->format('m'); $weekday = (int)$date->format('w'); // 0-6 - } - else { + } else { throw new \RuntimeException('Date format not supported'); } @@ -523,8 +521,7 @@ class Cron if ($array[$i] == $c + 1) { $c = $array[$i]; $cron[\count($cron) - 1] = $s . '-' . $c; - } - else { + } else { $s = $c = $array[$i]; $cron[] = $c; } diff --git a/system/src/Grav/Common/Scheduler/IntervalTrait.php b/system/src/Grav/Common/Scheduler/IntervalTrait.php index b382c9d72..821833780 100644 --- a/system/src/Grav/Common/Scheduler/IntervalTrait.php +++ b/system/src/Grav/Common/Scheduler/IntervalTrait.php @@ -396,4 +396,3 @@ trait IntervalTrait return $value; } } - diff --git a/system/src/Grav/Common/Scheduler/Job.php b/system/src/Grav/Common/Scheduler/Job.php index 6250f1d62..26b9c5e99 100644 --- a/system/src/Grav/Common/Scheduler/Job.php +++ b/system/src/Grav/Common/Scheduler/Job.php @@ -519,4 +519,3 @@ class Job return $this; } } - diff --git a/system/src/Grav/Common/Scheduler/Scheduler.php b/system/src/Grav/Common/Scheduler/Scheduler.php index 753c2f95d..7192fefd1 100644 --- a/system/src/Grav/Common/Scheduler/Scheduler.php +++ b/system/src/Grav/Common/Scheduler/Scheduler.php @@ -52,7 +52,6 @@ class Scheduler if (!file_exists($this->status_path)) { Folder::create($this->status_path); } - } /** @@ -108,7 +107,6 @@ class Scheduler $foreground[] = $job; } } - } return [$background, $foreground]; } @@ -182,7 +180,7 @@ class Scheduler } // Finish handling any background jobs - foreach($background as $job) { + foreach ($background as $job) { $job->finalize(); } diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php index 581d5e774..494be2e13 100644 --- a/system/src/Grav/Common/Security.php +++ b/system/src/Grav/Common/Security.php @@ -54,7 +54,6 @@ class Security ]); foreach ($routes as $path) { - $status && $status([ 'type' => 'progress', ]); @@ -76,7 +75,6 @@ class Security $list[$page->filePathClean()] = $results; } } - } catch (\Exception $e) { continue; } @@ -137,18 +135,18 @@ class Security $string = urldecode($string); // Convert Hexadecimals - $string = (string)preg_replace_callback('!(&#|\\\)[xX]([0-9a-fA-F]+);?!u', function($m) { + $string = (string)preg_replace_callback('!(&#|\\\)[xX]([0-9a-fA-F]+);?!u', function ($m) { return \chr(hexdec($m[2])); }, $string); // Clean up entities - $string = preg_replace('!(�+[0-9]+)!u','$1;', $string); + $string = preg_replace('!(�+[0-9]+)!u', '$1;', $string); // Decode entities $string = html_entity_decode($string, ENT_NOQUOTES, 'UTF-8'); // Strip whitespace characters - $string = preg_replace('!\s!u','', $string); + $string = preg_replace('!\s!u', '', $string); $config = Grav::instance()['config']; @@ -178,11 +176,9 @@ class Security // Iterate over rules and return label if fail foreach ((array) $patterns as $name => $regex) { if ($enabled_rules[$name] === true) { - if (preg_match($regex, $string) || preg_match($regex, $orig)) { return $name; } - } } diff --git a/system/src/Grav/Common/Service/ConfigServiceProvider.php b/system/src/Grav/Common/Service/ConfigServiceProvider.php index c874441f1..17fc9e3cf 100644 --- a/system/src/Grav/Common/Service/ConfigServiceProvider.php +++ b/system/src/Grav/Common/Service/ConfigServiceProvider.php @@ -98,7 +98,7 @@ class ConfigServiceProvider implements ServiceProviderInterface $files += (new ConfigFileFinder)->setBase('plugins')->locateInFolders($paths); $compiled = new CompiledConfig($cache, $files, GRAV_ROOT); - $compiled->setBlueprints(function() use ($container) { + $compiled->setBlueprints(function () use ($container) { return $container['blueprints']; }); @@ -168,5 +168,4 @@ class ConfigServiceProvider implements ServiceProviderInterface } return $paths; } - } diff --git a/system/src/Grav/Common/Service/PagesServiceProvider.php b/system/src/Grav/Common/Service/PagesServiceProvider.php index d41c97617..01c546f7d 100644 --- a/system/src/Grav/Common/Service/PagesServiceProvider.php +++ b/system/src/Grav/Common/Service/PagesServiceProvider.php @@ -84,7 +84,6 @@ class PagesServiceProvider implements ServiceProviderInterface // if page is not found, try some fallback stuff if (!$page || !$page->routable()) { - // Try fallback URL stuff... $page = $grav->fallbackUrl($path); diff --git a/system/src/Grav/Common/Service/RequestServiceProvider.php b/system/src/Grav/Common/Service/RequestServiceProvider.php index 6410ef725..88c457341 100644 --- a/system/src/Grav/Common/Service/RequestServiceProvider.php +++ b/system/src/Grav/Common/Service/RequestServiceProvider.php @@ -31,7 +31,7 @@ class RequestServiceProvider implements ServiceProviderInterface return $creator->fromGlobals(); }; - $container['route'] = $container->factory(function() { + $container['route'] = $container->factory(function () { return clone Uri::getCurrentRoute(); }); } diff --git a/system/src/Grav/Common/Service/StreamsServiceProvider.php b/system/src/Grav/Common/Service/StreamsServiceProvider.php index 3bbbea1d3..0ad2072c1 100644 --- a/system/src/Grav/Common/Service/StreamsServiceProvider.php +++ b/system/src/Grav/Common/Service/StreamsServiceProvider.php @@ -21,7 +21,7 @@ class StreamsServiceProvider implements ServiceProviderInterface { public function register(Container $container) { - $container['locator'] = function(Container $container) { + $container['locator'] = function (Container $container) { $locator = new UniformResourceLocator(GRAV_ROOT); /** @var Setup $setup */ @@ -31,7 +31,7 @@ class StreamsServiceProvider implements ServiceProviderInterface return $locator; }; - $container['streams'] = function(Container $container) { + $container['streams'] = function (Container $container) { /** @var Setup $setup */ $setup = $container['setup']; diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeCache.php b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php index ce343e09d..711150269 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeCache.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php @@ -13,7 +13,6 @@ use Twig\Compiler; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Node; - class TwigNodeCache extends Node { /** diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeRender.php b/system/src/Grav/Common/Twig/Node/TwigNodeRender.php index dbf061392..d380cef2e 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeRender.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeRender.php @@ -31,8 +31,7 @@ class TwigNodeRender extends Node implements NodeCaptureInterface ?AbstractExpression $context, $lineno, $tag = null - ) - { + ) { $nodes = ['object' => $object, 'layout' => $layout, 'context' => $context]; $nodes = array_filter($nodes); diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeScript.php b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php index 2537f8c43..6285020a9 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeScript.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php @@ -36,8 +36,7 @@ class TwigNodeScript extends Node implements NodeCaptureInterface ?AbstractExpression $attributes, $lineno = 0, $tag = null - ) - { + ) { $nodes = ['body' => $body, 'file' => $file, 'group' => $group, 'priority' => $priority, 'attributes' => $attributes]; $nodes = array_filter($nodes); @@ -69,17 +68,17 @@ class TwigNodeScript extends Node implements NodeCaptureInterface $compiler->write('$attributes = [];' . "\n"); } - if ($this->hasNode('group')) { - $compiler - ->write("\$attributes['group'] = ") - ->subcompile($this->getNode('group')) - ->raw(";\n") - ->write("if (!is_string(\$attributes['group'])) {\n") - ->indent() - ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');\n") - ->outdent() - ->write("}\n"); - } + if ($this->hasNode('group')) { + $compiler + ->write("\$attributes['group'] = ") + ->subcompile($this->getNode('group')) + ->raw(";\n") + ->write("if (!is_string(\$attributes['group'])) {\n") + ->indent() + ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');\n") + ->outdent() + ->write("}\n"); + } if ($this->hasNode('priority')) { $compiler diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php index ba9b3f54e..39a351c0f 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php @@ -36,8 +36,7 @@ class TwigNodeStyle extends Node implements NodeCaptureInterface ?AbstractExpression $attributes, $lineno = 0, $tag = null - ) - { + ) { $nodes = ['body' => $body, 'file' => $file, 'group' => $group, 'priority' => $priority, 'attributes' => $attributes]; $nodes = array_filter($nodes); diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php index ecee44314..b1dad0c34 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php @@ -28,8 +28,7 @@ class TwigNodeSwitch extends Node Node $default = null, $lineno = 0, $tag = null - ) - { + ) { $nodes = ['value' => $value, 'cases' => $cases, 'default' => $default]; $nodes = array_filter($nodes); diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php b/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php index c736d8570..3c4ef3fd6 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php @@ -26,8 +26,7 @@ class TwigNodeThrow extends Node Node $message, $lineno = 0, $tag = null - ) - { + ) { parent::__construct(['message' => $message], ['code' => $code], $lineno, $tag); } diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php index d935398ca..74fae400d 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php @@ -26,8 +26,7 @@ class TwigNodeTryCatch extends Node Node $catch = null, $lineno = 0, $tag = null - ) - { + ) { $nodes = ['try' => $try, 'catch' => $catch]; $nodes = array_filter($nodes); diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php index f6646d003..dc621c87b 100644 --- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php +++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php @@ -65,6 +65,4 @@ class TwigTokenParserCache extends AbstractTokenParser { return 'cache'; } - - } diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 26e7249ae..93b152a8e 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -308,7 +308,6 @@ class Twig $this->setTemplate($name, $content); $output = $local_twig->render($name, $twig_vars); } - } catch (LoaderError $e) { throw new \RuntimeException($e->getRawMessage(), 404, $e); } @@ -338,7 +337,6 @@ class Twig } return $output; - } diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index 4a093cf46..ad7d2da9d 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -546,11 +546,9 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface if ($now > $unix_date) { $difference = $now - $unix_date; $tense = $this->grav['language']->translate('GRAV.NICETIME.AGO', null, true); - } elseif ($now == $unix_date) { $difference = $now - $unix_date; $tense = $this->grav['language']->translate('GRAV.NICETIME.JUST_NOW', null, false); - } else { $difference = $unix_date - $now; $tense = $this->grav['language']->translate('GRAV.NICETIME.FROM_NOW', null, true); @@ -566,8 +564,10 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface $periods[$j] .= '_PLURAL'; } - if ($this->grav['language']->getTranslation($this->grav['language']->getLanguage(), - $periods[$j] . '_MORE_THAN_TWO') + if ($this->grav['language']->getTranslation( + $this->grav['language']->getLanguage(), + $periods[$j] . '_MORE_THAN_TWO' + ) ) { if ($difference > 2) { $periods[$j] .= '_MORE_THAN_TWO'; @@ -599,7 +599,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface } $results = Security::detectXssFromArray($data); - $results_parts = array_map(function($value, $key) { + $results_parts = array_map(function ($value, $key) { return $key.': \''.$value . '\''; }, array_values($results), array_keys($results)); @@ -617,7 +617,6 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface $string = preg_replace('/((?:href|src) *= *[\'"](?!(http|ftp)))/i', "$1$url", $string); return $string; - } /** @@ -664,7 +663,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface public function definedDefaultFilter($value, $default = null) { return $value ?? $default; - } + } /** * @param string $value @@ -839,7 +838,8 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface * @param string $twig * @return mixed */ - public function evaluateTwigFunc($context, $twig ) { + public function evaluateTwigFunc($context, $twig) + { $loader = new FilesystemLoader('.'); $env = new Environment($loader); @@ -856,7 +856,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface * @param string $string * @return mixed */ - public function evaluateStringFunc($context, $string ) + public function evaluateStringFunc($context, $string) { return $this->evaluateTwigFunc($context, "{{ $string }}"); } @@ -1169,7 +1169,6 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface $exif_reader = $this->grav['exif']->getReader(); if ($image && file_exists($image) && $this->config->get('system.media.auto_metadata_exif') && $exif_reader) { - $exif_data = $exif_reader->read($image); if ($exif_data) { @@ -1408,11 +1407,10 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface * @param string|null $className * @return bool */ - public function ofTypeFunc($var, $typeTest=null, $className=null) + public function ofTypeFunc($var, $typeTest = null, $className = null) { - switch ($typeTest) - { + switch ($typeTest) { default: return false; break; diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index b7ad4181c..2a46847f1 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -639,7 +639,7 @@ class Uri $ip = getenv('HTTP_FORWARDED_FOR'); } elseif (getenv('HTTP_FORWARDED')) { $ip = getenv('HTTP_FORWARDED'); - } elseif (getenv('REMOTE_ADDR')){ + } elseif (getenv('REMOTE_ADDR')) { $ip = getenv('REMOTE_ADDR'); } else { $ip = 'UNKNOWN'; @@ -774,7 +774,6 @@ class Uri } elseif ($url_path === '/' || ($base_url !== '' && Utils::startsWith($url_path, $base_url))) { $url_path = $base_url . $url_path; } else { - // see if page is relative to this or absolute if (Utils::startsWith($url_path, '/')) { $normalized_url = Utils::normalizePath($base_url . $url_path); @@ -837,7 +836,6 @@ class Uri // handle absolute URLs if (\is_array($url) && !$external && ($absolute === true || $grav['config']->get('system.absolute_urls', false))) { - $url['scheme'] = $uri->scheme(true); $url['host'] = $uri->host(); $url['port'] = $uri->port(true); @@ -899,7 +897,9 @@ class Uri $encodedUrl = preg_replace_callback( '%[^:/@?&=#]+%usD', - function ($matches) { return rawurlencode($matches[0]); }, + function ($matches) { + return rawurlencode($matches[0]); + }, $url ); @@ -909,7 +909,7 @@ class Uri return false; } - foreach($parts as $name => $value) { + foreach ($parts as $name => $value) { $parts[$name] = rawurldecode($value); } @@ -1101,7 +1101,7 @@ class Uri { $regex = '/(\/)\/+/'; $path = str_replace(['\\', '/ /'], '/', $path); - $path = preg_replace($regex,'$1',$path); + $path = preg_replace($regex, '$1', $path); return $path; } @@ -1158,7 +1158,7 @@ class Uri } elseif (isset($env['HTTP_CLOUDFRONT_FORWARDED_PROTO'])) { $this->scheme = $env['HTTP_CLOUDFRONT_FORWARDED_PROTO']; } elseif (isset($env['REQUEST_SCHEME']) && empty($env['HTTPS'])) { - $this->scheme = $env['REQUEST_SCHEME']; + $this->scheme = $env['REQUEST_SCHEME']; } else { $https = $env['HTTPS'] ?? ''; $this->scheme = (empty($https) || strtolower($https) === 'off') ? 'http' : 'https'; @@ -1182,17 +1182,17 @@ class Uri // Build port. if (isset($env['HTTP_X_FORWARDED_PORT'])) { - $this->port = (int)$env['HTTP_X_FORWARDED_PORT']; + $this->port = (int)$env['HTTP_X_FORWARDED_PORT']; } elseif (isset($env['X-FORWARDED-PORT'])) { - $this->port = (int)$env['X-FORWARDED-PORT']; + $this->port = (int)$env['X-FORWARDED-PORT']; } elseif (isset($env['HTTP_CLOUDFRONT_FORWARDED_PROTO'])) { // Since AWS Cloudfront does not provide a forwarded port header, // we have to build the port using the scheme. - $this->port = $this->port(); + $this->port = $this->port(); } elseif (isset($env['SERVER_PORT'])) { - $this->port = (int)$env['SERVER_PORT']; + $this->port = (int)$env['SERVER_PORT']; } else { - $this->port = null; + $this->port = null; } if ($this->hasStandardPort()) { @@ -1333,7 +1333,7 @@ class Uri if (isset($_SERVER['CONTENT_TYPE'])) { $content_type = $_SERVER['CONTENT_TYPE']; if ($short) { - return Utils::substrToString($content_type,';'); + return Utils::substrToString($content_type, ';'); } return $content_type; } @@ -1366,7 +1366,9 @@ class Uri public function setUriProperties($data) { foreach (get_object_vars($this) as $property => $default) { - if (!array_key_exists($property, $data)) continue; + if (!array_key_exists($property, $data)) { + continue; + } $this->{$property} = $data[$property]; // assign value to object } return $this; diff --git a/system/src/Grav/Common/User/DataUser/UserCollection.php b/system/src/Grav/Common/User/DataUser/UserCollection.php index 800322a9f..e8dfd7e36 100644 --- a/system/src/Grav/Common/User/DataUser/UserCollection.php +++ b/system/src/Grav/Common/User/DataUser/UserCollection.php @@ -54,7 +54,7 @@ class UserCollection implements UserCollectionInterface $content = (array)$file->content() + ['username' => $username, 'state' => 'enabled']; $userClass = $this->className; - $callable = function() { + $callable = function () { $blueprints = new Blueprints; return $blueprints->get('user/account'); diff --git a/system/src/Grav/Common/User/Group.php b/system/src/Grav/Common/User/Group.php index 9815c0e5e..c9e745eb6 100644 --- a/system/src/Grav/Common/User/Group.php +++ b/system/src/Grav/Common/User/Group.php @@ -37,7 +37,7 @@ class Group extends Data { $groups = []; - foreach(static::groups() as $groupname => $group) { + foreach (static::groups() as $groupname => $group) { $groups[$groupname] = $group['readableName'] ?? $groupname; } diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 367b2a426..b2e16ebe1 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -88,7 +88,6 @@ abstract class Utils // Return location where the file would be if it was saved. $resource = $locator->findResource("{$scheme}://{$host}{$path}", false, true); } - } elseif ($host || $port) { // If URL doesn't have scheme but has host or port, it is external. return str_replace(' ', '%20', $input); @@ -105,12 +104,10 @@ abstract class Utils $resource .= '#' . $parts['fragment']; } } - } else { // Not a valid URL (can still be a stream). $resource = $locator->findResource($input, false); } - } else { $root = $uri->rootUrl(); @@ -222,7 +219,8 @@ abstract class Utils * @param string $haystack * @return false|int */ - public static function matchWildcard($wildcard_pattern, $haystack) { + public static function matchWildcard($wildcard_pattern, $haystack) + { $regex = str_replace( array("\*", "\?"), // wildcard chars array('.*','.'), // regexp chars @@ -245,7 +243,7 @@ abstract class Utils $opening = $brackets[0] ?? '{'; $closing = $brackets[1] ?? '}'; $expression = '/' . preg_quote($opening, '/') . '(.*?)' . preg_quote($closing, '/') . '/'; - $callback = static function($match) use ($variables) { + $callback = static function ($match) use ($variables) { return $variables[$match[1]] ?? $match[0]; }; @@ -308,8 +306,7 @@ abstract class Utils { $pos = strrpos($subject, $search); - if($pos !== false) - { + if ($pos !== false) { $subject = static::mb_substr_replace($subject, $replace, $pos, mb_strlen($search)); } @@ -653,8 +650,7 @@ abstract class Utils // Return 304 Not Modified if the file is already cached in the browser if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && - strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= filemtime($file)) - { + strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= filemtime($file)) { header('HTTP/1.1 304 Not Modified'); exit(); } @@ -670,7 +666,7 @@ abstract class Utils if ($range) { fseek($fp, $range); } - while (!feof($fp) && (!connection_aborted()) && ($bytes_send < $new_length) ) { + while (!feof($fp) && (!connection_aborted()) && ($bytes_send < $new_length)) { $buffer = fread($fp, $chunksize); echo($buffer); //echo($buffer); // is also possible flush(); @@ -893,7 +889,7 @@ abstract class Utils public static function checkFilename($filename) { $dangerous_extensions = Grav::instance()['config']->get('security.uploads_dangerous_extensions', []); - array_walk($dangerous_extensions, function(&$val) { + array_walk($dangerous_extensions, function (&$val) { $val = '.' . $val; }); @@ -936,7 +932,7 @@ abstract class Utils } // Strip off leading / to ensure explode is accurate - if (Utils::startsWith($path,'/')) { + if (Utils::startsWith($path, '/')) { $root .= '/'; $path = ltrim($path, '/'); } @@ -1330,8 +1326,7 @@ abstract class Utils while (count($keys) > 1) { $key = array_shift($keys); - if ( ! isset($array[$key]) || ! is_array($array[$key])) - { + if (! isset($array[$key]) || ! is_array($array[$key])) { $array[$key] = array(); } @@ -1364,7 +1359,8 @@ abstract class Utils * * @return bool */ - public static function isApache() { + public static function isApache() + { return isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false; } @@ -1566,11 +1562,11 @@ abstract class Utils $parts = parse_url($enc_url); - if($parts === false) { + if ($parts === false) { throw new \InvalidArgumentException('Malformed URL: ' . $url); } - foreach($parts as $name => $value) { + foreach ($parts as $name => $value) { $parts[$name] = urldecode($value); } @@ -1634,15 +1630,22 @@ abstract class Utils // Maximum netmask length = same as packed address $len = 8*strlen($ip); - if ($prefix > $len) $prefix = $len; + if ($prefix > $len) { + $prefix = $len; + } $mask = str_repeat('f', $prefix>>2); - switch($prefix & 3) - { - case 3: $mask .= 'e'; break; - case 2: $mask .= 'c'; break; - case 1: $mask .= '8'; break; + switch ($prefix & 3) { + case 3: + $mask .= 'e'; + break; + case 2: + $mask .= 'c'; + break; + case 1: + $mask .= '8'; + break; } $mask = str_pad($mask, $len>>2, '0'); diff --git a/system/src/Grav/Console/Cli/BackupCommand.php b/system/src/Grav/Console/Cli/BackupCommand.php index 54a26cff1..ccb77874a 100644 --- a/system/src/Grav/Console/Cli/BackupCommand.php +++ b/system/src/Grav/Console/Cli/BackupCommand.php @@ -33,7 +33,6 @@ class BackupCommand extends ConsoleCommand 'id', InputArgument::OPTIONAL, 'The ID of the backup profile to perform without prompting' - ) ->setDescription('Creates a backup of the Grav instance') ->setHelp('The backup creates a zipped backup.'); @@ -115,6 +114,4 @@ class BackupCommand extends ConsoleCommand break; } } - } - diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php index a90597373..49fdc5ad3 100644 --- a/system/src/Grav/Console/Cli/CleanCommand.php +++ b/system/src/Grav/Console/Cli/CleanCommand.php @@ -319,5 +319,4 @@ class CleanCommand extends Command $this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta', null, ['bold'])); $this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, ['bold'])); } - } diff --git a/system/src/Grav/Console/Cli/ClearCacheCommand.php b/system/src/Grav/Console/Cli/ClearCacheCommand.php index 8ef6f4ff6..5003cb47d 100644 --- a/system/src/Grav/Console/Cli/ClearCacheCommand.php +++ b/system/src/Grav/Console/Cli/ClearCacheCommand.php @@ -77,4 +77,3 @@ class ClearCacheCommand extends ConsoleCommand } } } - diff --git a/system/src/Grav/Console/Cli/ComposerCommand.php b/system/src/Grav/Console/Cli/ComposerCommand.php index ffb4e998c..b1c0a2163 100644 --- a/system/src/Grav/Console/Cli/ComposerCommand.php +++ b/system/src/Grav/Console/Cli/ComposerCommand.php @@ -46,5 +46,4 @@ class ComposerCommand extends ConsoleCommand $this->output->writeln("\nInstalling vendor dependencies"); $this->output->writeln($this->composerUpdate(GRAV_ROOT, $action)); } - } diff --git a/system/src/Grav/Console/Cli/InstallCommand.php b/system/src/Grav/Console/Cli/InstallCommand.php index 05f281e78..ec7d981a5 100644 --- a/system/src/Grav/Console/Cli/InstallCommand.php +++ b/system/src/Grav/Console/Cli/InstallCommand.php @@ -92,8 +92,6 @@ class InstallCommand extends ConsoleCommand } else { $this->output->writeln('ERROR invalid YAML in ' . $dependencies_file); } - - } /** @@ -116,7 +114,6 @@ class InstallCommand extends ConsoleCommand $this->output->writeln('SUCCESS cloned ' . $data['url'] . ' -> ' . $path . ''); } else { $this->output->writeln('ERROR cloning ' . $data['url']); - } $this->output->writeln(''); @@ -124,7 +121,6 @@ class InstallCommand extends ConsoleCommand $this->output->writeln('' . $path . ' already exists, skipping...'); $this->output->writeln(''); } - } } diff --git a/system/src/Grav/Console/Cli/LogViewerCommand.php b/system/src/Grav/Console/Cli/LogViewerCommand.php index f9e93a3ec..c0f6ede12 100644 --- a/system/src/Grav/Console/Cli/LogViewerCommand.php +++ b/system/src/Grav/Console/Cli/LogViewerCommand.php @@ -80,6 +80,5 @@ class LogViewerCommand extends ConsoleCommand } else { $io->error('cannot find the log file: logs/' . $file); } - } } diff --git a/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php b/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php index b946ddf9d..5bd0ef1b2 100644 --- a/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php +++ b/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php @@ -274,4 +274,3 @@ class PageSystemValidatorCommand extends ConsoleCommand return CompiledYamlFile::instance('cache://tests/' . $name . '.yaml'); } } - diff --git a/system/src/Grav/Console/Cli/SandboxCommand.php b/system/src/Grav/Console/Cli/SandboxCommand.php index f96141287..8e7e5c157 100644 --- a/system/src/Grav/Console/Cli/SandboxCommand.php +++ b/system/src/Grav/Console/Cli/SandboxCommand.php @@ -217,7 +217,6 @@ class SandboxCommand extends ConsoleCommand $destination = $this->source . '/user/pages'; Folder::rcopy($destination, $pages_dir); $this->output->writeln(' ' . $destination . ' -> Created'); - } } diff --git a/system/src/Grav/Console/Cli/SchedulerCommand.php b/system/src/Grav/Console/Cli/SchedulerCommand.php index c83c58214..ac237905e 100644 --- a/system/src/Grav/Console/Cli/SchedulerCommand.php +++ b/system/src/Grav/Console/Cli/SchedulerCommand.php @@ -149,7 +149,6 @@ class SchedulerCommand extends ConsoleCommand $table->setRows($rows); $table->render(); - } elseif ($this->input->getOption('install')) { $io->title('Install Scheduler'); diff --git a/system/src/Grav/Console/Cli/SecurityCommand.php b/system/src/Grav/Console/Cli/SecurityCommand.php index 7f7308653..dbbc91660 100644 --- a/system/src/Grav/Console/Cli/SecurityCommand.php +++ b/system/src/Grav/Console/Cli/SecurityCommand.php @@ -59,11 +59,9 @@ class SecurityCommand extends ConsoleCommand $io->newline(2); if (!empty($output)) { - $counter = 1; foreach ($output as $route => $results) { - - $results_parts = array_map(function($value, $key) { + $results_parts = array_map(function ($value, $key) { return $key.': \''.$value . '\''; }, array_values($results), array_keys($results)); @@ -71,13 +69,11 @@ class SecurityCommand extends ConsoleCommand } $io->error('Security Scan complete: ' . \count($output) . ' potential XSS issues found...'); - } else { $io->success('Security Scan complete: No issues found...'); } $io->newline(1); - } /** @@ -101,6 +97,4 @@ class SecurityCommand extends ConsoleCommand break; } } - } - diff --git a/system/src/Grav/Console/Cli/ServerCommand.php b/system/src/Grav/Console/Cli/ServerCommand.php index d5b6add0a..99e1fb826 100644 --- a/system/src/Grav/Console/Cli/ServerCommand.php +++ b/system/src/Grav/Console/Cli/ServerCommand.php @@ -85,7 +85,7 @@ class ServerCommand extends ConsoleCommand unset($commands[self::SYMFONY_SERVER]); } - foreach($commands as $name => $command) { + foreach ($commands as $name => $command) { $process = $this->runProcess($name, $command); if (!$process) { diff --git a/system/src/Grav/Console/Cli/YamlLinterCommand.php b/system/src/Grav/Console/Cli/YamlLinterCommand.php index c48b63321..b26afa393 100644 --- a/system/src/Grav/Console/Cli/YamlLinterCommand.php +++ b/system/src/Grav/Console/Cli/YamlLinterCommand.php @@ -28,8 +28,8 @@ class YamlLinterCommand extends ConsoleCommand 'The environment to trigger a specific configuration. For example: localhost, mysite.dev, www.mysite.com' ) ->addOption( - 'all', - 'a', + 'all', + 'a', InputOption::VALUE_NONE, 'Go through the whole Grav installation' ) diff --git a/system/src/Grav/Console/ConsoleCommand.php b/system/src/Grav/Console/ConsoleCommand.php index 2c63eaf54..6d54ca35f 100644 --- a/system/src/Grav/Console/ConsoleCommand.php +++ b/system/src/Grav/Console/ConsoleCommand.php @@ -43,5 +43,4 @@ class ConsoleCommand extends Command $this->output->writeln('GPM Releases Configuration: ' . ucfirst(Grav::instance()['config']->get('system.gpm.releases')) . ''); $this->output->writeln(''); } - } diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php index bd2765162..82377d1f7 100644 --- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php +++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php @@ -63,8 +63,7 @@ class DirectInstallCommand extends ConsoleCommand // Making sure the destination is usable $this->destination = realpath($this->input->getOption('destination')); - if ( - !Installer::isGravInstance($this->destination) || + if (!Installer::isGravInstance($this->destination) || !Installer::isValidDestination($this->destination, [Installer::EXISTS, Installer::IS_LINK]) ) { $this->output->writeln('ERROR: ' . Installer::lastErrorMsg()); @@ -153,13 +152,13 @@ class DirectInstallCommand extends ConsoleCommand if (isset($blueprint['dependencies'])) { $dependencies = []; foreach ($blueprint['dependencies'] as $dependency) { - if (is_array($dependency)){ - if (isset($dependency['name'])) { - $dependencies[] = $dependency['name']; - } - if (isset($dependency['github'])) { - $dependencies[] = $dependency['github']; - } + if (is_array($dependency)) { + if (isset($dependency['name'])) { + $dependencies[] = $dependency['name']; + } + if (isset($dependency['github'])) { + $dependencies[] = $dependency['github']; + } } else { $dependencies[] = $dependency; } @@ -180,7 +179,6 @@ class DirectInstallCommand extends ConsoleCommand } if ($type === 'grav') { - $this->output->write(' |- Checking destination... '); Installer::isValidDestination(GRAV_ROOT . '/system'); if (Installer::IS_LINK === Installer::lastErrorCode()) { @@ -224,7 +222,6 @@ class DirectInstallCommand extends ConsoleCommand Folder::delete($tmp_source); Folder::delete($tmp_zip); exit; - } $this->output->write("\x0D"); @@ -248,7 +245,7 @@ class DirectInstallCommand extends ConsoleCommand $this->output->write("\x0D"); - if(Installer::lastErrorCode()) { + if (Installer::lastErrorCode()) { $this->output->writeln(" '- " . Installer::lastErrorMsg() . ''); $this->output->writeln(''); } else { @@ -256,7 +253,6 @@ class DirectInstallCommand extends ConsoleCommand $this->output->writeln(" '- Success! "); $this->output->writeln(''); } - } else { $this->output->writeln(" '- ERROR: ZIP package could not be found"); } diff --git a/system/src/Grav/Console/Gpm/IndexCommand.php b/system/src/Grav/Console/Gpm/IndexCommand.php index d4a39898f..e60e43167 100644 --- a/system/src/Grav/Console/Gpm/IndexCommand.php +++ b/system/src/Grav/Console/Gpm/IndexCommand.php @@ -117,7 +117,6 @@ class IndexCommand extends ConsoleCommand $packages = $this->sort($packages); if (!empty($packages)) { - $table = []; $index = 0; diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php index 2fe1a2ee1..1abe84852 100644 --- a/system/src/Grav/Console/Gpm/InfoCommand.php +++ b/system/src/Grav/Console/Gpm/InfoCommand.php @@ -88,8 +88,10 @@ class InfoCommand extends ConsoleCommand $packageURL = '<' . $foundPackage->author['url'] . '>'; } - $this->output->writeln('' . str_pad('Author', - 12) . ': ' . $foundPackage->author['name'] . ' <' . $foundPackage->author['email'] . '> ' . $packageURL); + $this->output->writeln('' . str_pad( + 'Author', + 12 + ) . ': ' . $foundPackage->author['name'] . ' <' . $foundPackage->author['email'] . '> ' . $packageURL); foreach ([ 'version', @@ -136,8 +138,10 @@ class InfoCommand extends ConsoleCommand // display changelog information $questionHelper = $this->getHelper('question'); - $question = new ConfirmationQuestion('Would you like to read the changelog? [y|N] ', - false); + $question = new ConfirmationQuestion( + 'Would you like to read the changelog? [y|N] ', + false + ); $answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question); if ($answer) { @@ -175,6 +179,5 @@ class InfoCommand extends ConsoleCommand } $this->output->writeln(''); - } } diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index 5de16b7b2..20a962f2a 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -112,8 +112,7 @@ class InstallCommand extends ConsoleCommand $this->data = $this->gpm->findPackages($packages); $this->loadLocalConfig(); - if ( - !Installer::isGravInstance($this->destination) || + if (!Installer::isGravInstance($this->destination) || !Installer::isValidDestination($this->destination, [Installer::EXISTS, Installer::IS_LINK]) ) { $this->output->writeln('ERROR: ' . Installer::lastErrorMsg()); @@ -129,8 +128,10 @@ class InstallCommand extends ConsoleCommand } if (\count($this->data['not_found'])) { - $this->output->writeln('These packages were not found on Grav: ' . implode(', ', - array_keys($this->data['not_found'])) . ''); + $this->output->writeln('These packages were not found on Grav: ' . implode( + ', ', + array_keys($this->data['not_found']) + ) . ''); } unset($this->data['not_found'], $this->data['total']); @@ -162,8 +163,8 @@ class InstallCommand extends ConsoleCommand if ($dependencies) { try { $this->installDependencies($dependencies, 'install', 'The following dependencies need to be installed...'); - $this->installDependencies($dependencies, 'update', 'The following dependencies need to be updated...'); - $this->installDependencies($dependencies, 'ignore', "The following dependencies can be updated as there is a newer version, but it's not mandatory...", false); + $this->installDependencies($dependencies, 'update', 'The following dependencies need to be updated...'); + $this->installDependencies($dependencies, 'ignore', "The following dependencies can be updated as there is a newer version, but it's not mandatory...", false); } catch (\Exception $e) { $this->output->writeln('Installation aborted'); return false; @@ -185,7 +186,6 @@ class InstallCommand extends ConsoleCommand $this->processPackage($package, false); } else { if (Installer::lastErrorCode() == Installer::EXISTS) { - try { $this->askConfirmationIfMajorVersionUpdated($package); $this->gpm->checkNoOtherPackageNeedsThisDependencyInALowerVersion($package->slug, $package->available, array_keys($data)); @@ -270,7 +270,9 @@ class InstallCommand extends ConsoleCommand */ public function installDependencies($dependencies, $type, $message, $required = true) { - $packages = array_filter($dependencies, function ($action) use ($type) { return $action === $type; }); + $packages = array_filter($dependencies, function ($action) use ($type) { + return $action === $type; + }); if (\count($packages) > 0) { $this->output->writeln($message); @@ -453,7 +455,6 @@ class InstallCommand extends ConsoleCommand return $path; } } - } return false; @@ -620,8 +621,10 @@ class InstallCommand extends ConsoleCommand return false; } - $question = new ConfirmationQuestion(" | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ", - false); + $question = new ConfirmationQuestion( + " | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ", + false + ); $answer = $question_helper->ask($this->input, $this->output, $question); if (!$answer) { @@ -684,7 +687,11 @@ class InstallCommand extends ConsoleCommand public function progress($progress) { $this->output->write("\x0D"); - $this->output->write(' |- Downloading package... ' . str_pad($progress['percent'], 5, ' ', - STR_PAD_LEFT) . '%'); + $this->output->write(' |- Downloading package... ' . str_pad( + $progress['percent'], + 5, + ' ', + STR_PAD_LEFT + ) . '%'); } } diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index 62c6120ce..1764cf011 100644 --- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php @@ -121,8 +121,10 @@ class SelfupgradeCommand extends ConsoleCommand $this->output->writeln('You are currently using v' . GRAV_VERSION . '.'); if (!$this->all_yes) { - $question = new ConfirmationQuestion('Would you like to read the changelog before proceeding? [y|N] ', - false); + $question = new ConfirmationQuestion( + 'Would you like to read the changelog before proceeding? [y|N] ', + false + ); $answer = $questionHelper->ask($this->input, $this->output, $question); if ($answer) { @@ -239,8 +241,12 @@ class SelfupgradeCommand extends ConsoleCommand public function progress($progress) { $this->output->write("\x0D"); - $this->output->write(" |- Downloading upgrade [{$this->formatBytes($progress['filesize']) }]... " . str_pad($progress['percent'], - 5, ' ', STR_PAD_LEFT) . '%'); + $this->output->write(" |- Downloading upgrade [{$this->formatBytes($progress['filesize']) }]... " . str_pad( + $progress['percent'], + 5, + ' ', + STR_PAD_LEFT + ) . '%'); } /** diff --git a/system/src/Grav/Console/Gpm/UninstallCommand.php b/system/src/Grav/Console/Gpm/UninstallCommand.php index 99fc81ab0..29c6d8634 100644 --- a/system/src/Grav/Console/Gpm/UninstallCommand.php +++ b/system/src/Grav/Console/Gpm/UninstallCommand.php @@ -91,8 +91,10 @@ class UninstallCommand extends ConsoleCommand } if (count($this->data['not_found'])) { - $this->output->writeln('These packages were not found installed: ' . implode(', ', - $this->data['not_found']) . ''); + $this->output->writeln('These packages were not found installed: ' . implode( + ', ', + $this->data['not_found'] + ) . ''); } unset($this->data['not_found'], $this->data['total']); @@ -115,7 +117,6 @@ class UninstallCommand extends ConsoleCommand $this->output->writeln(" '- Success! "); } } - } // clear cache after successful upgrade @@ -153,7 +154,6 @@ class UninstallCommand extends ConsoleCommand } if (isset($package->dependencies)) { - $dependencies = $package->dependencies; if ($is_dependency) { @@ -172,7 +172,6 @@ class UninstallCommand extends ConsoleCommand $questionHelper = $this->getHelper('question'); foreach ($dependencies as $dependency) { - $this->dependencies[] = $dependency['name']; if (\is_array($dependency)) { @@ -199,7 +198,6 @@ class UninstallCommand extends ConsoleCommand $this->output->writeln(" '- Uninstallation failed or aborted."); } else { $this->output->writeln(" '- Success! "); - } $this->output->writeln(''); } else { @@ -207,7 +205,6 @@ class UninstallCommand extends ConsoleCommand $this->output->writeln(''); } } - } } @@ -262,8 +259,10 @@ class UninstallCommand extends ConsoleCommand return false; } - $question = new ConfirmationQuestion(" | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ", - false); + $question = new ConfirmationQuestion( + " | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ", + false + ); $answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question); if (!$answer) { diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php index d8ea735d7..074cd8e58 100644 --- a/system/src/Grav/Console/Gpm/UpdateCommand.php +++ b/system/src/Grav/Console/Gpm/UpdateCommand.php @@ -174,7 +174,7 @@ class UpdateCommand extends ConsoleCommand } $this->output->writeln( - // index + // index str_pad($index++ + 1, 2, '0', STR_PAD_LEFT) . '. ' . // name '' . str_pad($package->name, 15) . ' ' . @@ -251,15 +251,18 @@ class UpdateCommand extends ConsoleCommand } $this->output->writeln(''); - $this->output->writeln('Limiting updates for only ' . implode(', ', - $list) . ''); + $this->output->writeln('Limiting updates for only ' . implode( + ', ', + $list + ) . ''); } if (\count($ignore)) { $this->output->writeln(''); - $this->output->writeln('Packages not found or not requiring updates: ' . implode(', ', - $ignore) . ''); - + $this->output->writeln('Packages not found or not requiring updates: ' . implode( + ', ', + $ignore + ) . ''); } } diff --git a/system/src/Grav/Console/Gpm/VersionCommand.php b/system/src/Grav/Console/Gpm/VersionCommand.php index becc3274c..910e20c19 100644 --- a/system/src/Grav/Console/Gpm/VersionCommand.php +++ b/system/src/Grav/Console/Gpm/VersionCommand.php @@ -68,7 +68,6 @@ class VersionCommand extends ConsoleCommand if ($upgrader->isUpgradable()) { $updatable = " [upgradable: v{$upgrader->getRemoteVersion()}]"; } - } else { // get currently installed version $locator = \Grav\Common\Grav::instance()['locator']; diff --git a/system/src/Grav/Framework/Cache/Adapter/SessionCache.php b/system/src/Grav/Framework/Cache/Adapter/SessionCache.php index 62c68a0c9..d382909a8 100644 --- a/system/src/Grav/Framework/Cache/Adapter/SessionCache.php +++ b/system/src/Grav/Framework/Cache/Adapter/SessionCache.php @@ -33,7 +33,6 @@ class SessionCache extends AbstractCache $stored = [self::VALUE => $value]; if (null !== $ttl) { $stored[self::LIFETIME] = time() + $ttl; - } $_SESSION[$this->getNamespace()][$key] = $stored; diff --git a/system/src/Grav/Framework/DI/Container.php b/system/src/Grav/Framework/DI/Container.php index c4b3ef4ca..898073774 100644 --- a/system/src/Grav/Framework/DI/Container.php +++ b/system/src/Grav/Framework/DI/Container.php @@ -24,4 +24,4 @@ class Container extends \Pimple\Container implements ContainerInterface { return $this->offsetExists($id); } -} \ No newline at end of file +} diff --git a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php index 2337c334d..84db79a79 100644 --- a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php @@ -95,8 +95,8 @@ class CsvFormatter extends AbstractFormatter $csv_line = str_getcsv($line, $delimiter); if ($null_replace) { - array_walk($csv_line, static function(&$el) use ($null_replace) { - $el = str_replace($null_replace, null, $el); + array_walk($csv_line, static function (&$el) use ($null_replace) { + $el = str_replace($null_replace, null, $el); }); } diff --git a/system/src/Grav/Framework/File/Formatter/FormatterInterface.php b/system/src/Grav/Framework/File/Formatter/FormatterInterface.php index a8d5bc5b8..7beeefb34 100644 --- a/system/src/Grav/Framework/File/Formatter/FormatterInterface.php +++ b/system/src/Grav/Framework/File/Formatter/FormatterInterface.php @@ -7,4 +7,6 @@ use Grav\Framework\File\Interfaces\FileFormatterInterface; /** * @deprecated 1.6 Use Grav\Framework\File\Interfaces\FileFormatterInterface instead */ -interface FormatterInterface extends FileFormatterInterface {}; +interface FormatterInterface extends FileFormatterInterface +{ +}; diff --git a/system/src/Grav/Framework/File/Formatter/IniFormatter.php b/system/src/Grav/Framework/File/Formatter/IniFormatter.php index 8d72c52f1..17543f440 100644 --- a/system/src/Grav/Framework/File/Formatter/IniFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/IniFormatter.php @@ -37,10 +37,10 @@ class IniFormatter extends AbstractFormatter $string = ''; foreach ($data as $key => $value) { $string .= $key . '="' . preg_replace( - ['/"/', '/\\\/', "/\t/", "/\n/", "/\r/"], - ['\"', '\\\\', '\t', '\n', '\r'], - $value - ) . "\"\n"; + ['/"/', '/\\\/', "/\t/", "/\n/", "/\r/"], + ['\"', '\\\\', '\t', '\n', '\r'], + $value + ) . "\"\n"; } return $string; diff --git a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php index fb1507337..c700206e9 100644 --- a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php @@ -127,7 +127,7 @@ class MarkdownFormatter extends AbstractFormatter // Parse header. preg_match($headerRegex, ltrim($data), $matches); - if(empty($matches)) { + if (empty($matches)) { $content[$bodyVar] = $data; } else { // Normalize frontmatter. diff --git a/system/src/Grav/Framework/Filesystem/Filesystem.php b/system/src/Grav/Framework/Filesystem/Filesystem.php index 9cd206df4..f2423b800 100644 --- a/system/src/Grav/Framework/Filesystem/Filesystem.php +++ b/system/src/Grav/Framework/Filesystem/Filesystem.php @@ -19,13 +19,13 @@ class Filesystem implements FilesystemInterface private $normalize; /** @var static */ - static protected $default; + protected static $default; /** @var static */ - static protected $unsafe; + protected static $unsafe; /** @var static */ - static protected $safe; + protected static $safe; /** * @param bool|null $normalize See $this->setNormalization() diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php index e27c8ae29..5683fdd93 100644 --- a/system/src/Grav/Framework/Flex/Flex.php +++ b/system/src/Grav/Framework/Flex/Flex.php @@ -297,7 +297,7 @@ class Flex implements \Countable { $guess = false; if (strpos($flexKey, ':') !== false) { - [$type, $key] = explode(':', $flexKey, 2); + [$type, $key] = explode(':', $flexKey, 2); $type = $this->resolveType($type); } else { diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php index 940e7042c..50753b119 100644 --- a/system/src/Grav/Framework/Flex/FlexCollection.php +++ b/system/src/Grav/Framework/Flex/FlexCollection.php @@ -472,9 +472,11 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface */ public function find($value, $field = 'id') { - if ($value) foreach ($this as $element) { - if (mb_strtolower($element->getProperty($field)) === mb_strtolower($value)) { - return $element; + if ($value) { + foreach ($this as $element) { + if (mb_strtolower($element->getProperty($field)) === mb_strtolower($value)) { + return $element; + } } } diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php index 58e042cd2..06eebe462 100644 --- a/system/src/Grav/Framework/Flex/FlexDirectory.php +++ b/system/src/Grav/Framework/Flex/FlexDirectory.php @@ -468,7 +468,6 @@ class FlexDirectory implements FlexAuthorizeInterface } return $this->objectClassName; - } /** @@ -770,7 +769,8 @@ class FlexDirectory implements FlexAuthorizeInterface $index = $this->index; if (null === $index) { - $i++; $j = $i; + $i++; + $j = $i; /** @var Debugger $debugger */ $debugger = Grav::instance()['debugger']; $debugger->startTimer('flex-keys-' . $this->type . $j, "Flex: Loading {$this->type} index"); @@ -790,8 +790,10 @@ class FlexDirectory implements FlexAuthorizeInterface $className = $this->getIndexClass(); $keys = $className::loadEntriesFromStorage($storage); if (!$cache instanceof MemoryCache) { - $debugger->addMessage(sprintf('Flex: Caching %s index of %d objects', $this->type, \count($keys)), - 'debug'); + $debugger->addMessage( + sprintf('Flex: Caching %s index of %d objects', $this->type, \count($keys)), + 'debug' + ); } try { $cache->set('__keys', $keys); diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index bcab36170..ba0eaf37b 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -909,7 +909,9 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface $list = $this->getNestedProperty($property) ?: []; /** @var FlexCollection $collection */ - $collection = $collection->filter(function ($object) use ($list) { return \in_array($object->id, $list, true); }); + $collection = $collection->filter(function ($object) use ($list) { + return \in_array($object->id, $list, true); + }); return $collection; } @@ -1012,7 +1014,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface $elements['storage_timestamp'] = (int)$elements['storage_timestamp']; } - unset ($elements['_post_entries_save']); + unset($elements['_post_entries_save']); } /** diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php b/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php index f63212c92..905359a63 100644 --- a/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php +++ b/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php @@ -28,7 +28,7 @@ class FlexPageIndex extends FlexIndex * @return string * @internal */ - static public function normalizeRoute(string $route) + public static function normalizeRoute(string $route) { static $case_insensitive; diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php index 46e873065..ca7326d5f 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php @@ -27,7 +27,7 @@ use RocketTheme\Toolbox\Event\Event; */ trait PageContentTrait { - static protected $headerProperties = [ + protected static $headerProperties = [ 'slug' => 'slug', 'routes' => false, 'title' => 'title', @@ -59,7 +59,7 @@ trait PageContentTrait 'debugger' => false, ]; - static protected $calculatedProperties = [ + protected static $calculatedProperties = [ 'name' => 'name', 'parent' => 'parent', 'parent_key' => 'parentStorageKey', @@ -194,7 +194,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'title', $var, - function($value) { + function ($value) { return trim($value ?? ($this->root() ? '' : ucfirst($this->slug()))); } ); @@ -208,7 +208,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'menu', $var, - function($value) { + function ($value) { return trim($value ?: $this->title()); } ); @@ -222,7 +222,7 @@ trait PageContentTrait $value = $this->loadHeaderProperty( 'visible', $var, - function($value) { + function ($value) { return ($value ?? $this->order() !== false) && !$this->modular(); } ); @@ -238,7 +238,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'published', $var, - static function($value) { + static function ($value) { return (bool)($value ?? true); } ); @@ -252,7 +252,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'publish_date', $var, - function($value) { + function ($value) { return $value ? Utils::date2timestamp($value, $this->getProperty('dateformat')) : null; } ); @@ -266,7 +266,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'unpublish_date', $var, - function($value) { + function ($value) { return $value ? Utils::date2timestamp($value, $this->getProperty('dateformat')) : null; } ); @@ -280,7 +280,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'process', $var, - function($value) { + function ($value) { $value = array_replace(Grav::instance()['config']->get('system.pages.process', []), is_array($value) ? $value : []); foreach ($value as $process => $status) { $value[$process] = (bool)$status; @@ -299,7 +299,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'slug', $var, - function($value) { + function ($value) { return $value ?: static::normalizeRoute(preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder())); } ); @@ -313,7 +313,7 @@ trait PageContentTrait $property = $this->loadProperty( 'order', $var, - function($value) { + function ($value) { if (null === $value) { preg_match(static::PAGE_ORDER_REGEX, $this->folder(), $order); @@ -337,7 +337,7 @@ trait PageContentTrait $property = 'id'; $value = null === $var ? $this->getProperty($property) : null; if (null === $value) { - $value = $this->language() . ($var ?? ($this->modified() . md5( 'flex-' . $this->getFlexType() . '-' . $this->getKey()))); + $value = $this->language() . ($var ?? ($this->modified() . md5('flex-' . $this->getFlexType() . '-' . $this->getKey()))); $this->setProperty($property, $value); if ($this->doHasProperty($property)) { @@ -375,7 +375,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'last_modified', $var, - static function($value) { + static function ($value) { return (bool)($value ?? Grav::instance()['config']->get('system.pages.last_modified')); } ); @@ -389,7 +389,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'date', $var, - function($value) { + function ($value) { $value = $value ? Utils::date2timestamp($value, $this->getProperty('dateformat')) : false; return $value ?: $this->modified(); @@ -405,7 +405,7 @@ trait PageContentTrait return $this->loadHeaderProperty( 'dateformat', $var, - static function($value) { + static function ($value) { return $value ?? null; } ); @@ -419,14 +419,14 @@ trait PageContentTrait return $this->loadHeaderProperty( 'taxonomy', $var, - static function($value) { + static function ($value) { if (is_array($value)) { // make sure first level are arrays - array_walk($value, static function(&$val) { + array_walk($value, static function (&$val) { $val = (array) $val; }); // make sure all values are strings - array_walk_recursive($value, static function(&$val) { + array_walk_recursive($value, static function (&$val) { $val = (string) $val; }); } @@ -691,7 +691,6 @@ trait PageContentTrait // Content Processed but not cached yet $grav->fireEvent('onPageContentProcessed', new Event(['page' => $this])); - } else { if ($process_markdown) { $this->_content = $this->processMarkdown($this->_content, $options); diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php index fabfcfb4e..b0c721a1d 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php @@ -469,7 +469,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'template', $var, - function($value) { + function ($value) { return trim($value ?? (($this->modular() ? 'modular/' : '') . str_replace($this->extension(), '', $this->name()))); } ); @@ -488,7 +488,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'template_format', $var, - function($value) { + function ($value) { return ltrim($value ?? $this->getNestedProperty('header.append_url_extension') ?: Utils::getPageFormat(), '.'); } ); @@ -528,7 +528,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'expires', $var, - static function($value) { + static function ($value) { return (int)($value ?? Grav::instance()['config']->get('system.pages.expires')); } ); @@ -546,7 +546,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'cache_control', $var, - static function($value) { + static function ($value) { return ((string)($value ?? Grav::instance()['config']->get('system.pages.cache_control'))) ?: null; } ); @@ -557,7 +557,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'ssl', $var, - static function($value) { + static function ($value) { return $value ? (bool)$value : null; } ); @@ -669,7 +669,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'etag', $var, - static function($value) { + static function ($value) { return (bool)($value ?? Grav::instance()['config']->get('system.pages.last_modified')); } ); @@ -730,7 +730,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'order_dir', $var, - static function($value) { + static function ($value) { return strtolower(trim($value) ?: Grav::instance()['config']->get('system.pages.order.dir')) === 'desc' ? 'desc' : 'asc'; } ); @@ -753,7 +753,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'order_by', $var, - static function($value) { + static function ($value) { return trim($value) ?: Grav::instance()['config']->get('system.pages.order.by'); } ); @@ -771,7 +771,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'order_manual', $var, - static function($value) { + static function ($value) { return (array)$value; } ); @@ -790,7 +790,7 @@ trait PageLegacyTrait return $this->loadHeaderProperty( 'max_count', $var, - static function($value) { + static function ($value) { return (int)($value ?? Grav::instance()['config']->get('system.pages.list.count')); } ); diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php index d15a0f6de..66a882103 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php @@ -33,7 +33,7 @@ trait PageRoutableTrait return $this->loadHeaderProperty( 'url_extension', null, - function($value) { + function ($value) { if ($this->home()) { return ''; } @@ -56,7 +56,7 @@ trait PageRoutableTrait $value = $this->loadHeaderProperty( 'routable', $var, - function($value) { + function ($value) { return ($value ?? true) && $this->published() && $this->getLanguages(true); } ); @@ -243,7 +243,7 @@ trait PageRoutableTrait return $this->loadHeaderProperty( 'redirect', $var, - static function($value) { + static function ($value) { return trim($value) ?: null; } ); @@ -306,7 +306,7 @@ trait PageRoutableTrait return $this->loadProperty( 'folder', $var, - function($value) { + function ($value) { if (null === $value) { $value = $this->getStorageKey(true) ?: $this->getKey(); } @@ -328,7 +328,7 @@ trait PageRoutableTrait return $this->loadProperty( 'parent_key', $var, - function($value) { + function ($value) { if (null === $value) { $value = $this->getStorageKey(true) ?: $this->getKey(); $value = ltrim(dirname("/{$value}"), '/') ?: ''; diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php index 01d7aa926..5cfd5bbc3 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php @@ -206,7 +206,7 @@ trait PageTranslateTrait return $this->loadHeaderProperty( 'lang', $var, - function($value) { + function ($value) { $value = $value ?? $this->getMetaData()['lang'] ?? ''; return trim($value) ?: null; diff --git a/system/src/Grav/Framework/Form/FormFlash.php b/system/src/Grav/Framework/Form/FormFlash.php index 9b712eeda..2e99c579b 100644 --- a/system/src/Grav/Framework/Form/FormFlash.php +++ b/system/src/Grav/Framework/Form/FormFlash.php @@ -62,7 +62,9 @@ class FormFlash implements FormFlashInterface 'unique_id' => $args[1] ?? null, 'form_name' => $args[2] ?? null, ]; - $config = array_filter($config, static function ($val) { return $val !== null; }); + $config = array_filter($config, static function ($val) { + return $val !== null; + }); } $this->sessionId = $config['session_id'] ?? 'no-session'; @@ -112,7 +114,8 @@ class FormFlash implements FormFlashInterface if ($exists) { try { $data = (array)$file->content(); - } catch (\Exception $e) {} + } catch (\Exception $e) { + } } return $data; diff --git a/system/src/Grav/Framework/Form/Traits/FormTrait.php b/system/src/Grav/Framework/Form/Traits/FormTrait.php index d596c0a3b..c58e51b68 100644 --- a/system/src/Grav/Framework/Form/Traits/FormTrait.php +++ b/system/src/Grav/Framework/Form/Traits/FormTrait.php @@ -248,7 +248,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); diff --git a/system/src/Grav/Framework/Object/Base/ObjectTrait.php b/system/src/Grav/Framework/Object/Base/ObjectTrait.php index baeeb2bb7..0fbbafa19 100644 --- a/system/src/Grav/Framework/Object/Base/ObjectTrait.php +++ b/system/src/Grav/Framework/Object/Base/ObjectTrait.php @@ -17,7 +17,7 @@ namespace Grav\Framework\Object\Base; trait ObjectTrait { /** @var string */ - static protected $type; + protected static $type; /** * @var string diff --git a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php index 0eefb78a0..1d6a999ae 100644 --- a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php +++ b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php @@ -101,7 +101,7 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor public static function sortByField($name, $orientation = 1, \Closure $next = null) { if (!$next) { - $next = function($a, $b) { + $next = function ($a, $b) { return 0; }; } diff --git a/system/src/Grav/Framework/Object/ObjectIndex.php b/system/src/Grav/Framework/Object/ObjectIndex.php index 4ba9b75e6..73ca13f88 100644 --- a/system/src/Grav/Framework/Object/ObjectIndex.php +++ b/system/src/Grav/Framework/Object/ObjectIndex.php @@ -24,7 +24,7 @@ use Grav\Framework\Object\Interfaces\ObjectCollectionInterface; abstract class ObjectIndex extends AbstractIndexCollection implements ObjectCollectionInterface, NestedObjectInterface { /** @var string */ - static protected $type; + protected static $type; /** * @var string diff --git a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php index 7092e15d5..4932acf6a 100644 --- a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php +++ b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php @@ -95,7 +95,9 @@ trait ArrayPropertyTrait */ protected function getElements() { - return array_filter($this->_elements, function ($val) { return $val !== null; }); + return array_filter($this->_elements, function ($val) { + return $val !== null; + }); } /** diff --git a/system/src/Grav/Framework/RequestHandler/RequestHandler.php b/system/src/Grav/Framework/RequestHandler/RequestHandler.php index c4d53873b..80f5fd85d 100644 --- a/system/src/Grav/Framework/RequestHandler/RequestHandler.php +++ b/system/src/Grav/Framework/RequestHandler/RequestHandler.php @@ -63,4 +63,4 @@ class RequestHandler implements RequestHandlerInterface return $this; } -} \ No newline at end of file +} diff --git a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php index 153d1a160..79358003d 100644 --- a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php +++ b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php @@ -56,4 +56,4 @@ trait RequestHandlerTrait return $this->handle($request); } -} \ No newline at end of file +} diff --git a/system/src/Grav/Framework/Route/Route.php b/system/src/Grav/Framework/Route/Route.php index 95a111c16..0cdac8b0a 100644 --- a/system/src/Grav/Framework/Route/Route.php +++ b/system/src/Grav/Framework/Route/Route.php @@ -411,7 +411,6 @@ class Route $this->extension = $gravParts['extension'] ?? ''; $this->gravParams = $gravParts['params'] ?: []; $this->queryParams = $parts['query_params'] ?: []; - } else { $this->root = RouteFactory::getRoot(); $this->language = RouteFactory::getLanguage(); diff --git a/system/src/Grav/Framework/Uri/UriFactory.php b/system/src/Grav/Framework/Uri/UriFactory.php index e5cb1d319..e8172980d 100644 --- a/system/src/Grav/Framework/Uri/UriFactory.php +++ b/system/src/Grav/Framework/Uri/UriFactory.php @@ -122,7 +122,9 @@ class UriFactory $encodedUrl = preg_replace_callback( '%[^:/@?&=#]+%u', - function ($matches) { return rawurlencode($matches[0]); }, + function ($matches) { + return rawurlencode($matches[0]); + }, $url ); diff --git a/system/src/Grav/Installer/Install.php b/system/src/Grav/Installer/Install.php index 5345ce3a0..dc7d556e9 100644 --- a/system/src/Grav/Installer/Install.php +++ b/system/src/Grav/Installer/Install.php @@ -144,7 +144,7 @@ class Install { $results = []; - $this->checkVersion($results, 'php','php', $this->requires['php'], PHP_VERSION); + $this->checkVersion($results, 'php', 'php', $this->requires['php'], PHP_VERSION); $this->checkVersion($results, 'grav', 'grav', $this->requires['grav'], GRAV_VERSION); $this->checkPlugins($results, $this->requires['plugins']); @@ -284,4 +284,4 @@ class Install $this->checkVersion($results, 'plugin', $name, $check, $version); } } -} \ No newline at end of file +} diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 1c0ffd94b..03677dd84 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -7,7 +7,7 @@ use Grav\Common\Grav; ini_set('error_log', __DIR__ . '/error.log'); -$grav = function() { +$grav = function () { Grav::resetInstance(); $grav = Grav::instance(); $grav['config']->init(); @@ -32,4 +32,3 @@ Fixtures::add('grav', $grav); $fake = Factory::create(); Fixtures::add('fake', $fake); - diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php index 199872966..74ef5a6b8 100644 --- a/tests/_support/Helper/Unit.php +++ b/tests/_support/Helper/Unit.php @@ -2,6 +2,7 @@ namespace Helper; use Codeception; + // here you can define custom actions // all public methods declared in helper class will be available in $I @@ -14,13 +15,15 @@ class Unit extends Codeception\Module /** * HOOK: used after configuration is loaded */ - public function _initialize() { + public function _initialize() + { } /** * HOOK: on every Actor class initialization */ - public function _cleanup() { + public function _cleanup() + { } /** @@ -28,13 +31,15 @@ class Unit extends Codeception\Module * * @param array $settings */ - public function _beforeSuite($settings = []) { + public function _beforeSuite($settings = []) + { } /** * HOOK: after suite **/ - public function _afterSuite() { + public function _afterSuite() + { } /** @@ -42,7 +47,8 @@ class Unit extends Codeception\Module * * @param Codeception\Step $step* */ - public function _beforeStep(Codeception\Step $step) { + public function _beforeStep(Codeception\Step $step) + { } /** @@ -50,7 +56,8 @@ class Unit extends Codeception\Module * * @param Codeception\Step $step */ - public function _afterStep(Codeception\Step $step) { + public function _afterStep(Codeception\Step $step) + { } /** @@ -58,7 +65,8 @@ class Unit extends Codeception\Module * * @param Codeception\TestCase $test */ - public function _before(Codeception\TestCase $test) { + public function _before(Codeception\TestCase $test) + { } /** @@ -66,7 +74,8 @@ class Unit extends Codeception\Module * * @param Codeception\TestCase $test */ - public function _after(Codeception\TestCase $test) { + public function _after(Codeception\TestCase $test) + { } /** @@ -75,6 +84,7 @@ class Unit extends Codeception\Module * @param Codeception\TestCase $test * @param $fail */ - public function _failed(Codeception\TestCase $test, $fail) { + public function _failed(Codeception\TestCase $test, $fail) + { } } diff --git a/tests/functional/Grav/Console/DirectInstallCommandTest.php b/tests/functional/Grav/Console/DirectInstallCommandTest.php index d1bc6cf76..d26a29ce2 100644 --- a/tests/functional/Grav/Console/DirectInstallCommandTest.php +++ b/tests/functional/Grav/Console/DirectInstallCommandTest.php @@ -4,7 +4,6 @@ use Codeception\Util\Fixtures; use Grav\Common\Grav; use Grav\Console\Gpm\DirectInstallCommand; - /** * Class DirectInstallCommandTest */ @@ -22,7 +21,6 @@ class DirectInstallCommandTest extends \Codeception\TestCase\Test $this->grav = Fixtures::get('grav'); $this->directInstallCommand = new DirectInstallCommand(); } - } /** diff --git a/tests/phpstan/plugins-bootstrap.php b/tests/phpstan/plugins-bootstrap.php index 8d5492971..0126d28d6 100644 --- a/tests/phpstan/plugins-bootstrap.php +++ b/tests/phpstan/plugins-bootstrap.php @@ -30,7 +30,7 @@ $grav['config']->init(); /** @var UniformResourceLocator $locator */ $locator = Grav::instance()['locator']; $iterator = $locator->getIterator('plugins://'); -foreach($iterator as $directory) { +foreach ($iterator as $directory) { if (!$directory->isDir()) { continue; } diff --git a/tests/unit/Grav/Common/AssetsTest.php b/tests/unit/Grav/Common/AssetsTest.php index 4c574e389..d3e72dd7f 100644 --- a/tests/unit/Grav/Common/AssetsTest.php +++ b/tests/unit/Grav/Common/AssetsTest.php @@ -322,8 +322,6 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assets->add('test.css', ['media' => 'only screen and (min-width: 640px)']); $css = $this->assets->css(); $this->assertSame('' . PHP_EOL, $css); - - } public function testAddingAssetPropertiesWithArray() @@ -334,7 +332,6 @@ class AssetsTest extends \Codeception\TestCase\Test $js = $this->assets->js(); $this->assertSame('' . PHP_EOL, $js); $this->assets->reset(); - } public function testAddingJSAssetPropertiesWithArrayFromCollection() @@ -444,7 +441,6 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assets->addInlineJs('alert("test")', 15, 'bottom', ['id' => 'foo']); $js = $this->assets->js('bottom'); $this->assertSame('' . PHP_EOL, $js); - } public function testAddingCSSAssetPropertiesWithArrayFromCollection() @@ -773,6 +769,5 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assertGreaterThan(0, (array) $this->assets->getCss()); $this->assertInternalType('array', $this->assets->getJs()); $this->assertGreaterThan(0, (array) $this->assets->getJs()); - } } diff --git a/tests/unit/Grav/Common/BrowserTest.php b/tests/unit/Grav/Common/BrowserTest.php index 6e637384e..a4df12003 100644 --- a/tests/unit/Grav/Common/BrowserTest.php +++ b/tests/unit/Grav/Common/BrowserTest.php @@ -22,19 +22,23 @@ class BrowserTest extends \Codeception\TestCase\Test } public function testGetBrowser() - { /* Already covered by PhpUserAgent tests */ + { + /* Already covered by PhpUserAgent tests */ } public function testGetPlatform() - { /* Already covered by PhpUserAgent tests */ + { + /* Already covered by PhpUserAgent tests */ } public function testGetLongVersion() - { /* Already covered by PhpUserAgent tests */ + { + /* Already covered by PhpUserAgent tests */ } public function testGetVersion() - { /* Already covered by PhpUserAgent tests */ + { + /* Already covered by PhpUserAgent tests */ } public function testIsHuman() @@ -45,4 +49,3 @@ class BrowserTest extends \Codeception\TestCase\Test $this->assertFalse($this->grav['browser']->isHuman()); } } - diff --git a/tests/unit/Grav/Common/ComposerTest.php b/tests/unit/Grav/Common/ComposerTest.php index 243a88862..c1d7dbbfd 100644 --- a/tests/unit/Grav/Common/ComposerTest.php +++ b/tests/unit/Grav/Common/ComposerTest.php @@ -28,5 +28,4 @@ class ComposerTest extends \Codeception\TestCase\Test $this->assertNotNull(strstr($composerExecutor, 'php')); $this->assertNotNull(strstr($composerExecutor, 'composer')); } - } diff --git a/tests/unit/Grav/Common/GPM/GPMTest.php b/tests/unit/Grav/Common/GPM/GPMTest.php index 7e1c03e92..51049c47a 100644 --- a/tests/unit/Grav/Common/GPM/GPMTest.php +++ b/tests/unit/Grav/Common/GPM/GPMTest.php @@ -16,7 +16,6 @@ class GpmStub extends GPM if (isset($this->data[$packageName])) { return $this->data[$packageName]; } - } public function findPackages($searches = []) diff --git a/tests/unit/Grav/Common/Helpers/ExcerptsTest.php b/tests/unit/Grav/Common/Helpers/ExcerptsTest.php index 3673da558..e344a8fdc 100644 --- a/tests/unit/Grav/Common/Helpers/ExcerptsTest.php +++ b/tests/unit/Grav/Common/Helpers/ExcerptsTest.php @@ -78,10 +78,13 @@ class ExcerptsTest extends \Codeception\TestCase\Test public function testProcessImageHtml() { - $this->assertRegexp('|Sample Image|', - Excerpts::processImageHtml('Sample Image', $this->page)); - $this->assertRegexp('|Sample Image|', - Excerpts::processImageHtml('Sample Image', $this->page)); + $this->assertRegexp( + '|Sample Image|', + Excerpts::processImageHtml('Sample Image', $this->page) + ); + $this->assertRegexp( + '|Sample Image|', + Excerpts::processImageHtml('Sample Image', $this->page) + ); } - } diff --git a/tests/unit/Grav/Common/InflectorTest.php b/tests/unit/Grav/Common/InflectorTest.php index 9fad48964..b0b1d4ad9 100644 --- a/tests/unit/Grav/Common/InflectorTest.php +++ b/tests/unit/Grav/Common/InflectorTest.php @@ -29,119 +29,117 @@ class InflectorTest extends \Codeception\TestCase\Test public function testPluralize() { - $this->assertSame('words', $this->inflector->pluralize('word')); - $this->assertSame('kisses', $this->inflector->pluralize('kiss')); - $this->assertSame('volcanoes', $this->inflector->pluralize('volcanoe')); - $this->assertSame('cherries', $this->inflector->pluralize('cherry')); - $this->assertSame('days', $this->inflector->pluralize('day')); - $this->assertSame('knives', $this->inflector->pluralize('knife')); + $this->assertSame('words', $this->inflector->pluralize('word')); + $this->assertSame('kisses', $this->inflector->pluralize('kiss')); + $this->assertSame('volcanoes', $this->inflector->pluralize('volcanoe')); + $this->assertSame('cherries', $this->inflector->pluralize('cherry')); + $this->assertSame('days', $this->inflector->pluralize('day')); + $this->assertSame('knives', $this->inflector->pluralize('knife')); } public function testSingularize() { - $this->assertSame('word', $this->inflector->singularize('words')); - $this->assertSame('kiss', $this->inflector->singularize('kisses')); - $this->assertSame('volcanoe', $this->inflector->singularize('volcanoe')); - $this->assertSame('cherry', $this->inflector->singularize('cherries')); - $this->assertSame('day', $this->inflector->singularize('days')); - $this->assertSame('knife', $this->inflector->singularize('knives')); + $this->assertSame('word', $this->inflector->singularize('words')); + $this->assertSame('kiss', $this->inflector->singularize('kisses')); + $this->assertSame('volcanoe', $this->inflector->singularize('volcanoe')); + $this->assertSame('cherry', $this->inflector->singularize('cherries')); + $this->assertSame('day', $this->inflector->singularize('days')); + $this->assertSame('knife', $this->inflector->singularize('knives')); } public function testTitleize() { - $this->assertSame('This String Is Titleized', $this->inflector->titleize('ThisStringIsTitleized')); - $this->assertSame('This String Is Titleized', $this->inflector->titleize('this string is titleized')); - $this->assertSame('This String Is Titleized', $this->inflector->titleize('this_string_is_titleized')); - $this->assertSame('This String Is Titleized', $this->inflector->titleize('this-string-is-titleized')); + $this->assertSame('This String Is Titleized', $this->inflector->titleize('ThisStringIsTitleized')); + $this->assertSame('This String Is Titleized', $this->inflector->titleize('this string is titleized')); + $this->assertSame('This String Is Titleized', $this->inflector->titleize('this_string_is_titleized')); + $this->assertSame('This String Is Titleized', $this->inflector->titleize('this-string-is-titleized')); - $this->assertSame('This string is titleized', $this->inflector->titleize('ThisStringIsTitleized', 'first')); - $this->assertSame('This string is titleized', $this->inflector->titleize('this string is titleized', 'first')); - $this->assertSame('This string is titleized', $this->inflector->titleize('this_string_is_titleized', 'first')); - $this->assertSame('This string is titleized', $this->inflector->titleize('this-string-is-titleized', 'first')); + $this->assertSame('This string is titleized', $this->inflector->titleize('ThisStringIsTitleized', 'first')); + $this->assertSame('This string is titleized', $this->inflector->titleize('this string is titleized', 'first')); + $this->assertSame('This string is titleized', $this->inflector->titleize('this_string_is_titleized', 'first')); + $this->assertSame('This string is titleized', $this->inflector->titleize('this-string-is-titleized', 'first')); } public function testCamelize() { - $this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('This String Is Camelized')); - $this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('thisStringIsCamelized')); - $this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('This_String_Is_Camelized')); - $this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('this string is camelized')); - $this->assertSame('GravSPrettyCoolMy1', $this->inflector->camelize("Grav's Pretty Cool. My #1!")); + $this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('This String Is Camelized')); + $this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('thisStringIsCamelized')); + $this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('This_String_Is_Camelized')); + $this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('this string is camelized')); + $this->assertSame('GravSPrettyCoolMy1', $this->inflector->camelize("Grav's Pretty Cool. My #1!")); } public function testUnderscorize() { - $this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This String Is Underscorized')); - $this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('ThisStringIsUnderscorized')); - $this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This_String_Is_Underscorized')); - $this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This-String-Is-Underscorized')); + $this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This String Is Underscorized')); + $this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('ThisStringIsUnderscorized')); + $this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This_String_Is_Underscorized')); + $this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This-String-Is-Underscorized')); } public function testHyphenize() { - $this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This String Is Hyphenized')); - $this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('ThisStringIsHyphenized')); - $this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This-String-Is-Hyphenized')); - $this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This_String_Is_Hyphenized')); + $this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This String Is Hyphenized')); + $this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('ThisStringIsHyphenized')); + $this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This-String-Is-Hyphenized')); + $this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This_String_Is_Hyphenized')); } public function testHumanize() { //$this->assertSame('This string is humanized', $this->inflector->humanize('ThisStringIsHumanized')); - $this->assertSame('This string is humanized', $this->inflector->humanize('this_string_is_humanized')); + $this->assertSame('This string is humanized', $this->inflector->humanize('this_string_is_humanized')); //$this->assertSame('This string is humanized', $this->inflector->humanize('this-string-is-humanized')); - $this->assertSame('This String Is Humanized', $this->inflector->humanize('this_string_is_humanized', 'all')); + $this->assertSame('This String Is Humanized', $this->inflector->humanize('this_string_is_humanized', 'all')); //$this->assertSame('This String Is Humanized', $this->inflector->humanize('this-string-is-humanized'), 'all'); } public function testVariablize() { - $this->assertSame('thisStringIsVariablized', $this->inflector->variablize('This String Is Variablized')); - $this->assertSame('thisStringIsVariablized', $this->inflector->variablize('ThisStringIsVariablized')); - $this->assertSame('thisStringIsVariablized', $this->inflector->variablize('This_String_Is_Variablized')); - $this->assertSame('thisStringIsVariablized', $this->inflector->variablize('this string is variablized')); - $this->assertSame('gravSPrettyCoolMy1', $this->inflector->variablize("Grav's Pretty Cool. My #1!")); + $this->assertSame('thisStringIsVariablized', $this->inflector->variablize('This String Is Variablized')); + $this->assertSame('thisStringIsVariablized', $this->inflector->variablize('ThisStringIsVariablized')); + $this->assertSame('thisStringIsVariablized', $this->inflector->variablize('This_String_Is_Variablized')); + $this->assertSame('thisStringIsVariablized', $this->inflector->variablize('this string is variablized')); + $this->assertSame('gravSPrettyCoolMy1', $this->inflector->variablize("Grav's Pretty Cool. My #1!")); } public function testTableize() { - $this->assertSame('people', $this->inflector->tableize('Person')); - $this->assertSame('pages', $this->inflector->tableize('Page')); - $this->assertSame('blog_pages', $this->inflector->tableize('BlogPage')); - $this->assertSame('admin_dependencies', $this->inflector->tableize('adminDependency')); - $this->assertSame('admin_dependencies', $this->inflector->tableize('admin-dependency')); - $this->assertSame('admin_dependencies', $this->inflector->tableize('admin_dependency')); + $this->assertSame('people', $this->inflector->tableize('Person')); + $this->assertSame('pages', $this->inflector->tableize('Page')); + $this->assertSame('blog_pages', $this->inflector->tableize('BlogPage')); + $this->assertSame('admin_dependencies', $this->inflector->tableize('adminDependency')); + $this->assertSame('admin_dependencies', $this->inflector->tableize('admin-dependency')); + $this->assertSame('admin_dependencies', $this->inflector->tableize('admin_dependency')); } public function testClassify() { - $this->assertSame('Person', $this->inflector->classify('people')); - $this->assertSame('Page', $this->inflector->classify('pages')); - $this->assertSame('BlogPage', $this->inflector->classify('blog_pages')); - $this->assertSame('AdminDependency', $this->inflector->classify('admin_dependencies')); + $this->assertSame('Person', $this->inflector->classify('people')); + $this->assertSame('Page', $this->inflector->classify('pages')); + $this->assertSame('BlogPage', $this->inflector->classify('blog_pages')); + $this->assertSame('AdminDependency', $this->inflector->classify('admin_dependencies')); } public function testOrdinalize() { - $this->assertSame('1st', $this->inflector->ordinalize(1)); - $this->assertSame('2nd', $this->inflector->ordinalize(2)); - $this->assertSame('3rd', $this->inflector->ordinalize(3)); - $this->assertSame('4th', $this->inflector->ordinalize(4)); - $this->assertSame('5th', $this->inflector->ordinalize(5)); - $this->assertSame('16th', $this->inflector->ordinalize(16)); - $this->assertSame('51st', $this->inflector->ordinalize(51)); - $this->assertSame('111th', $this->inflector->ordinalize(111)); - $this->assertSame('123rd', $this->inflector->ordinalize(123)); + $this->assertSame('1st', $this->inflector->ordinalize(1)); + $this->assertSame('2nd', $this->inflector->ordinalize(2)); + $this->assertSame('3rd', $this->inflector->ordinalize(3)); + $this->assertSame('4th', $this->inflector->ordinalize(4)); + $this->assertSame('5th', $this->inflector->ordinalize(5)); + $this->assertSame('16th', $this->inflector->ordinalize(16)); + $this->assertSame('51st', $this->inflector->ordinalize(51)); + $this->assertSame('111th', $this->inflector->ordinalize(111)); + $this->assertSame('123rd', $this->inflector->ordinalize(123)); } public function testMonthize() { - $this->assertSame(0, $this->inflector->monthize(10)); - $this->assertSame(1, $this->inflector->monthize(33)); - $this->assertSame(1, $this->inflector->monthize(41)); - $this->assertSame(11, $this->inflector->monthize(364)); + $this->assertSame(0, $this->inflector->monthize(10)); + $this->assertSame(1, $this->inflector->monthize(33)); + $this->assertSame(1, $this->inflector->monthize(41)); + $this->assertSame(11, $this->inflector->monthize(364)); } } - - diff --git a/tests/unit/Grav/Common/Language/LanguageCodesTest.php b/tests/unit/Grav/Common/Language/LanguageCodesTest.php index ef6cabc6d..3fbc69eb0 100644 --- a/tests/unit/Grav/Common/Language/LanguageCodesTest.php +++ b/tests/unit/Grav/Common/Language/LanguageCodesTest.php @@ -2,7 +2,6 @@ use Grav\Common\Language\LanguageCodes; - /** * Class ParsedownTest */ @@ -10,15 +9,19 @@ class LanguageCodesTest extends \Codeception\TestCase\Test { public function testRtl() { - $this->assertSame('ltr', - LanguageCodes::getOrientation('en')); - $this->assertSame('rtl', - LanguageCodes::getOrientation('ar')); - $this->assertSame('rtl', - LanguageCodes::getOrientation('he')); + $this->assertSame( + 'ltr', + LanguageCodes::getOrientation('en') + ); + $this->assertSame( + 'rtl', + LanguageCodes::getOrientation('ar') + ); + $this->assertSame( + 'rtl', + LanguageCodes::getOrientation('he') + ); $this->assertTrue(LanguageCodes::isRtl('ar')); $this->assertFalse(LanguageCodes::isRtl('fr')); - } - } diff --git a/tests/unit/Grav/Common/Markdown/ParsedownTest.php b/tests/unit/Grav/Common/Markdown/ParsedownTest.php index 2293bb749..8f534ecfe 100644 --- a/tests/unit/Grav/Common/Markdown/ParsedownTest.php +++ b/tests/unit/Grav/Common/Markdown/ParsedownTest.php @@ -10,7 +10,6 @@ use Grav\Common\Markdown\Parsedown; use Grav\Common\Language\Language; use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator; - /** * Class ParsedownTest */ @@ -85,45 +84,71 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->grav['language'] = new Language($this->grav); $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init(); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)')); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)') + ); $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](/home-cache-image.jpg?cache)')); - $this->assertSame('

', - $this->parsedown->text('![](missing-image.jpg)')); - $this->assertSame('

', - $this->parsedown->text('![](/home-missing-image.jpg)')); - $this->assertSame('

', - $this->parsedown->text('![](/home-missing-image.jpg)')); - $this->assertSame('

', - $this->parsedown->text('![](https://getgrav-grav.netdna-ssl.com/user/pages/media/grav-logo.svg)')); - - } + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](/home-cache-image.jpg?cache)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](missing-image.jpg)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](/home-missing-image.jpg)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](/home-missing-image.jpg)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](https://getgrav-grav.netdna-ssl.com/user/pages/media/grav-logo.svg)') + ); + } public function testImagesSubDir() { $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](/home-cache-image.jpg?cache)')); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](cache-image.jpg?cache)')); - $this->assertSame('

', - $this->parsedown->text('![](missing-image.jpg)')); - $this->assertSame('

', - $this->parsedown->text('![](/home-missing-image.jpg)')); - + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](/home-cache-image.jpg?cache)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](cache-image.jpg?cache)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](missing-image.jpg)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](/home-missing-image.jpg)') + ); } public function testImagesAbsoluteUrls() @@ -131,16 +156,26 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](cache-image.jpg?cache)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](/home-cache-image.jpg?cache)')); - $this->assertSame('

', - $this->parsedown->text('![](missing-image.jpg)')); - $this->assertSame('

', - $this->parsedown->text('![](/home-missing-image.jpg)')); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](cache-image.jpg?cache)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](/home-cache-image.jpg?cache)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](missing-image.jpg)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](/home-missing-image.jpg)') + ); } public function testImagesSubDirAbsoluteUrls() @@ -148,36 +183,60 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](cache-image.jpg?cache)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)')); - $this->assertSame('

', - $this->parsedown->text('![](missing-image.jpg)')); - $this->assertSame('

', - $this->parsedown->text('![](/home-missing-image.jpg)')); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](cache-image.jpg?cache)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](missing-image.jpg)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](/home-missing-image.jpg)') + ); } public function testImagesAttributes() { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg "My Title")')); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg?classes=foo)')); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg?classes=foo,bar)')); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg?id=foo)')); - $this->assertSame('

Alt Text

', - $this->parsedown->text('![Alt Text](sample-image.jpg?id=foo)')); - $this->assertSame('

Alt Text

', - $this->parsedown->text('![Alt Text](sample-image.jpg?class=bar&id=foo)')); - $this->assertSame('

Alt Text

', - $this->parsedown->text('![Alt Text](sample-image.jpg?class=bar&id=foo "My Title")')); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg "My Title")') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg?classes=foo)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg?classes=foo,bar)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg?id=foo)') + ); + $this->assertSame( + '

Alt Text

', + $this->parsedown->text('![Alt Text](sample-image.jpg?id=foo)') + ); + $this->assertSame( + '

Alt Text

', + $this->parsedown->text('![Alt Text](sample-image.jpg?class=bar&id=foo)') + ); + $this->assertSame( + '

Alt Text

', + $this->parsedown->text('![Alt Text](sample-image.jpg?class=bar&id=foo "My Title")') + ); } @@ -199,24 +258,32 @@ class ParsedownTest extends \Codeception\TestCase\Test $excerpts = new Excerpts($page, $defaults); $this->parsedown = new Parsedown($excerpts); - $this->assertSame('

', - $this->parsedown->text('![](home-sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](home-cache-image.jpg?cache)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](home-cache-image.jpg?cropResize=200,200&foo)')); - $this->assertSame('

', - $this->parsedown->text('![](/home-missing-image.jpg)')); + $this->assertSame( + '

', + $this->parsedown->text('![](home-sample-image.jpg)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](home-cache-image.jpg?cache)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](home-cache-image.jpg?cropResize=200,200&foo)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](/home-missing-image.jpg)') + ); $this->config->set('system.languages.supported', ['fr','en']); unset($this->grav['language']); $this->grav['language'] = new Language($this->grav); $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init(); - $this->assertSame('

', - $this->parsedown->text('![](home-sample-image.jpg)')); - - + $this->assertSame( + '

', + $this->parsedown->text('![](home-sample-image.jpg)') + ); } public function testRootImagesSubDirAbsoluteUrls() @@ -224,16 +291,26 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

', - $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](cache-image.jpg?cache)')); - $this->assertRegexp('|

<\/p>|', - $this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)')); - $this->assertSame('

', - $this->parsedown->text('![](missing-image.jpg)')); - $this->assertSame('

', - $this->parsedown->text('![](/home-missing-image.jpg)')); + $this->assertSame( + '

', + $this->parsedown->text('![](sample-image.jpg)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](cache-image.jpg?cache)') + ); + $this->assertRegexp( + '|

<\/p>|', + $this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](missing-image.jpg)') + ); + $this->assertSame( + '

', + $this->parsedown->text('![](/home-missing-image.jpg)') + ); } public function testRootAbsoluteLinks() @@ -254,34 +331,54 @@ class ParsedownTest extends \Codeception\TestCase\Test $excerpts = new Excerpts($page, $defaults); $this->parsedown = new Parsedown($excerpts); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](item1-3)')); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](item1-3)') + ); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](../item2)')); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](../item2)') + ); - $this->assertSame('

With Query

', - $this->parsedown->text('[With Query](?foo=bar)')); - $this->assertSame('

With Param

', - $this->parsedown->text('[With Param](/foo:bar)')); - $this->assertSame('

With Anchor

', - $this->parsedown->text('[With Anchor](#foo)')); + $this->assertSame( + '

With Query

', + $this->parsedown->text('[With Query](?foo=bar)') + ); + $this->assertSame( + '

With Param

', + $this->parsedown->text('[With Param](/foo:bar)') + ); + $this->assertSame( + '

With Anchor

', + $this->parsedown->text('[With Anchor](#foo)') + ); $this->config->set('system.languages.supported', ['fr','en']); unset($this->grav['language']); $this->grav['language'] = new Language($this->grav); $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init(); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](../item2)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](item1-3)')); - $this->assertSame('

With Query

', - $this->parsedown->text('[With Query](?foo=bar)')); - $this->assertSame('

With Param

', - $this->parsedown->text('[With Param](/foo:bar)')); - $this->assertSame('

With Anchor

', - $this->parsedown->text('[With Anchor](#foo)')); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](../item2)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](item1-3)') + ); + $this->assertSame( + '

With Query

', + $this->parsedown->text('[With Query](?foo=bar)') + ); + $this->assertSame( + '

With Param

', + $this->parsedown->text('[With Param](/foo:bar)') + ); + $this->assertSame( + '

With Anchor

', + $this->parsedown->text('[With Anchor](#foo)') + ); } @@ -292,15 +389,22 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->grav['language'] = new Language($this->grav); $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init(); - $this->assertSame('

Current Anchor

', - $this->parsedown->text('[Current Anchor](#foo)')); - $this->assertSame('

Root Anchor

', - $this->parsedown->text('[Root Anchor](/#foo)')); - $this->assertSame('

Peer Anchor

', - $this->parsedown->text('[Peer Anchor](../item2-1#foo)')); - $this->assertSame('

Peer Anchor 2

', - $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')); - + $this->assertSame( + '

Current Anchor

', + $this->parsedown->text('[Current Anchor](#foo)') + ); + $this->assertSame( + '

Root Anchor

', + $this->parsedown->text('[Root Anchor](/#foo)') + ); + $this->assertSame( + '

Peer Anchor

', + $this->parsedown->text('[Peer Anchor](../item2-1#foo)') + ); + $this->assertSame( + '

Peer Anchor 2

', + $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)') + ); } public function testAnchorLinksLangAbsoluteUrls() @@ -311,36 +415,53 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->grav['language'] = new Language($this->grav); $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init(); - $this->assertSame('

Current Anchor

', - $this->parsedown->text('[Current Anchor](#foo)')); - $this->assertSame('

Peer Anchor

', - $this->parsedown->text('[Peer Anchor](../item2-1#foo)')); - $this->assertSame('

Peer Anchor 2

', - $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')); - $this->assertSame('

Root Anchor

', - $this->parsedown->text('[Root Anchor](/#foo)')); - + $this->assertSame( + '

Current Anchor

', + $this->parsedown->text('[Current Anchor](#foo)') + ); + $this->assertSame( + '

Peer Anchor

', + $this->parsedown->text('[Peer Anchor](../item2-1#foo)') + ); + $this->assertSame( + '

Peer Anchor 2

', + $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)') + ); + $this->assertSame( + '

Root Anchor

', + $this->parsedown->text('[Root Anchor](/#foo)') + ); } public function testExternalLinks() { - $this->assertSame('

cnn.com

', - $this->parsedown->text('[cnn.com](http://www.cnn.com)')); - $this->assertSame('

google.com

', - $this->parsedown->text('[google.com](https://www.google.com)')); - $this->assertSame('

complex url

', - $this->parsedown->text('[complex url](https://github.com/getgrav/grav/issues/new?title=[add-resource]%20New%20Plugin/Theme&body=Hello%20**There**)')); + $this->assertSame( + '

cnn.com

', + $this->parsedown->text('[cnn.com](http://www.cnn.com)') + ); + $this->assertSame( + '

google.com

', + $this->parsedown->text('[google.com](https://www.google.com)') + ); + $this->assertSame( + '

complex url

', + $this->parsedown->text('[complex url](https://github.com/getgrav/grav/issues/new?title=[add-resource]%20New%20Plugin/Theme&body=Hello%20**There**)') + ); } public function testExternalLinksSubDir() { $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

cnn.com

', - $this->parsedown->text('[cnn.com](http://www.cnn.com)')); - $this->assertSame('

google.com

', - $this->parsedown->text('[google.com](https://www.google.com)')); + $this->assertSame( + '

cnn.com

', + $this->parsedown->text('[cnn.com](http://www.cnn.com)') + ); + $this->assertSame( + '

google.com

', + $this->parsedown->text('[google.com](https://www.google.com)') + ); } public function testExternalLinksSubDirAbsoluteUrls() @@ -348,24 +469,36 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

cnn.com

', - $this->parsedown->text('[cnn.com](http://www.cnn.com)')); - $this->assertSame('

google.com

', - $this->parsedown->text('[google.com](https://www.google.com)')); + $this->assertSame( + '

cnn.com

', + $this->parsedown->text('[cnn.com](http://www.cnn.com)') + ); + $this->assertSame( + '

google.com

', + $this->parsedown->text('[google.com](https://www.google.com)') + ); } public function testAnchorLinksRelativeUrls() { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

Current Anchor

', - $this->parsedown->text('[Current Anchor](#foo)')); - $this->assertSame('

Root Anchor

', - $this->parsedown->text('[Root Anchor](/#foo)')); - $this->assertSame('

Peer Anchor

', - $this->parsedown->text('[Peer Anchor](../item2-1#foo)')); - $this->assertSame('

Peer Anchor 2

', - $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')); + $this->assertSame( + '

Current Anchor

', + $this->parsedown->text('[Current Anchor](#foo)') + ); + $this->assertSame( + '

Root Anchor

', + $this->parsedown->text('[Root Anchor](/#foo)') + ); + $this->assertSame( + '

Peer Anchor

', + $this->parsedown->text('[Peer Anchor](../item2-1#foo)') + ); + $this->assertSame( + '

Peer Anchor 2

', + $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)') + ); } public function testAnchorLinksAbsoluteUrls() @@ -373,14 +506,22 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

Current Anchor

', - $this->parsedown->text('[Current Anchor](#foo)')); - $this->assertSame('

Peer Anchor

', - $this->parsedown->text('[Peer Anchor](../item2-1#foo)')); - $this->assertSame('

Peer Anchor 2

', - $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')); - $this->assertSame('

Root Anchor

', - $this->parsedown->text('[Root Anchor](/#foo)')); + $this->assertSame( + '

Current Anchor

', + $this->parsedown->text('[Current Anchor](#foo)') + ); + $this->assertSame( + '

Peer Anchor

', + $this->parsedown->text('[Peer Anchor](../item2-1#foo)') + ); + $this->assertSame( + '

Peer Anchor 2

', + $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)') + ); + $this->assertSame( + '

Root Anchor

', + $this->parsedown->text('[Root Anchor](/#foo)') + ); } public function testAnchorLinksWithPortAbsoluteUrls() @@ -388,28 +529,44 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithURL('http://testing.dev:8080/item2/item2-2')->init(); - $this->assertSame('

Peer Anchor

', - $this->parsedown->text('[Peer Anchor](../item2-1#foo)')); - $this->assertSame('

Peer Anchor 2

', - $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')); - $this->assertSame('

Current Anchor

', - $this->parsedown->text('[Current Anchor](#foo)')); - $this->assertSame('

Root Anchor

', - $this->parsedown->text('[Root Anchor](/#foo)')); + $this->assertSame( + '

Peer Anchor

', + $this->parsedown->text('[Peer Anchor](../item2-1#foo)') + ); + $this->assertSame( + '

Peer Anchor 2

', + $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)') + ); + $this->assertSame( + '

Current Anchor

', + $this->parsedown->text('[Current Anchor](#foo)') + ); + $this->assertSame( + '

Root Anchor

', + $this->parsedown->text('[Root Anchor](/#foo)') + ); } public function testAnchorLinksSubDirRelativeUrls() { $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

Peer Anchor

', - $this->parsedown->text('[Peer Anchor](../item2-1#foo)')); - $this->assertSame('

Peer Anchor 2

', - $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')); - $this->assertSame('

Current Anchor

', - $this->parsedown->text('[Current Anchor](#foo)')); - $this->assertSame('

Root Anchor

', - $this->parsedown->text('[Root Anchor](/#foo)')); + $this->assertSame( + '

Peer Anchor

', + $this->parsedown->text('[Peer Anchor](../item2-1#foo)') + ); + $this->assertSame( + '

Peer Anchor 2

', + $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)') + ); + $this->assertSame( + '

Current Anchor

', + $this->parsedown->text('[Current Anchor](#foo)') + ); + $this->assertSame( + '

Root Anchor

', + $this->parsedown->text('[Root Anchor](/#foo)') + ); } public function testAnchorLinksSubDirAbsoluteUrls() @@ -417,40 +574,68 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

Peer Anchor

', - $this->parsedown->text('[Peer Anchor](../item2-1#foo)')); - $this->assertSame('

Peer Anchor 2

', - $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')); - $this->assertSame('

Current Anchor

', - $this->parsedown->text('[Current Anchor](#foo)')); - $this->assertSame('

Root Anchor

', - $this->parsedown->text('[Root Anchor](/#foo)')); + $this->assertSame( + '

Peer Anchor

', + $this->parsedown->text('[Peer Anchor](../item2-1#foo)') + ); + $this->assertSame( + '

Peer Anchor 2

', + $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)') + ); + $this->assertSame( + '

Current Anchor

', + $this->parsedown->text('[Current Anchor](#foo)') + ); + $this->assertSame( + '

Root Anchor

', + $this->parsedown->text('[Root Anchor](/#foo)') + ); } public function testSlugRelativeLinks() { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

Up to Root Level

', - $this->parsedown->text('[Up to Root Level](../..)')); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](../item2-1)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](item2-2-1)')); - $this->assertSame('

Up a Level

', - $this->parsedown->text('[Up a Level](..)')); - $this->assertSame('

Up and Down

', - $this->parsedown->text('[Up and Down](../../item3/item3-3)')); - $this->assertSame('

Down a Level with Query

', - $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)')); - $this->assertSame('

Up a Level with Query

', - $this->parsedown->text('[Up a Level with Query](../?foo=bar)')); - $this->assertSame('

Up and Down with Query

', - $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)')); - $this->assertSame('

Up and Down with Param

', - $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)')); - $this->assertSame('

Up and Down with Anchor

', - $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)')); + $this->assertSame( + '

Up to Root Level

', + $this->parsedown->text('[Up to Root Level](../..)') + ); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](../item2-1)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](item2-2-1)') + ); + $this->assertSame( + '

Up a Level

', + $this->parsedown->text('[Up a Level](..)') + ); + $this->assertSame( + '

Up and Down

', + $this->parsedown->text('[Up and Down](../../item3/item3-3)') + ); + $this->assertSame( + '

Down a Level with Query

', + $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)') + ); + $this->assertSame( + '

Up a Level with Query

', + $this->parsedown->text('[Up a Level with Query](../?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Query

', + $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Param

', + $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)') + ); + $this->assertSame( + '

Up and Down with Anchor

', + $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)') + ); } public function testSlugRelativeLinksAbsoluteUrls() @@ -458,52 +643,92 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](../item2-1)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](item2-2-1)')); - $this->assertSame('

Up a Level

', - $this->parsedown->text('[Up a Level](..)')); - $this->assertSame('

Up to Root Level

', - $this->parsedown->text('[Up to Root Level](../..)')); - $this->assertSame('

Up and Down

', - $this->parsedown->text('[Up and Down](../../item3/item3-3)')); - $this->assertSame('

Down a Level with Query

', - $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)')); - $this->assertSame('

Up a Level with Query

', - $this->parsedown->text('[Up a Level with Query](../?foo=bar)')); - $this->assertSame('

Up and Down with Query

', - $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)')); - $this->assertSame('

Up and Down with Param

', - $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)')); - $this->assertSame('

Up and Down with Anchor

', - $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)')); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](../item2-1)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](item2-2-1)') + ); + $this->assertSame( + '

Up a Level

', + $this->parsedown->text('[Up a Level](..)') + ); + $this->assertSame( + '

Up to Root Level

', + $this->parsedown->text('[Up to Root Level](../..)') + ); + $this->assertSame( + '

Up and Down

', + $this->parsedown->text('[Up and Down](../../item3/item3-3)') + ); + $this->assertSame( + '

Down a Level with Query

', + $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)') + ); + $this->assertSame( + '

Up a Level with Query

', + $this->parsedown->text('[Up a Level with Query](../?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Query

', + $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Param

', + $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)') + ); + $this->assertSame( + '

Up and Down with Anchor

', + $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)') + ); } public function testSlugRelativeLinksSubDir() { $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](../item2-1)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](item2-2-1)')); - $this->assertSame('

Up a Level

', - $this->parsedown->text('[Up a Level](..)')); - $this->assertSame('

Up to Root Level

', - $this->parsedown->text('[Up to Root Level](../..)')); - $this->assertSame('

Up and Down

', - $this->parsedown->text('[Up and Down](../../item3/item3-3)')); - $this->assertSame('

Down a Level with Query

', - $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)')); - $this->assertSame('

Up a Level with Query

', - $this->parsedown->text('[Up a Level with Query](../?foo=bar)')); - $this->assertSame('

Up and Down with Query

', - $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)')); - $this->assertSame('

Up and Down with Param

', - $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)')); - $this->assertSame('

Up and Down with Anchor

', - $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)')); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](../item2-1)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](item2-2-1)') + ); + $this->assertSame( + '

Up a Level

', + $this->parsedown->text('[Up a Level](..)') + ); + $this->assertSame( + '

Up to Root Level

', + $this->parsedown->text('[Up to Root Level](../..)') + ); + $this->assertSame( + '

Up and Down

', + $this->parsedown->text('[Up and Down](../../item3/item3-3)') + ); + $this->assertSame( + '

Down a Level with Query

', + $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)') + ); + $this->assertSame( + '

Up a Level with Query

', + $this->parsedown->text('[Up a Level with Query](../?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Query

', + $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Param

', + $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)') + ); + $this->assertSame( + '

Up and Down with Anchor

', + $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)') + ); } public function testSlugRelativeLinksSubDirAbsoluteUrls() @@ -511,26 +736,46 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](../item2-1)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](item2-2-1)')); - $this->assertSame('

Up a Level

', - $this->parsedown->text('[Up a Level](..)')); - $this->assertSame('

Up to Root Level

', - $this->parsedown->text('[Up to Root Level](../..)')); - $this->assertSame('

Up and Down

', - $this->parsedown->text('[Up and Down](../../item3/item3-3)')); - $this->assertSame('

Down a Level with Query

', - $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)')); - $this->assertSame('

Up a Level with Query

', - $this->parsedown->text('[Up a Level with Query](../?foo=bar)')); - $this->assertSame('

Up and Down with Query

', - $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)')); - $this->assertSame('

Up and Down with Param

', - $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)')); - $this->assertSame('

Up and Down with Anchor

', - $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)')); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](../item2-1)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](item2-2-1)') + ); + $this->assertSame( + '

Up a Level

', + $this->parsedown->text('[Up a Level](..)') + ); + $this->assertSame( + '

Up to Root Level

', + $this->parsedown->text('[Up to Root Level](../..)') + ); + $this->assertSame( + '

Up and Down

', + $this->parsedown->text('[Up and Down](../../item3/item3-3)') + ); + $this->assertSame( + '

Down a Level with Query

', + $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)') + ); + $this->assertSame( + '

Up a Level with Query

', + $this->parsedown->text('[Up a Level with Query](../?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Query

', + $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Param

', + $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)') + ); + $this->assertSame( + '

Up and Down with Anchor

', + $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)') + ); } @@ -538,20 +783,34 @@ class ParsedownTest extends \Codeception\TestCase\Test { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

Up and Down with Param

', - $this->parsedown->text('[Up and Down with Param](../../03.item3/03.item3-3/foo:bar)')); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](../01.item2-1)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](01.item2-2-1)')); - $this->assertSame('

Up and Down

', - $this->parsedown->text('[Up and Down](../../03.item3/03.item3-3)')); - $this->assertSame('

Down a Level with Query

', - $this->parsedown->text('[Down a Level with Query](01.item2-2-1?foo=bar)')); - $this->assertSame('

Up and Down with Query

', - $this->parsedown->text('[Up and Down with Query](../../03.item3/03.item3-3?foo=bar)')); - $this->assertSame('

Up and Down with Anchor

', - $this->parsedown->text('[Up and Down with Anchor](../../03.item3/03.item3-3#foo)')); + $this->assertSame( + '

Up and Down with Param

', + $this->parsedown->text('[Up and Down with Param](../../03.item3/03.item3-3/foo:bar)') + ); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](../01.item2-1)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](01.item2-2-1)') + ); + $this->assertSame( + '

Up and Down

', + $this->parsedown->text('[Up and Down](../../03.item3/03.item3-3)') + ); + $this->assertSame( + '

Down a Level with Query

', + $this->parsedown->text('[Down a Level with Query](01.item2-2-1?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Query

', + $this->parsedown->text('[Up and Down with Query](../../03.item3/03.item3-3?foo=bar)') + ); + $this->assertSame( + '

Up and Down with Anchor

', + $this->parsedown->text('[Up and Down with Anchor](../../03.item3/03.item3-3#foo)') + ); } @@ -559,40 +818,68 @@ class ParsedownTest extends \Codeception\TestCase\Test { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

Root

', - $this->parsedown->text('[Root](/)')); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](/item2/item2-1)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)')); - $this->assertSame('

Up a Level

', - $this->parsedown->text('[Up a Level](/item2)')); - $this->assertSame('

With Query

', - $this->parsedown->text('[With Query](/item2?foo=bar)')); - $this->assertSame('

With Param

', - $this->parsedown->text('[With Param](/item2/foo:bar)')); - $this->assertSame('

With Anchor

', - $this->parsedown->text('[With Anchor](/item2#foo)')); + $this->assertSame( + '

Root

', + $this->parsedown->text('[Root](/)') + ); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](/item2/item2-1)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)') + ); + $this->assertSame( + '

Up a Level

', + $this->parsedown->text('[Up a Level](/item2)') + ); + $this->assertSame( + '

With Query

', + $this->parsedown->text('[With Query](/item2?foo=bar)') + ); + $this->assertSame( + '

With Param

', + $this->parsedown->text('[With Param](/item2/foo:bar)') + ); + $this->assertSame( + '

With Anchor

', + $this->parsedown->text('[With Anchor](/item2#foo)') + ); } public function testDirectoryAbsoluteLinksSubDir() { $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

Root

', - $this->parsedown->text('[Root](/)')); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](/item2/item2-1)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)')); - $this->assertSame('

Up a Level

', - $this->parsedown->text('[Up a Level](/item2)')); - $this->assertSame('

With Query

', - $this->parsedown->text('[With Query](/item2?foo=bar)')); - $this->assertSame('

With Param

', - $this->parsedown->text('[With Param](/item2/foo:bar)')); - $this->assertSame('

With Anchor

', - $this->parsedown->text('[With Anchor](/item2#foo)')); + $this->assertSame( + '

Root

', + $this->parsedown->text('[Root](/)') + ); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](/item2/item2-1)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)') + ); + $this->assertSame( + '

Up a Level

', + $this->parsedown->text('[Up a Level](/item2)') + ); + $this->assertSame( + '

With Query

', + $this->parsedown->text('[With Query](/item2?foo=bar)') + ); + $this->assertSame( + '

With Param

', + $this->parsedown->text('[With Param](/item2/foo:bar)') + ); + $this->assertSame( + '

With Anchor

', + $this->parsedown->text('[With Anchor](/item2#foo)') + ); } public function testDirectoryAbsoluteLinksSubDirAbsoluteUrl() @@ -600,52 +887,86 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

Root

', - $this->parsedown->text('[Root](/)')); - $this->assertSame('

Peer Page

', - $this->parsedown->text('[Peer Page](/item2/item2-1)')); - $this->assertSame('

Down a Level

', - $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)')); - $this->assertSame('

Up a Level

', - $this->parsedown->text('[Up a Level](/item2)')); - $this->assertSame('

With Query

', - $this->parsedown->text('[With Query](/item2?foo=bar)')); - $this->assertSame('

With Param

', - $this->parsedown->text('[With Param](/item2/foo:bar)')); - $this->assertSame('

With Anchor

', - $this->parsedown->text('[With Anchor](/item2#foo)')); + $this->assertSame( + '

Root

', + $this->parsedown->text('[Root](/)') + ); + $this->assertSame( + '

Peer Page

', + $this->parsedown->text('[Peer Page](/item2/item2-1)') + ); + $this->assertSame( + '

Down a Level

', + $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)') + ); + $this->assertSame( + '

Up a Level

', + $this->parsedown->text('[Up a Level](/item2)') + ); + $this->assertSame( + '

With Query

', + $this->parsedown->text('[With Query](/item2?foo=bar)') + ); + $this->assertSame( + '

With Param

', + $this->parsedown->text('[With Param](/item2/foo:bar)') + ); + $this->assertSame( + '

With Anchor

', + $this->parsedown->text('[With Anchor](/item2#foo)') + ); } public function testSpecialProtocols() { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

mailto

', - $this->parsedown->text('[mailto](mailto:user@domain.com)')); - $this->assertSame('

xmpp

', - $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)')); - $this->assertSame('

tel

', - $this->parsedown->text('[tel](tel:123-555-12345)')); - $this->assertSame('

sms

', - $this->parsedown->text('[sms](sms:123-555-12345)')); - $this->assertSame('

ts.example.com

', - $this->parsedown->text('[ts.example.com](rdp://ts.example.com)')); + $this->assertSame( + '

mailto

', + $this->parsedown->text('[mailto](mailto:user@domain.com)') + ); + $this->assertSame( + '

xmpp

', + $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)') + ); + $this->assertSame( + '

tel

', + $this->parsedown->text('[tel](tel:123-555-12345)') + ); + $this->assertSame( + '

sms

', + $this->parsedown->text('[sms](sms:123-555-12345)') + ); + $this->assertSame( + '

ts.example.com

', + $this->parsedown->text('[ts.example.com](rdp://ts.example.com)') + ); } public function testSpecialProtocolsSubDir() { $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

mailto

', - $this->parsedown->text('[mailto](mailto:user@domain.com)')); - $this->assertSame('

xmpp

', - $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)')); - $this->assertSame('

tel

', - $this->parsedown->text('[tel](tel:123-555-12345)')); - $this->assertSame('

sms

', - $this->parsedown->text('[sms](sms:123-555-12345)')); - $this->assertSame('

ts.example.com

', - $this->parsedown->text('[ts.example.com](rdp://ts.example.com)')); + $this->assertSame( + '

mailto

', + $this->parsedown->text('[mailto](mailto:user@domain.com)') + ); + $this->assertSame( + '

xmpp

', + $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)') + ); + $this->assertSame( + '

tel

', + $this->parsedown->text('[tel](tel:123-555-12345)') + ); + $this->assertSame( + '

sms

', + $this->parsedown->text('[sms](sms:123-555-12345)') + ); + $this->assertSame( + '

ts.example.com

', + $this->parsedown->text('[ts.example.com](rdp://ts.example.com)') + ); } public function testSpecialProtocolsSubDirAbsoluteUrl() @@ -653,16 +974,26 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

mailto

', - $this->parsedown->text('[mailto](mailto:user@domain.com)')); - $this->assertSame('

xmpp

', - $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)')); - $this->assertSame('

tel

', - $this->parsedown->text('[tel](tel:123-555-12345)')); - $this->assertSame('

sms

', - $this->parsedown->text('[sms](sms:123-555-12345)')); - $this->assertSame('

ts.example.com

', - $this->parsedown->text('[ts.example.com](rdp://ts.example.com)')); + $this->assertSame( + '

mailto

', + $this->parsedown->text('[mailto](mailto:user@domain.com)') + ); + $this->assertSame( + '

xmpp

', + $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)') + ); + $this->assertSame( + '

tel

', + $this->parsedown->text('[tel](tel:123-555-12345)') + ); + $this->assertSame( + '

sms

', + $this->parsedown->text('[sms](sms:123-555-12345)') + ); + $this->assertSame( + '

ts.example.com

', + $this->parsedown->text('[ts.example.com](rdp://ts.example.com)') + ); } public function testReferenceLinks() @@ -671,64 +1002,98 @@ class ParsedownTest extends \Codeception\TestCase\Test $sample = '[relative link][r_relative] [r_relative]: ../item2-3#blah'; - $this->assertSame('

relative link

', - $this->parsedown->text($sample)); + $this->assertSame( + '

relative link

', + $this->parsedown->text($sample) + ); $sample = '[absolute link][r_absolute] [r_absolute]: /item3#blah'; - $this->assertSame('

absolute link

', - $this->parsedown->text($sample)); + $this->assertSame( + '

absolute link

', + $this->parsedown->text($sample) + ); $sample = '[external link][r_external] [r_external]: http://www.cnn.com'; - $this->assertSame('

external link

', - $this->parsedown->text($sample)); + $this->assertSame( + '

external link

', + $this->parsedown->text($sample) + ); } public function testAttributeLinks() { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

Anchor Class

', - $this->parsedown->text('[Anchor Class](?classes=button#something)')); - $this->assertSame('

Relative Class

', - $this->parsedown->text('[Relative Class](../item2-3?classes=button)')); - $this->assertSame('

Relative ID

', - $this->parsedown->text('[Relative ID](../item2-3?id=unique)')); - $this->assertSame('

External

', - $this->parsedown->text('[External](https://github.com/getgrav/grav?classes=button,big)')); - $this->assertSame('

Relative Noprocess

', - $this->parsedown->text('[Relative Noprocess](../item2-3?id=unique&noprocess)')); - $this->assertSame('

Relative Target

', - $this->parsedown->text('[Relative Target](../item2-3?target=_blank)')); - $this->assertSame('

Relative Rel

', - $this->parsedown->text('[Relative Rel](../item2-3?rel=nofollow)')); - $this->assertSame('

Relative Mixed

', - $this->parsedown->text('[Relative Mixed](../item2-3?foo=bar&baz=qux&rel=nofollow&class=button)')); + $this->assertSame( + '

Anchor Class

', + $this->parsedown->text('[Anchor Class](?classes=button#something)') + ); + $this->assertSame( + '

Relative Class

', + $this->parsedown->text('[Relative Class](../item2-3?classes=button)') + ); + $this->assertSame( + '

Relative ID

', + $this->parsedown->text('[Relative ID](../item2-3?id=unique)') + ); + $this->assertSame( + '

External

', + $this->parsedown->text('[External](https://github.com/getgrav/grav?classes=button,big)') + ); + $this->assertSame( + '

Relative Noprocess

', + $this->parsedown->text('[Relative Noprocess](../item2-3?id=unique&noprocess)') + ); + $this->assertSame( + '

Relative Target

', + $this->parsedown->text('[Relative Target](../item2-3?target=_blank)') + ); + $this->assertSame( + '

Relative Rel

', + $this->parsedown->text('[Relative Rel](../item2-3?rel=nofollow)') + ); + $this->assertSame( + '

Relative Mixed

', + $this->parsedown->text('[Relative Mixed](../item2-3?foo=bar&baz=qux&rel=nofollow&class=button)') + ); } public function testInvalidLinks() { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

Non Existent Page

', - $this->parsedown->text('[Non Existent Page](no-page)')); - $this->assertSame('

Existent File

', - $this->parsedown->text('[Existent File](existing-file.zip)')); - $this->assertSame('

Non Existent File

', - $this->parsedown->text('[Non Existent File](missing-file.zip)')); + $this->assertSame( + '

Non Existent Page

', + $this->parsedown->text('[Non Existent Page](no-page)') + ); + $this->assertSame( + '

Existent File

', + $this->parsedown->text('[Existent File](existing-file.zip)') + ); + $this->assertSame( + '

Non Existent File

', + $this->parsedown->text('[Non Existent File](missing-file.zip)') + ); } public function testInvalidLinksSubDir() { $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

Non Existent Page

', - $this->parsedown->text('[Non Existent Page](no-page)')); - $this->assertSame('

Existent File

', - $this->parsedown->text('[Existent File](existing-file.zip)')); - $this->assertSame('

Non Existent File

', - $this->parsedown->text('[Non Existent File](missing-file.zip)')); + $this->assertSame( + '

Non Existent Page

', + $this->parsedown->text('[Non Existent Page](no-page)') + ); + $this->assertSame( + '

Existent File

', + $this->parsedown->text('[Existent File](existing-file.zip)') + ); + $this->assertSame( + '

Non Existent File

', + $this->parsedown->text('[Non Existent File](missing-file.zip)') + ); } public function testInvalidLinksSubDirAbsoluteUrl() @@ -736,12 +1101,18 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

Non Existent Page

', - $this->parsedown->text('[Non Existent Page](no-page)')); - $this->assertSame('

Existent File

', - $this->parsedown->text('[Existent File](existing-file.zip)')); - $this->assertSame('

Non Existent File

', - $this->parsedown->text('[Non Existent File](missing-file.zip)')); + $this->assertSame( + '

Non Existent Page

', + $this->parsedown->text('[Non Existent Page](no-page)') + ); + $this->assertSame( + '

Existent File

', + $this->parsedown->text('[Existent File](existing-file.zip)') + ); + $this->assertSame( + '

Non Existent File

', + $this->parsedown->text('[Non Existent File](missing-file.zip)') + ); } @@ -754,5 +1125,4 @@ class ParsedownTest extends \Codeception\TestCase\Test { return preg_replace('/^\s*(.*)/', '', $string); } - } diff --git a/tests/unit/Grav/Common/Page/PagesTest.php b/tests/unit/Grav/Common/Page/PagesTest.php index 4de75fb42..b03a04a37 100644 --- a/tests/unit/Grav/Common/Page/PagesTest.php +++ b/tests/unit/Grav/Common/Page/PagesTest.php @@ -54,7 +54,7 @@ class PagesTest extends \Codeception\TestCase\Test public function testInstances() { $this->assertInternalType('array', $this->pages->instances()); - foreach($this->pages->instances() as $instance) { + foreach ($this->pages->instances() as $instance) { $this->assertInstanceOf(PageInterface::class, $instance); } } @@ -219,14 +219,13 @@ class PagesTest extends \Codeception\TestCase\Test public function testBlueprints() { - } public function testAll() { $this->assertInternalType('object', $this->pages->all()); $this->assertInternalType('array', $this->pages->all()->toArray()); - foreach($this->pages->all() as $page) { + foreach ($this->pages->all() as $page) { $this->assertInstanceOf(PageInterface::class, $page); } } @@ -241,47 +240,37 @@ class PagesTest extends \Codeception\TestCase\Test public function testGetTypes() { - } public function testTypes() { - } public function testModularTypes() { - } public function testPageTypes() { - } public function testAccessLevels() { - } public function testParents() { - } public function testParentsRawRoutes() { - } public function testGetHomeRoute() { - } public function testResetPages() { - } - } diff --git a/tests/unit/Grav/Common/Twig/TwigExtensionTest.php b/tests/unit/Grav/Common/Twig/TwigExtensionTest.php index 56181f994..9777fd91e 100644 --- a/tests/unit/Grav/Common/Twig/TwigExtensionTest.php +++ b/tests/unit/Grav/Common/Twig/TwigExtensionTest.php @@ -23,21 +23,21 @@ class TwigExtensionTest extends \Codeception\TestCase\Test public function testInflectorFilter() { - $this->assertSame('people', $this->twig_ext->inflectorFilter('plural', 'person')); - $this->assertSame('shoe', $this->twig_ext->inflectorFilter('singular', 'shoes')); - $this->assertSame('Welcome Page', $this->twig_ext->inflectorFilter('title', 'welcome page')); - $this->assertSame('SendEmail', $this->twig_ext->inflectorFilter('camel', 'send_email')); - $this->assertSame('camel_cased', $this->twig_ext->inflectorFilter('underscor', 'CamelCased')); - $this->assertSame('something-text', $this->twig_ext->inflectorFilter('hyphen', 'Something Text')); - $this->assertSame('Something text to read', $this->twig_ext->inflectorFilter('human', 'something_text_to_read')); - $this->assertSame(5, $this->twig_ext->inflectorFilter('month', 175)); - $this->assertSame('10th', $this->twig_ext->inflectorFilter('ordinal', 10)); + $this->assertSame('people', $this->twig_ext->inflectorFilter('plural', 'person')); + $this->assertSame('shoe', $this->twig_ext->inflectorFilter('singular', 'shoes')); + $this->assertSame('Welcome Page', $this->twig_ext->inflectorFilter('title', 'welcome page')); + $this->assertSame('SendEmail', $this->twig_ext->inflectorFilter('camel', 'send_email')); + $this->assertSame('camel_cased', $this->twig_ext->inflectorFilter('underscor', 'CamelCased')); + $this->assertSame('something-text', $this->twig_ext->inflectorFilter('hyphen', 'Something Text')); + $this->assertSame('Something text to read', $this->twig_ext->inflectorFilter('human', 'something_text_to_read')); + $this->assertSame(5, $this->twig_ext->inflectorFilter('month', 175)); + $this->assertSame('10th', $this->twig_ext->inflectorFilter('ordinal', 10)); } public function testMd5Filter() { - $this->assertSame(md5('grav'), $this->twig_ext->md5Filter('grav')); - $this->assertSame(md5('devs@getgrav.org'), $this->twig_ext->md5Filter('devs@getgrav.org')); + $this->assertSame(md5('grav'), $this->twig_ext->md5Filter('grav')); + $this->assertSame(md5('devs@getgrav.org'), $this->twig_ext->md5Filter('devs@getgrav.org')); } public function testKsortFilter() @@ -48,8 +48,8 @@ class TwigExtensionTest extends \Codeception\TestCase\Test public function testContainsFilter() { - $this->assertTrue($this->twig_ext->containsFilter('grav','grav')); - $this->assertTrue($this->twig_ext->containsFilter('So, I found this new cms, called grav, and it\'s pretty awesome guys','grav')); + $this->assertTrue($this->twig_ext->containsFilter('grav', 'grav')); + $this->assertTrue($this->twig_ext->containsFilter('So, I found this new cms, called grav, and it\'s pretty awesome guys', 'grav')); } public function testNicetimeFilter() @@ -73,121 +73,115 @@ class TwigExtensionTest extends \Codeception\TestCase\Test public function testRandomizeFilter() { $array = [1,2,3,4,5]; - $this->assertContains(2, $this->twig_ext->randomizeFilter($array)); - $this->assertSame($array, $this->twig_ext->randomizeFilter($array, 5)); - $this->assertSame($array[0], $this->twig_ext->randomizeFilter($array, 1)[0]); - $this->assertSame($array[3], $this->twig_ext->randomizeFilter($array, 4)[3]); - $this->assertSame($array[1], $this->twig_ext->randomizeFilter($array, 4)[1]); + $this->assertContains(2, $this->twig_ext->randomizeFilter($array)); + $this->assertSame($array, $this->twig_ext->randomizeFilter($array, 5)); + $this->assertSame($array[0], $this->twig_ext->randomizeFilter($array, 1)[0]); + $this->assertSame($array[3], $this->twig_ext->randomizeFilter($array, 4)[3]); + $this->assertSame($array[1], $this->twig_ext->randomizeFilter($array, 4)[1]); } public function testModulusFilter() { - $this->assertSame(3, $this->twig_ext->modulusFilter(3,4)); - $this->assertSame(1, $this->twig_ext->modulusFilter(11,2)); - $this->assertSame(0, $this->twig_ext->modulusFilter(10,2)); - $this->assertSame(2, $this->twig_ext->modulusFilter(10,4)); + $this->assertSame(3, $this->twig_ext->modulusFilter(3, 4)); + $this->assertSame(1, $this->twig_ext->modulusFilter(11, 2)); + $this->assertSame(0, $this->twig_ext->modulusFilter(10, 2)); + $this->assertSame(2, $this->twig_ext->modulusFilter(10, 4)); } public function testAbsoluteUrlFilter() { - } public function testMarkdownFilter() { - } public function testStartsWithFilter() { - } public function testEndsWithFilter() { - } public function testDefinedDefaultFilter() { - } public function testRtrimFilter() { - } public function testLtrimFilter() { - } public function testRepeatFunc() { - } public function testRegexReplace() { - } public function testUrlFunc() { - } public function testEvaluateFunc() { - } public function testDump() { - } public function testGistFunc() { - } public function testRandomStringFunc() { - } public function testPadFilter() { - } public function testArrayFunc() { - $this->assertSame('this is my text', - $this->twig_ext->regexReplace('

this is my text

', '(<\/?p>)', '')); - $this->assertSame('this is my text', - $this->twig_ext->regexReplace('

this is my text

', ['(

)','(<\/p>)'], ['',''])); + $this->assertSame( + 'this is my text', + $this->twig_ext->regexReplace('

this is my text

', '(<\/?p>)', '') + ); + $this->assertSame( + 'this is my text', + $this->twig_ext->regexReplace('

this is my text

', ['(

)','(<\/p>)'], ['','']) + ); } public function testArrayKeyValue() { - $this->assertSame(['meat' => 'steak'], - $this->twig_ext->arrayKeyValueFunc('meat', 'steak')); - $this->assertSame(['fruit' => 'apple', 'meat' => 'steak'], - $this->twig_ext->arrayKeyValueFunc('meat', 'steak', ['fruit' => 'apple'])); + $this->assertSame( + ['meat' => 'steak'], + $this->twig_ext->arrayKeyValueFunc('meat', 'steak') + ); + $this->assertSame( + ['fruit' => 'apple', 'meat' => 'steak'], + $this->twig_ext->arrayKeyValueFunc('meat', 'steak', ['fruit' => 'apple']) + ); } public function stringFunc() { - } public function testRangeFunc() { $hundred = []; - for($i = 0; $i <= 100; $i++) { $hundred[] = $i; } + for ($i = 0; $i <= 100; $i++) { + $hundred[] = $i; + } $this->assertSame([0], $this->twig_ext->rangeFunc(0, 0)); diff --git a/tests/unit/Grav/Common/UriTest.php b/tests/unit/Grav/Common/UriTest.php index 9977d6732..a30c01da8 100644 --- a/tests/unit/Grav/Common/UriTest.php +++ b/tests/unit/Grav/Common/UriTest.php @@ -914,7 +914,7 @@ class UriTest extends \Codeception\TestCase\Test $this->assertTrue($this->uri->validateHostname('goog.wine')); $this->assertTrue($this->uri->validateHostname('goog.localhost')); - $this->assertFalse($this->uri->validateHostname('localhost:80') ); + $this->assertFalse($this->uri->validateHostname('localhost:80')); $this->assertFalse($this->uri->validateHostname('http://localhost')); $this->assertFalse($this->uri->validateHostname('localhost!')); } @@ -1143,7 +1143,6 @@ class UriTest extends \Codeception\TestCase\Test public function testConvertUrl() { - } public function testAddNonce() diff --git a/tests/unit/Grav/Common/UtilsTest.php b/tests/unit/Grav/Common/UtilsTest.php index e7862427c..71ffb6f34 100644 --- a/tests/unit/Grav/Common/UtilsTest.php +++ b/tests/unit/Grav/Common/UtilsTest.php @@ -32,21 +32,27 @@ class UtilsTest extends \Codeception\TestCase\Test $this->assertTrue(Utils::startsWith('english', 'en')); $this->assertTrue(Utils::startsWith('English', 'En')); $this->assertTrue(Utils::startsWith('ENGLISH', 'EN')); - $this->assertTrue(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'EN')); + $this->assertTrue(Utils::startsWith( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'EN' + )); $this->assertFalse(Utils::startsWith('english', 'En')); $this->assertFalse(Utils::startsWith('English', 'EN')); $this->assertFalse(Utils::startsWith('ENGLISH', 'en')); - $this->assertFalse(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'e')); + $this->assertFalse(Utils::startsWith( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'e' + )); $this->assertTrue(Utils::startsWith('english', 'En', false)); $this->assertTrue(Utils::startsWith('English', 'EN', false)); $this->assertTrue(Utils::startsWith('ENGLISH', 'en', false)); - $this->assertTrue(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'e', false)); - + $this->assertTrue(Utils::startsWith( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'e', + false + )); } public function testEndsWith() @@ -54,20 +60,27 @@ class UtilsTest extends \Codeception\TestCase\Test $this->assertTrue(Utils::endsWith('english', 'sh')); $this->assertTrue(Utils::endsWith('EngliSh', 'Sh')); $this->assertTrue(Utils::endsWith('ENGLISH', 'SH')); - $this->assertTrue(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'ENGLISH')); + $this->assertTrue(Utils::endsWith( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'ENGLISH' + )); $this->assertFalse(Utils::endsWith('english', 'de')); $this->assertFalse(Utils::endsWith('EngliSh', 'sh')); $this->assertFalse(Utils::endsWith('ENGLISH', 'Sh')); - $this->assertFalse(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'DEUSTCH')); + $this->assertFalse(Utils::endsWith( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'DEUSTCH' + )); $this->assertTrue(Utils::endsWith('english', 'SH', false)); $this->assertTrue(Utils::endsWith('EngliSh', 'sH', false)); $this->assertTrue(Utils::endsWith('ENGLISH', 'sh', false)); - $this->assertTrue(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'english', false)); + $this->assertTrue(Utils::endsWith( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'english', + false + )); } public function testContains() @@ -75,20 +88,27 @@ class UtilsTest extends \Codeception\TestCase\Test $this->assertTrue(Utils::contains('english', 'nglis')); $this->assertTrue(Utils::contains('EngliSh', 'gliSh')); $this->assertTrue(Utils::contains('ENGLISH', 'ENGLI')); - $this->assertTrue(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'ENGLISH')); + $this->assertTrue(Utils::contains( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'ENGLISH' + )); $this->assertFalse(Utils::contains('EngliSh', 'GLI')); $this->assertFalse(Utils::contains('EngliSh', 'English')); $this->assertFalse(Utils::contains('ENGLISH', 'SCH')); - $this->assertFalse(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'DEUSTCH')); + $this->assertFalse(Utils::contains( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'DEUSTCH' + )); $this->assertTrue(Utils::contains('EngliSh', 'GLI', false)); $this->assertTrue(Utils::contains('EngliSh', 'ENGLISH', false)); $this->assertTrue(Utils::contains('ENGLISH', 'ish', false)); - $this->assertTrue(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', - 'english', false)); + $this->assertTrue(Utils::contains( + 'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'english', + false + )); } public function testSubstrToString() @@ -139,7 +159,6 @@ class UtilsTest extends \Codeception\TestCase\Test $this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate')); $this->assertEquals('This' . '…', Utils::truncate('This is a string to truncate', 3, true)); $this->assertEquals('', 6, true)); - } public function testSafeTruncate() @@ -159,7 +178,7 @@ class UtilsTest extends \Codeception\TestCase\Test $this->assertEquals('

This is a string to truncate

', Utils::truncateHtml('

This is a string to truncate

', 100)); $this->assertEquals('', Utils::truncateHtml('', 6)); $this->assertEquals('
  1. item 1 so...
', Utils::truncateHtml('
  1. item 1 something
  2. item 2 bold
', 10)); - $this->assertEquals("

This is a string.

\n

It splits two lines.

", Utils::truncateHtml("

This is a string.

\n

It splits two lines.

", 100)); + $this->assertEquals("

This is a string.

\n

It splits two lines.

", Utils::truncateHtml("

This is a string.

\n

It splits two lines.

", 100)); } public function testSafeTruncateHtml() @@ -182,7 +201,6 @@ class UtilsTest extends \Codeception\TestCase\Test public function download() { - } public function testGetMimeByExtension() @@ -340,7 +358,7 @@ class UtilsTest extends \Codeception\TestCase\Test 'test1' => 'test1Value' ]; - Utils::setDotNotation($array, 'test.test3.test4' , $new); + Utils::setDotNotation($array, 'test.test3.test4', $new); $this->assertEquals('test1Value', $array['test']['test3']['test4']['test1']); } @@ -512,7 +530,6 @@ class UtilsTest extends \Codeception\TestCase\Test public function testUrlWithStreams() { - } public function testUrlwithExternals() diff --git a/tests/unit/Grav/Console/Gpm/InstallCommandTest.php b/tests/unit/Grav/Console/Gpm/InstallCommandTest.php index e76843b35..da15594b1 100644 --- a/tests/unit/Grav/Console/Gpm/InstallCommandTest.php +++ b/tests/unit/Grav/Console/Gpm/InstallCommandTest.php @@ -19,10 +19,9 @@ class InstallCommandTest extends \Codeception\TestCase\Test { $this->grav = Fixtures::get('grav'); $this->installCommand = new InstallCommand(); - } protected function _after() { } -} \ No newline at end of file +} diff --git a/tests/unit/Grav/Framework/File/Formatter/CsvFormatterTest.php b/tests/unit/Grav/Framework/File/Formatter/CsvFormatterTest.php index 70a8c9e41..c2b321f25 100644 --- a/tests/unit/Grav/Framework/File/Formatter/CsvFormatterTest.php +++ b/tests/unit/Grav/Framework/File/Formatter/CsvFormatterTest.php @@ -17,7 +17,6 @@ class CsvFormatterTest extends \Codeception\TestCase\Test self::assertCount(3, $lines); self::assertEquals('col1,col2,col3', $lines[0]); - } /** @@ -43,5 +42,4 @@ class CsvFormatterTest extends \Codeception\TestCase\Test $encoded = (new CsvFormatter())->encode([]); self::assertEquals('', $encoded); } - } diff --git a/tests/unit/_bootstrap.php b/tests/unit/_bootstrap.php index f92ef0c09..5a76515f7 100644 --- a/tests/unit/_bootstrap.php +++ b/tests/unit/_bootstrap.php @@ -1,4 +1,3 @@