@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | private function isNonDocumentationPageInHiddenSubdirectory(): bool |
129 | 129 | { |
130 | - return ! $this->isInstanceOf(DocumentationPage::class) |
|
130 | + return !$this->isInstanceOf(DocumentationPage::class) |
|
131 | 131 | && $this->pageIsInSubdirectory() |
132 | 132 | && $this->getSubdirectoryConfiguration() === 'hidden' |
133 | 133 | && basename($this->identifier) !== 'index'; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $pageKey = $this->{$pageKeyName}; |
189 | 189 | |
190 | 190 | // Check if the config entry is a flat array or a keyed array. |
191 | - if (! array_key_exists($pageKey, $config)) { |
|
191 | + if (!array_key_exists($pageKey, $config)) { |
|
192 | 192 | // Adding an offset makes so that pages with a front matter priority, or |
193 | 193 | // explicit keyed priority selection that is lower can be shown first. |
194 | 194 | // This is all to make it easier to mix ways of adding priorities. |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | protected function invert(?bool $value): ?bool |
238 | 238 | { |
239 | - return $value === null ? null : ! $value; |
|
239 | + return $value === null ? null : !$value; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | protected function offset(?int $value, int $offset): ?int |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $lineLength = max(array_map('strlen', array_map('strip_tags', $lines))); |
42 | 42 | |
43 | - $lines = array_map(function (string $line) use ($lineLength): string { |
|
43 | + $lines = array_map(function(string $line) use ($lineLength): string { |
|
44 | 44 | return sprintf(' │ <span class="text-white">%s</span>%s│', |
45 | 45 | $line, str_repeat(' ', ($lineLength - strlen(strip_tags($line))) + 1) |
46 | 46 | ); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | public function getFormatter(): Closure |
58 | 58 | { |
59 | - return function (string $type, string $line): void { |
|
59 | + return function(string $type, string $line): void { |
|
60 | 60 | $this->handleOutput($line); |
61 | 61 | }; |
62 | 62 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | protected function handleOutput(string $buffer): void |
71 | 71 | { |
72 | - str($buffer)->trim()->explode("\n")->each(function (string $line): void { |
|
72 | + str($buffer)->trim()->explode("\n")->each(function(string $line): void { |
|
73 | 73 | $this->renderLine($this->formatLineForOutput($line)); |
74 | 74 | }); |
75 | 75 | } |
@@ -62,12 +62,12 @@ |
||
62 | 62 | |
63 | 63 | protected function authorizePostRequest(): void |
64 | 64 | { |
65 | - if (! $this->isRequestMadeFromLocalhost()) { |
|
65 | + if (!$this->isRequestMadeFromLocalhost()) { |
|
66 | 66 | throw new HttpException(403, "Refusing to serve request from address {$_SERVER['REMOTE_ADDR']} (must be on localhost)"); |
67 | 67 | } |
68 | 68 | |
69 | 69 | if ($this->withSession) { |
70 | - if (! $this->validateCSRFToken($this->request->get('_token'))) { |
|
70 | + if (!$this->validateCSRFToken($this->request->get('_token'))) { |
|
71 | 71 | throw new HttpException(403, 'Invalid CSRF token'); |
72 | 72 | } |
73 | 73 | } |
@@ -46,11 +46,11 @@ |
||
46 | 46 | |
47 | 47 | $page = Hyde::pages()->getPage($pagePath); |
48 | 48 | |
49 | - if (! $page instanceof BaseMarkdownPage) { |
|
49 | + if (!$page instanceof BaseMarkdownPage) { |
|
50 | 50 | $this->abort(400, 'Page is not a markdown page'); |
51 | 51 | } |
52 | 52 | |
53 | - if (! $force && hash('sha256', $page->markdown()->body()) !== $currentContentHash) { |
|
53 | + if (!$force && hash('sha256', $page->markdown()->body()) !== $currentContentHash) { |
|
54 | 54 | $this->abort(409, 'Content has changed in another window'); |
55 | 55 | } |
56 | 56 |
@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | public const NAVIGATION_SCHEMA = [ |
16 | 16 | 'label' => 'string', // The text to display |
17 | - 'priority' => 'int', // Order is also supported |
|
18 | - 'hidden' => 'bool', // Visible is also supported (but obviously invert the value) |
|
17 | + 'priority' => 'int', // Order is also supported |
|
18 | + 'hidden' => 'bool', // Visible is also supported (but obviously invert the value) |
|
19 | 19 | 'group' => 'string', // Category is also supported |
20 | 20 | ]; |
21 | 21 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $path = static::path($filename); |
55 | 55 | |
56 | - if (! file_exists($path)) { |
|
56 | + if (!file_exists($path)) { |
|
57 | 57 | return $default; |
58 | 58 | } |
59 | 59 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | $path = static::path(basename($filename, '.html').'.html'); |
73 | 73 | |
74 | - if (! file_exists($path)) { |
|
74 | + if (!file_exists($path)) { |
|
75 | 75 | return $default === null ? null : $default; |
76 | 76 | } |
77 | 77 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $path = static::path(basename($filename, '.md').'.md'); |
91 | 91 | |
92 | - if (! file_exists($path)) { |
|
92 | + if (!file_exists($path)) { |
|
93 | 93 | return $default === null ? null : Markdown::render($default); |
94 | 94 | } |
95 | 95 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $path = static::path(basename($filename, '.blade.php').'.blade.php'); |
109 | 109 | |
110 | - if (! file_exists($path)) { |
|
110 | + if (!file_exists($path)) { |
|
111 | 111 | return $default === null ? null : Blade::render($default); |
112 | 112 | } |
113 | 113 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $element = $this->query($selector); |
68 | 68 | |
69 | - if (! $element) { |
|
69 | + if (!$element) { |
|
70 | 70 | PHPUnit::fail("No element matching the selector '$selector' was found in the HTML."); |
71 | 71 | } |
72 | 72 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | $matchingNodes = collect(); |
84 | 84 | |
85 | - $traverse = function (TestableHtmlElement $node) use (&$traverse, $class, &$matchingNodes): void { |
|
85 | + $traverse = function(TestableHtmlElement $node) use (&$traverse, $class, &$matchingNodes): void { |
|
86 | 86 | if (in_array($class, $node->classes, true)) { |
87 | 87 | $matchingNodes->push($node); |
88 | 88 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $nodes = new Collection(); |
155 | 155 | $dom = new DOMDocument(); |
156 | 156 | |
157 | - $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET | LIBXML_NOXMLDECL | LIBXML_COMPACT | LIBXML_PARSEHUGE); |
|
157 | + $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NOERROR|LIBXML_NOWARNING|LIBXML_NONET|LIBXML_NOXMLDECL|LIBXML_COMPACT|LIBXML_PARSEHUGE); |
|
158 | 158 | |
159 | 159 | // Initiate recursive parsing from the root element |
160 | 160 | foreach ($dom->childNodes as $childNode) { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | $structure = ''; |
39 | 39 | |
40 | - $this->nodes->each(function (TestableHtmlElement $node) use (&$structure): void { |
|
40 | + $this->nodes->each(function(TestableHtmlElement $node) use (&$structure): void { |
|
41 | 41 | $structure .= $this->createStructureMapEntry($node, 0); |
42 | 42 | }); |
43 | 43 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $text = ''; |
50 | 50 | |
51 | - $this->nodes->each(function (TestableHtmlElement $node) use (&$text): void { |
|
51 | + $this->nodes->each(function(TestableHtmlElement $node) use (&$text): void { |
|
52 | 52 | $text .= $this->createTextMapEntry($node); |
53 | 53 | }); |
54 | 54 | |
@@ -89,17 +89,17 @@ discard block |
||
89 | 89 | |
90 | 90 | protected function createStructureMapEntry(TestableHtmlElement $node, int $level): string |
91 | 91 | { |
92 | - return sprintf("\n%s%s%s", str_repeat(' ', $level), $node->tag, $node->nodes->map(function (TestableHtmlElement $node) use ($level): string { |
|
92 | + return sprintf("\n%s%s%s", str_repeat(' ', $level), $node->tag, $node->nodes->map(function(TestableHtmlElement $node) use ($level): string { |
|
93 | 93 | return $this->createStructureMapEntry($node, $level + 1); |
94 | 94 | })->implode('')); |
95 | 95 | } |
96 | 96 | |
97 | 97 | protected function createTextMapEntry(TestableHtmlElement $node, bool $addNewline = true): string |
98 | 98 | { |
99 | - $childEntries = $node->nodes->map(function (TestableHtmlElement $node): string { |
|
99 | + $childEntries = $node->nodes->map(function(TestableHtmlElement $node): string { |
|
100 | 100 | $isInline = in_array($node->tag, ['a', 'abbr', 'acronym', 'b', 'bdo', 'big', 'br', 'button', 'cite', 'code', 'dfn', 'em', 'i', 'img', 'input', 'kbd', 'label', 'map', 'object', 'q', 'samp', 'script', 'select', 'small', 'span', 'strong', 'sub', 'sup', 'textarea', 'time', 'tt', 'var']); |
101 | 101 | |
102 | - return $this->createTextMapEntry($node, ! $isInline); |
|
102 | + return $this->createTextMapEntry($node, !$isInline); |
|
103 | 103 | })->implode(''); |
104 | 104 | |
105 | 105 | return sprintf('%s%s%s', $addNewline ? "\n" : ' ', $node->text, $childEntries); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | $html .= '<h2>Abstract Syntax Tree Node Inspection</h2>'; |
113 | 113 | $openAllButton = '<script>function openAll() {document.querySelectorAll(\'details\').forEach((el) => el.open = true);}</script><a href="javascript:openAll();" onclick="this.remove();">Open all</a>'; |
114 | - $html .= sprintf("\n<details open><summary><strong>Document</strong> <small>$openAllButton</small></summary>\n<ul>%s</ul></details>\n", $this->nodes->map(function (TestableHtmlElement $node): string { |
|
114 | + $html .= sprintf("\n<details open><summary><strong>Document</strong> <small>$openAllButton</small></summary>\n<ul>%s</ul></details>\n", $this->nodes->map(function(TestableHtmlElement $node): string { |
|
115 | 115 | return $this->createDumpNodeMapEntry($node); |
116 | 116 | })->implode('')); |
117 | 117 | |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | { |
131 | 131 | $data = $node->toArray(); |
132 | 132 | |
133 | - $list = sprintf("\n <ul class=\"node\">\n%s </ul>\n", implode('', array_map(function (string|iterable $value, string $key): string { |
|
133 | + $list = sprintf("\n <ul class=\"node\">\n%s </ul>\n", implode('', array_map(function(string|iterable $value, string $key): string { |
|
134 | 134 | if ($value instanceof Collection) { |
135 | 135 | if ($value->isEmpty()) { |
136 | 136 | return sprintf(" <li><strong>%s</strong>: <span>None</span></li>\n", ucfirst($key)); |
137 | 137 | } |
138 | 138 | |
139 | - return sprintf(" <li><strong>%s</strong>: <ul>%s</ul></li>\n", ucfirst($key), $value->map(function (TestableHtmlElement $node): string { |
|
139 | + return sprintf(" <li><strong>%s</strong>: <ul>%s</ul></li>\n", ucfirst($key), $value->map(function(TestableHtmlElement $node): string { |
|
140 | 140 | return $this->createDumpNodeMapEntry($node); |
141 | 141 | })->implode('')); |
142 | 142 | } |
143 | 143 | |
144 | 144 | if (is_array($value)) { |
145 | - if (! is_numeric(array_key_first($value))) { |
|
146 | - $value = array_map(function (string $value, string $key): string { |
|
145 | + if (!is_numeric(array_key_first($value))) { |
|
146 | + $value = array_map(function(string $value, string $key): string { |
|
147 | 147 | return sprintf('%s: %s', $key, str_contains($value, ' ') ? sprintf('"%s"', $value) : $value); |
148 | 148 | }, $value, array_keys($value)); |
149 | 149 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | public function check_documentation_site_has_an_index_page(Result $result): Result |
78 | 78 | { |
79 | - if (! Features::hasDocumentationPages()) { |
|
79 | + if (!Features::hasDocumentationPages()) { |
|
80 | 80 | return $result->skip('Does documentation site have an index page?') |
81 | 81 | ->withTip('Skipped because: The documentation page feature is disabled in config'); |
82 | 82 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | public function check_a_torchlight_api_token_is_set(Result $result): Result |
124 | 124 | { |
125 | - if (! Features::enabled(Feature::Torchlight)) { |
|
125 | + if (!Features::enabled(Feature::Torchlight)) { |
|
126 | 126 | return $result->skip('Check a Torchlight API token is set') |
127 | 127 | ->withTip('Torchlight is an API for code syntax highlighting. You can enable it in the Hyde config.'); |
128 | 128 | } |