@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | protected function runDiscovery(): void |
37 | 37 | { |
38 | - $this->kernel->files()->each(function (SourceFile $file): void { |
|
38 | + $this->kernel->files()->each(function(SourceFile $file): void { |
|
39 | 39 | $this->addPage($this->parsePage($file->pageClass, $file->getPath())); |
40 | 40 | }); |
41 | 41 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /** @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass */ |
63 | 63 | public function getPages(?string $pageClass = null): PageCollection |
64 | 64 | { |
65 | - return $pageClass ? $this->filter(function (HydePage $page) use ($pageClass): bool { |
|
65 | + return $pageClass ? $this->filter(function(HydePage $page) use ($pageClass) : bool { |
|
66 | 66 | return $page instanceof $pageClass; |
67 | 67 | }) : $this; |
68 | 68 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | protected function runDiscovery(): void |
38 | 38 | { |
39 | - $this->kernel->pages()->each(function (HydePage $page): void { |
|
39 | + $this->kernel->pages()->each(function(HydePage $page): void { |
|
40 | 40 | $this->addRoute(new Route($page)); |
41 | 41 | }); |
42 | 42 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass */ |
57 | 57 | public function getRoutes(?string $pageClass = null): RouteCollection |
58 | 58 | { |
59 | - return $pageClass ? $this->filter(function (Route $route) use ($pageClass): bool { |
|
59 | + return $pageClass ? $this->filter(function(Route $route) use ($pageClass) : bool { |
|
60 | 60 | return $route->getPage() instanceof $pageClass; |
61 | 61 | }) : $this; |
62 | 62 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use Hyde\Foundation\HydeKernel; |
7 | 7 | use JetBrains\PhpStorm\Deprecated; |
8 | 8 | |
9 | - if (! function_exists('hyde')) { |
|
9 | + if (!function_exists('hyde')) { |
|
10 | 10 | /** |
11 | 11 | * Get the available HydeKernel instance. |
12 | 12 | */ |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | } |
17 | 17 | } |
18 | 18 | |
19 | - if (! function_exists('unslash')) { |
|
19 | + if (!function_exists('unslash')) { |
|
20 | 20 | /** |
21 | 21 | * Remove trailing slashes from the start and end of a string. |
22 | 22 | * |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | if (defined('HYDE_COMPATIBILITY_MODE') && HYDE_COMPATIBILITY_MODE === true) { |
35 | 35 | // Don't declare these functions when running in compatibility mode. |
36 | 36 | } else { |
37 | - if (! function_exists('asset')) { |
|
37 | + if (!function_exists('asset')) { |
|
38 | 38 | /** |
39 | 39 | * Get a relative link or URL to an asset in the media directory. |
40 | 40 | */ |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - if (! function_exists('route')) { |
|
47 | + if (!function_exists('route')) { |
|
48 | 48 | /** |
49 | 49 | * Get a page route instance by its key. Casting it to a string will return a relative link to the page. |
50 | 50 | */ |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - if (! function_exists('url')) { |
|
57 | + if (!function_exists('url')) { |
|
58 | 58 | /** |
59 | 59 | * Get a qualified URL to the supplied path if a base URL is set. |
60 | 60 | */ |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | use function trim; |
80 | 80 | use function md5; |
81 | 81 | |
82 | - if (! function_exists('\Hyde\hyde')) { |
|
82 | + if (!function_exists('\Hyde\hyde')) { |
|
83 | 83 | /** |
84 | 84 | * Get the available HydeKernel instance. |
85 | 85 | */ |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - if (! function_exists('\Hyde\unslash')) { |
|
92 | + if (!function_exists('\Hyde\unslash')) { |
|
93 | 93 | /** |
94 | 94 | * Remove trailing slashes from the start and end of a string. |
95 | 95 | */ |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if (! function_exists('\Hyde\unixsum')) { |
|
102 | + if (!function_exists('\Hyde\unixsum')) { |
|
103 | 103 | /** |
104 | 104 | * A EOL agnostic wrapper for calculating MD5 checksums. |
105 | 105 | * |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | - if (! function_exists('\Hyde\unixsum_file')) { |
|
114 | + if (!function_exists('\Hyde\unixsum_file')) { |
|
115 | 115 | /** |
116 | 116 | * Shorthand for {@see unixsum()} but loads a file. |
117 | 117 | */ |
@@ -121,63 +121,63 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - if (! function_exists('\Hyde\make_title')) { |
|
124 | + if (!function_exists('\Hyde\make_title')) { |
|
125 | 125 | function make_title(string $value): string |
126 | 126 | { |
127 | 127 | return hyde()->makeTitle($value); |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - if (! function_exists('\Hyde\normalize_newlines')) { |
|
131 | + if (!function_exists('\Hyde\normalize_newlines')) { |
|
132 | 132 | function normalize_newlines(string $string): string |
133 | 133 | { |
134 | 134 | return hyde()->normalizeNewlines($string); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - if (! function_exists('\Hyde\strip_newlines')) { |
|
138 | + if (!function_exists('\Hyde\strip_newlines')) { |
|
139 | 139 | function strip_newlines(string $string): string |
140 | 140 | { |
141 | 141 | return hyde()->stripNewlines($string); |
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - if (! function_exists('\Hyde\trim_slashes')) { |
|
145 | + if (!function_exists('\Hyde\trim_slashes')) { |
|
146 | 146 | function trim_slashes(string $string): string |
147 | 147 | { |
148 | 148 | return hyde()->trimSlashes($string); |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - if (! function_exists('\Hyde\evaluate_arrayable')) { |
|
152 | + if (!function_exists('\Hyde\evaluate_arrayable')) { |
|
153 | 153 | function evaluate_arrayable(array|Arrayable $array): array |
154 | 154 | { |
155 | 155 | return $array instanceof Arrayable ? $array->toArray() : $array; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - if (! function_exists('\Hyde\yaml_encode')) { |
|
159 | + if (!function_exists('\Hyde\yaml_encode')) { |
|
160 | 160 | function yaml_encode(mixed $input, int $inline = 2, int $indent = 4, int $flags = 0): string |
161 | 161 | { |
162 | 162 | return Yaml::dump($input instanceof Arrayable ? $input->toArray() : $input, $inline, $indent, $flags); |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - if (! function_exists('\Hyde\yaml_decode')) { |
|
166 | + if (!function_exists('\Hyde\yaml_decode')) { |
|
167 | 167 | function yaml_decode(string $input, int $flags = 0): mixed |
168 | 168 | { |
169 | 169 | return Yaml::parse($input, $flags); |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - if (! function_exists('\Hyde\path_join')) { |
|
173 | + if (!function_exists('\Hyde\path_join')) { |
|
174 | 174 | function path_join(string $directory, string ...$paths): string |
175 | 175 | { |
176 | 176 | return implode('/', array_merge([$directory], $paths)); |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - if (! function_exists('\Hyde\normalize_slashes')) { |
|
180 | + if (!function_exists('\Hyde\normalize_slashes')) { |
|
181 | 181 | function normalize_slashes(string $string): string |
182 | 182 | { |
183 | 183 | return str_replace('\\', '/', $string); |
@@ -84,7 +84,7 @@ |
||
84 | 84 | */ |
85 | 85 | private function formatArray(array $array): string |
86 | 86 | { |
87 | - $json = json_encode($array, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
87 | + $json = json_encode($array, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); |
|
88 | 88 | |
89 | 89 | // Transform JSON to PHP array syntax |
90 | 90 | $php = preg_replace('/^(\s*)\"(\w+)\":/m', '$1$2:', $json); // Remove quotes from keys |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | protected static function mockRender(): Render |
55 | 55 | { |
56 | - return tap(new Render(), function () { |
|
56 | + return tap(new Render(), function() { |
|
57 | 57 | Render::swap(new RenderData()); |
58 | 58 | }); |
59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | protected static function mockConfig(array $items = []): void |
67 | 67 | { |
68 | - Config::swap(tap(new Repository($items), function ($config) { |
|
68 | + Config::swap(tap(new Repository($items), function($config) { |
|
69 | 69 | app()->instance('config', $config); |
70 | 70 | })); |
71 | 71 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | /** @return \Illuminate\Filesystem\Filesystem&\Mockery\MockInterface */ |
74 | 74 | protected function mockFilesystem(array $methods = []): Filesystem |
75 | 75 | { |
76 | - return tap(Mockery::mock(Filesystem::class, $methods)->makePartial(), function ($filesystem) { |
|
76 | + return tap(Mockery::mock(Filesystem::class, $methods)->makePartial(), function($filesystem) { |
|
77 | 77 | app()->instance(Filesystem::class, $filesystem); |
78 | 78 | }); |
79 | 79 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /** @return \Illuminate\Filesystem\Filesystem&\Mockery\MockInterface */ |
82 | 82 | protected function mockFilesystemStrict(array $methods = []): Filesystem |
83 | 83 | { |
84 | - return tap(Mockery::mock(Filesystem::class, $methods), function ($filesystem) { |
|
84 | + return tap(Mockery::mock(Filesystem::class, $methods), function($filesystem) { |
|
85 | 85 | app()->instance(Filesystem::class, $filesystem); |
86 | 86 | }); |
87 | 87 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | #[Deprecated(reason: 'Use `asset` method instead.', replacement: '%class%->asset(%parameter0%)')] |
100 | 100 | public function mediaLink(string $destination, bool $validate = false): string |
101 | 101 | { |
102 | - if ($validate && ! file_exists($sourcePath = "{$this->kernel->getMediaDirectory()}/$destination")) { |
|
102 | + if ($validate && !file_exists($sourcePath = "{$this->kernel->getMediaDirectory()}/$destination")) { |
|
103 | 103 | throw new FileNotFoundException($sourcePath); |
104 | 104 | } |
105 | 105 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | { |
138 | 138 | $value = Config::getNullableString('hyde.url'); |
139 | 139 | |
140 | - return ! blank($value) && $value !== 'http://localhost'; |
|
140 | + return !blank($value) && $value !== 'http://localhost'; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | // Since v1.7.0, we return the relative path even if the base URL is not set, |
163 | 163 | // as this is more likely to be the desired behavior the user's expecting. |
164 | - if (! blank($path)) { |
|
164 | + if (!blank($path)) { |
|
165 | 165 | return $path; |
166 | 166 | } |
167 | 167 |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $element = $this->query($selector); |
69 | 69 | |
70 | - if (! $element) { |
|
70 | + if (!$element) { |
|
71 | 71 | PHPUnit::fail("No element matching the selector '$selector' was found in the HTML."); |
72 | 72 | } |
73 | 73 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $nodes = new Collection(); |
152 | 152 | $dom = new DOMDocument(); |
153 | 153 | |
154 | - $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET | LIBXML_NOXMLDECL | LIBXML_COMPACT | LIBXML_PARSEHUGE); |
|
154 | + $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NOERROR|LIBXML_NOWARNING|LIBXML_NONET|LIBXML_NOXMLDECL|LIBXML_COMPACT|LIBXML_PARSEHUGE); |
|
155 | 155 | |
156 | 156 | // Initiate recursive parsing from the root element |
157 | 157 | foreach ($dom->childNodes as $childNode) { |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public static function handle(string $directory, array|string|false $matchExtensions = false, bool $recursive = false): Collection |
23 | 23 | { |
24 | - if (! Filesystem::isDirectory($directory)) { |
|
24 | + if (!Filesystem::isDirectory($directory)) { |
|
25 | 25 | return collect(); |
26 | 26 | } |
27 | 27 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $finder->name(static::buildFileExtensionPattern((array) $matchExtensions)); |
36 | 36 | } |
37 | 37 | |
38 | - return collect($finder)->map(function (SplFileInfo $file): string { |
|
38 | + return collect($finder)->map(function(SplFileInfo $file): string { |
|
39 | 39 | return Hyde::pathToRelative($file->getPathname()); |
40 | 40 | })->sort()->values(); |
41 | 41 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** @param array<string> $extensions */ |
52 | 52 | private static function expandCommaSeparatedValues(array $extensions): array |
53 | 53 | { |
54 | - return array_merge(...array_map(function (string $item): array { |
|
54 | + return array_merge(...array_map(function(string $item): array { |
|
55 | 55 | return array_map(fn (string $item): string => trim($item), explode(',', $item)); |
56 | 56 | }, $extensions)); |
57 | 57 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | /** @param array<string> $extensions */ |
60 | 60 | private static function normalizeExtensionForRegexPattern(array $extensions): string |
61 | 61 | { |
62 | - return implode('|', array_map(function (string $extension): string { |
|
62 | + return implode('|', array_map(function(string $extension): string { |
|
63 | 63 | return preg_quote(ltrim($extension, '.'), '/'); |
64 | 64 | }, $extensions)); |
65 | 65 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | // Scan the source directory, and directories therein, for files that match the model's file extension. |
62 | 62 | foreach (Filesystem::findFiles($pageClass::sourceDirectory(), $pageClass::fileExtension(), true) as $path) { |
63 | - if (! str_starts_with(basename((string) $path), '_')) { |
|
63 | + if (!str_starts_with(basename((string) $path), '_')) { |
|
64 | 64 | $this->addFile(SourceFile::make($path, $pageClass)); |
65 | 65 | } |
66 | 66 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | /** @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass */ |
75 | 75 | public function getFiles(?string $pageClass = null): FileCollection |
76 | 76 | { |
77 | - return $pageClass ? $this->filter(function (SourceFile $file) use ($pageClass): bool { |
|
77 | + return $pageClass ? $this->filter(function(SourceFile $file) use ($pageClass) : bool { |
|
78 | 78 | return $file->pageClass === $pageClass; |
79 | 79 | }) : $this; |
80 | 80 | } |