@@ -65,16 +65,16 @@ |
||
| 65 | 65 | public static function openBrowser(string $url): void |
| 66 | 66 | { |
| 67 | 67 | if (self::isWindows()) { |
| 68 | - passthru('start "web" explorer "' . $url . '"'); |
|
| 68 | + passthru('start "web" explorer "'.$url.'"'); |
|
| 69 | 69 | |
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | 72 | passthru('which xdg-open', $linux); |
| 73 | 73 | passthru('which open', $osx); |
| 74 | 74 | if (0 === $linux) { |
| 75 | - passthru('xdg-open ' . $url); |
|
| 75 | + passthru('xdg-open '.$url); |
|
| 76 | 76 | } elseif (0 === $osx) { |
| 77 | - passthru('open ' . $url); |
|
| 77 | + passthru('open '.$url); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $this->options = array_merge([ |
| 140 | 140 | 'drafts' => false, // build drafts or not |
| 141 | 141 | 'dry-run' => false, // if dry-run is true, generated files are not saved |
| 142 | - 'page' => '', // specific page to build |
|
| 142 | + 'page' => '', // specific page to build |
|
| 143 | 143 | ], $options); |
| 144 | 144 | |
| 145 | 145 | // process each step |
@@ -367,9 +367,9 @@ discard block |
||
| 367 | 367 | public static function getVersion(): string |
| 368 | 368 | { |
| 369 | 369 | if (!isset(self::$version)) { |
| 370 | - $filePath = __DIR__ . '/../VERSION'; |
|
| 370 | + $filePath = __DIR__.'/../VERSION'; |
|
| 371 | 371 | if (Plateform::isPhar()) { |
| 372 | - $filePath = Plateform::getPharPath() . '/VERSION'; |
|
| 372 | + $filePath = Plateform::getPharPath().'/VERSION'; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | try { |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | $this->getLogger()->error('The "baseurl" configuration key is required in production (e.g.: "baseurl: https://example.com/").'); |
| 400 | 400 | } |
| 401 | 401 | // default language |
| 402 | - if (!preg_match('/^' . Config::LANG_CODE_PATTERN . '$/', (string) $this->config->get('language'))) { |
|
| 402 | + if (!preg_match('/^'.Config::LANG_CODE_PATTERN.'$/', (string) $this->config->get('language'))) { |
|
| 403 | 403 | throw new RuntimeException(\sprintf('The configured default language code "%s" is not valid (e.g.: "language: fr-FR").', $this->config->get('language'))); |
| 404 | 404 | } |
| 405 | 405 | // locales |
| 406 | 406 | foreach ((array) $this->config->get('languages') as $lang) { |
| 407 | - if (!preg_match('/^' . Config::LANG_LOCALE_PATTERN . '$/', $lang['locale'])) { |
|
| 407 | + if (!preg_match('/^'.Config::LANG_LOCALE_PATTERN.'$/', $lang['locale'])) { |
|
| 408 | 408 | throw new RuntimeException(\sprintf('The configured language locale "%s" is not valid (e.g.: "locale: fr_FR").', $lang['locale'])); |
| 409 | 409 | } |
| 410 | 410 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * Overrides configuration with environment variables. |
| 69 | 69 | */ |
| 70 | 70 | $data = $this->getData(); |
| 71 | - $applyEnv = function ($array) use ($data) { |
|
| 71 | + $applyEnv = function($array) use ($data) { |
|
| 72 | 72 | $iterator = new \RecursiveIteratorIterator( |
| 73 | 73 | new \RecursiveArrayIterator($array), |
| 74 | 74 | \RecursiveIteratorIterator::SELF_FIRST |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $path[] = $iterator->getSubIterator($depth)->key(); |
| 81 | 81 | } |
| 82 | 82 | $sPath = implode('_', $path); |
| 83 | - if ($getEnv = getenv('CECIL_' . strtoupper($sPath))) { |
|
| 83 | + if ($getEnv = getenv('CECIL_'.strtoupper($sPath))) { |
|
| 84 | 84 | $data->set(str_replace('_', '.', strtolower($sPath)), $this->castSetValue($getEnv)); |
| 85 | 85 | } |
| 86 | 86 | $iterator->next(); |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | throw new RuntimeException(\sprintf('The default language "%s" is not listed in "languages" key configuration.', $this->getLanguageDefault())); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - $languages = array_filter($languages, function ($language) { |
|
| 510 | + $languages = array_filter($languages, function($language) { |
|
| 511 | 511 | return !(isset($language['enabled']) && $language['enabled'] === false); |
| 512 | 512 | }); |
| 513 | 513 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | $page404 = '404.html'; |
| 75 | 75 | |
| 76 | 76 | if ($language['code'] !== $this->config->getLanguageDefault()) { |
| 77 | - $suffix = '.' . $language['code']; |
|
| 78 | - $page404 = $language['code'] . '/404.html'; |
|
| 77 | + $suffix = '.'.$language['code']; |
|
| 78 | + $page404 = $language['code'].'/404.html'; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | foreach ($menusConfig as $menuConfig => $entry) { |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | protected function collectPages(): void |
| 148 | 148 | { |
| 149 | - $filteredPages = $this->builder->getPages()->filter(function (Page $page) { |
|
| 149 | + $filteredPages = $this->builder->getPages()->filter(function(Page $page) { |
|
| 150 | 150 | return $page->hasVariable('menu') |
| 151 | 151 | && $page->getVariable('published') |
| 152 | 152 | && in_array($page->getVariable('language', $this->config->getLanguageDefault()), array_column($this->config->getLanguages(), 'code')); |
@@ -63,8 +63,8 @@ |
||
| 63 | 63 | $files = Finder::create() |
| 64 | 64 | ->files() |
| 65 | 65 | ->in($this->builder->getConfig()->getOutputPath()) |
| 66 | - ->name('/\.(' . implode('|', $extensions) . ')$/') |
|
| 67 | - ->notName('/\.min\.(' . implode('|', $extensions) . ')$/') |
|
| 66 | + ->name('/\.('.implode('|', $extensions).')$/') |
|
| 67 | + ->notName('/\.min\.('.implode('|', $extensions).')$/') |
|
| 68 | 68 | ->sortByName(true); |
| 69 | 69 | $max = count($files); |
| 70 | 70 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $files = Finder::create() |
| 55 | 55 | ->files() |
| 56 | 56 | ->in($this->builder->getConfig()->getDataPath()) |
| 57 | - ->name('/\.(' . implode('|', (array) $this->builder->getConfig()->get('data.ext')) . ')$/') |
|
| 57 | + ->name('/\.('.implode('|', (array) $this->builder->getConfig()->get('data.ext')).')$/') |
|
| 58 | 58 | ->sortByName(true); |
| 59 | 59 | $total = count($files); |
| 60 | 60 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | foreach ($files as $file) { |
| 76 | 76 | $count++; |
| 77 | 77 | set_error_handler( |
| 78 | - function ($severity, $message, $file, $line) { |
|
| 78 | + function($severity, $message, $file, $line) { |
|
| 79 | 79 | throw new \ErrorException($message, 0, $severity, $file, $line, null); |
| 80 | 80 | } |
| 81 | 81 | ); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $basename = $file->getBasename('.' . $file->getExtension()); |
|
| 103 | + $basename = $file->getBasename('.'.$file->getExtension()); |
|
| 104 | 104 | $subpath = \Cecil\Util\File::getFS()->makePathRelative( |
| 105 | 105 | $file->getPath(), |
| 106 | 106 | $this->builder->getConfig()->getDataPath() |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | $staticFiles[$count]['date'] = (new \DateTime())->setTimestamp($file->getCTime()); |
| 71 | 71 | $staticFiles[$count]['updated'] = (new \DateTime())->setTimestamp($file->getMTime()); |
| 72 | 72 | $staticFiles[$count]['name'] = $file->getBasename(); |
| 73 | - $staticFiles[$count]['basename'] = $file->getBasename('.' . $file->getExtension()); |
|
| 73 | + $staticFiles[$count]['basename'] = $file->getBasename('.'.$file->getExtension()); |
|
| 74 | 74 | $staticFiles[$count]['ext'] = $file->getExtension(); |
| 75 | 75 | $count++; |
| 76 | 76 | |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | /** @var Collection $pages */ |
| 67 | 67 | $pages = $this->builder->getPages() |
| 68 | 68 | // published only |
| 69 | - ->filter(function (Page $page) { |
|
| 69 | + ->filter(function(Page $page) { |
|
| 70 | 70 | return (bool) $page->getVariable('published'); |
| 71 | 71 | }) |
| 72 | 72 | // enrichs some variables |
| 73 | - ->map(function (Page $page) { |
|
| 73 | + ->map(function(Page $page) { |
|
| 74 | 74 | $formats = $this->getOutputFormats($page); |
| 75 | 75 | // output formats |
| 76 | 76 | $page->setVariable('output', $formats); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | // renders with Twig |
| 126 | 126 | try { |
| 127 | 127 | $deprecations = []; |
| 128 | - set_error_handler(function ($type, $msg) use (&$deprecations) { |
|
| 128 | + set_error_handler(function($type, $msg) use (&$deprecations) { |
|
| 129 | 129 | if (E_USER_DEPRECATED === $type) { |
| 130 | 130 | $deprecations[] = $msg; |
| 131 | 131 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | // ```yaml |
| 236 | 236 | // page: [html, json] |
| 237 | 237 | // ``` |
| 238 | - $formats = $this->config->get('output.pagetypeformats.' . $page->getType()); |
|
| 238 | + $formats = $this->config->get('output.pagetypeformats.'.$page->getType()); |
|
| 239 | 239 | if (empty($formats)) { |
| 240 | 240 | throw new RuntimeException('Configuration key "pagetypeformats" can\'t be empty.'); |
| 241 | 241 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | protected function getTranslations(Page $refPage): \Cecil\Collection\Page\Collection |
| 275 | 275 | { |
| 276 | - $pages = $this->builder->getPages()->filter(function (Page $page) use ($refPage) { |
|
| 276 | + $pages = $this->builder->getPages()->filter(function(Page $page) use ($refPage) { |
|
| 277 | 277 | return $page->getId() !== $refPage->getId() |
| 278 | 278 | && $page->getVariable('langref') == $refPage->getVariable('langref') |
| 279 | 279 | && $page->getType() == $refPage->getType() |
@@ -294,15 +294,15 @@ discard block |
||
| 294 | 294 | // add generator meta tag |
| 295 | 295 | if (!preg_match('/<meta name="generator".*/i', $output)) { |
| 296 | 296 | $meta = \sprintf('<meta name="generator" content="Cecil %s" />', Builder::getVersion()); |
| 297 | - $output = preg_replace_callback('/([[:blank:]]*)(<\/head>)/i', function ($matches) use ($meta) { |
|
| 298 | - return str_repeat($matches[1] ?: ' ', 2) . $meta . "\n" . $matches[1] . $matches[2]; |
|
| 297 | + $output = preg_replace_callback('/([[:blank:]]*)(<\/head>)/i', function($matches) use ($meta) { |
|
| 298 | + return str_repeat($matches[1] ?: ' ', 2).$meta."\n".$matches[1].$matches[2]; |
|
| 299 | 299 | }, $output); |
| 300 | 300 | } |
| 301 | 301 | // replace excerpt or break tag by HTML anchor |
| 302 | 302 | // https://regex101.com/r/Xl7d5I/3 |
| 303 | 303 | $pattern = '(.*)(<!--[[:blank:]]?(excerpt|break)[[:blank:]]?-->)(.*)'; |
| 304 | 304 | $replacement = '$1<span id="more"></span>$4'; |
| 305 | - $excerpt = preg_replace('/' . $pattern . '/is', $replacement, $output, 1); |
|
| 305 | + $excerpt = preg_replace('/'.$pattern.'/is', $replacement, $output, 1); |
|
| 306 | 306 | $output = $excerpt ?? $output; |
| 307 | 307 | } |
| 308 | 308 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | //'/href="([A-Za-z0-9_\.\-\/]+)\.md(\#[A-Za-z0-9\-]+)?"/is', |
| 313 | 313 | // https://regex101.com/r/ycWMe4/1 |
| 314 | 314 | '/href="(\/|)([A-Za-z0-9_\.\-\/]+)\.md(\#[A-Za-z0-9\-]+)?"/is', |
| 315 | - function ($matches) use ($page) { |
|
| 315 | + function($matches) use ($page) { |
|
| 316 | 316 | // section spage |
| 317 | 317 | $hrefPattern = 'href="../%s/%s"'; |
| 318 | 318 | // root page |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function process(): void |
| 59 | 59 | { |
| 60 | - $namePattern = '/\.(' . implode('|', (array) $this->builder->getConfig()->get('pages.ext')) . ')$/'; |
|
| 60 | + $namePattern = '/\.('.implode('|', (array) $this->builder->getConfig()->get('pages.ext')).')$/'; |
|
| 61 | 61 | $content = Finder::create() |
| 62 | 62 | ->files() |
| 63 | 63 | ->in($this->builder->getConfig()->getPagesPath()) |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $this->builder->getLogger()->error(sprintf('File "%s" doesn\'t exist.', $this->page)); |
| 81 | 81 | } |
| 82 | 82 | $content->path('.')->path(dirname($this->page)); |
| 83 | - $content->name('/index\.(' . implode('|', (array) $this->builder->getConfig()->get('pages.ext')) . ')$/'); |
|
| 83 | + $content->name('/index\.('.implode('|', (array) $this->builder->getConfig()->get('pages.ext')).')$/'); |
|
| 84 | 84 | $namePattern = basename($this->page); |
| 85 | 85 | } |
| 86 | 86 | $content->name($namePattern); |