Completed
Push — chore/php-8-migration ( 83422f )
by Vladimir
09:57
created
src/Document/BasePageView.php 1 patch
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
55 55
 
56 56
         $instance->evaluateFrontMatter([], $complexVariables);
57 57
 
58
-        if ($instance->hasExpandedFrontMatter()) {
58
+        if ($instance->hasExpandedFrontMatter())
59
+        {
59 60
             return new RepeaterPageView($filePath);
60 61
         }
61 62
 
@@ -74,7 +75,8 @@  discard block
 block discarded – undo
74 75
      */
75 76
     public static function createVirtual($frontMatter, $body): StaticPageView
76 77
     {
77
-        if (vfsStreamWrapper::getRoot() == null) {
78
+        if (vfsStreamWrapper::getRoot() == null)
79
+        {
78 80
             vfsStream::setup();
79 81
         }
80 82
 
@@ -108,12 +110,16 @@  discard block
 block discarded – undo
108 110
 
109 111
         $contentItemBody = fs::getInternalResource('redirect.html.twig');
110 112
 
111
-        try {
112
-            if (!empty($redirectTemplate)) {
113
+        try
114
+        {
115
+            if (!empty($redirectTemplate))
116
+            {
113 117
                 $redirectView = new File($redirectTemplate);
114 118
                 $contentItemBody = $redirectView->getContents();
115 119
             }
116
-        } catch (Exception $e) {
120
+        }
121
+        catch (Exception $e)
122
+        {
117 123
             trigger_error($e->getMessage(), E_USER_WARNING);
118 124
         }
119 125
 
Please login to merge, or discard this patch.
src/Document/ContentItem.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,10 +34,12 @@  discard block
 block discarded – undo
34 34
     {
35 35
         $fm = $this->getFrontMatter();
36 36
 
37
-        if (isset($fm['redirect_from'])) {
37
+        if (isset($fm['redirect_from']))
38
+        {
38 39
             $redirects = $fm['redirect_from'];
39 40
 
40
-            if (!is_array($redirects)) {
41
+            if (!is_array($redirects))
42
+            {
41 43
                 $redirects = [$redirects];
42 44
             }
43 45
 
@@ -54,10 +56,12 @@  discard block
 block discarded – undo
54 56
      */
55 57
     public function getContent(): string
56 58
     {
57
-        if (!$this->bodyContentEvaluated) {
59
+        if (!$this->bodyContentEvaluated)
60
+        {
58 61
             $this->bodyContent = $this->parseTemplateLanguage($this->bodyContent);
59 62
 
60
-            if ($this->markupEngine) {
63
+            if ($this->markupEngine)
64
+            {
61 65
                 $this->bodyContent = $this->markupEngine->parse($this->bodyContent, $this);
62 66
             }
63 67
 
Please login to merge, or discard this patch.
src/Filesystem/File.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,13 +62,15 @@
 block discarded – undo
62 62
      */
63 63
     public function getContents(): string
64 64
     {
65
-        if (!$this->exists()) {
65
+        if (!$this->exists())
66
+        {
66 67
             throw $this->buildNotFoundException();
67 68
         }
68 69
 
69 70
         $content = file_get_contents($this->getAbsolutePath());
70 71
 
71
-        if ($content === false) {
72
+        if ($content === false)
73
+        {
72 74
             $error = error_get_last();
73 75
 
74 76
             throw new RuntimeException($error['message']);
Please login to merge, or discard this patch.
src/Filesystem/FileExplorer.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     /**
123 123
      * Get the current File object.
124 124
      */
125
-    public function current(): File|Folder
125
+    public function current(): File | Folder
126 126
     {
127 127
         /** @var SplFileInfo $current */
128 128
         $current = parent::current();
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     /**
139 139
      * {@inheritdoc}
140 140
      */
141
-    public function getChildren(): FileExplorer|RecursiveFilterIterator|null
141
+    public function getChildren(): FileExplorer | RecursiveFilterIterator | null
142 142
     {
143 143
         $explorer = new self(
144 144
             $this->getInnerIterator()->getChildren(),
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      *
199 199
      * @deprecated use `FileExplorer::createFromDefinition()` instead
200 200
      */
201
-    public static function create(string|Folder $folder, array $includes = [], array $excludes = [], ?int $flags = null): FileExplorer
201
+    public static function create(string | Folder $folder, array $includes = [], array $excludes = [], ?int $flags = null): FileExplorer
202 202
     {
203 203
         $folder = fs::realpath($folder);
204 204
         $iterator = new RecursiveDirectoryIterator((string)$folder, RecursiveDirectoryIterator::SKIP_DOTS);
Please login to merge, or discard this patch.
Braces   +25 added lines, -12 removed lines patch added patch discarded remove patch
@@ -103,12 +103,15 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function accept(): bool
105 105
     {
106
-        if (!empty($this->matchers)) {
107
-            foreach ($this->matchers as $matcher) {
106
+        if (!empty($this->matchers))
107
+        {
108
+            foreach ($this->matchers as $matcher)
109
+            {
108 110
                 $result = call_user_func($matcher, $this->current());
109 111
 
110 112
                 // If any custom matchers return false, let's exit immediately
111
-                if ($result === false) {
113
+                if ($result === false)
114
+                {
112 115
                     return false;
113 116
                 }
114 117
             }
@@ -128,7 +131,8 @@  discard block
 block discarded – undo
128 131
         $current = parent::current();
129 132
         $path = new FilesystemPath($current->getPathname());
130 133
 
131
-        if ($current->isDir()) {
134
+        if ($current->isDir())
135
+        {
132 136
             return new Folder($path);
133 137
         }
134 138
 
@@ -147,7 +151,8 @@  discard block
 block discarded – undo
147 151
             $this->flags
148 152
         );
149 153
 
150
-        foreach ($this->matchers as $matcher) {
154
+        foreach ($this->matchers as $matcher)
155
+        {
151 156
             $explorer->addMatcher($matcher);
152 157
         }
153 158
 
@@ -167,18 +172,22 @@  discard block
 block discarded – undo
167 172
      */
168 173
     public function matchesPattern(string $filePath): bool
169 174
     {
170
-        if (self::strpos_array($filePath, $this->includes)) {
175
+        if (self::strpos_array($filePath, $this->includes))
176
+        {
171 177
             return true;
172 178
         }
173
-        if (($this->flags & self::INCLUDE_ONLY_FILES) && !$this->current()->isDir()) {
179
+        if (($this->flags & self::INCLUDE_ONLY_FILES) && !$this->current()->isDir())
180
+        {
174 181
             return false;
175 182
         }
176
-        if (($this->flags & self::IGNORE_DIRECTORIES) && $this->current()->isDir()) {
183
+        if (($this->flags & self::IGNORE_DIRECTORIES) && $this->current()->isDir())
184
+        {
177 185
             return false;
178 186
         }
179 187
 
180 188
         if (!($this->flags & self::ALLOW_DOT_FILES)
181
-            && preg_match('#(^|\\\\|\/)\..+(\\\\|\/|$)#', $filePath) === 1) {
189
+            && preg_match('#(^|\\\\|\/)\..+(\\\\|\/|$)#', $filePath) === 1)
190
+        {
182 191
             return false;
183 192
         }
184 193
 
@@ -218,12 +227,16 @@  discard block
 block discarded – undo
218 227
      */
219 228
     private static function strpos_array(string $haystack, array $needle): bool
220 229
     {
221
-        foreach ($needle as $query) {
222
-            if ($query[0] === '/' && $query[strlen($query) - 1] === '/' && preg_match($query, $haystack) === 1) {
230
+        foreach ($needle as $query)
231
+        {
232
+            if ($query[0] === '/' && $query[strlen($query) - 1] === '/' && preg_match($query, $haystack) === 1)
233
+            {
223 234
                 return true;
224 235
             }
225 236
 
226
-            if (str_contains($haystack, $query)) { // stop on first true result
237
+            if (str_contains($haystack, $query))
238
+            {
239
+// stop on first true result
227 240
                 return true;
228 241
             }
229 242
         }
Please login to merge, or discard this patch.
src/Filesystem/FilesystemPath.php 1 patch
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,7 +39,8 @@  discard block
 block discarded – undo
39 39
         $this->isWindows = $dirSep === '\\';
40 40
         $this->isVFS = fs::isVFS($filePath);
41 41
 
42
-        if ($this->isWindows) {
42
+        if ($this->isWindows)
43
+        {
43 44
             $filePath = $this->unixifyPath($filePath);
44 45
         }
45 46
 
@@ -58,7 +59,8 @@  discard block
 block discarded – undo
58 59
      */
59 60
     public function appendToPath($append): self
60 61
     {
61
-        if ($this->isFile(false)) {
62
+        if ($this->isFile(false))
63
+        {
62 64
             throw new InvalidArgumentException("Appending to a file's path is not possible");
63 65
         }
64 66
 
@@ -86,7 +88,8 @@  discard block
 block discarded – undo
86 88
      */
87 89
     public function getAbsolutePath(): string
88 90
     {
89
-        if (!$this->isVFS && $this->isWindows) {
91
+        if (!$this->isVFS && $this->isWindows)
92
+        {
90 93
             return str_replace('/', '\\', $this->absolutePath);
91 94
         }
92 95
 
@@ -112,7 +115,8 @@  discard block
 block discarded – undo
112 115
     {
113 116
         $absPath = $this->absolutePath;
114 117
 
115
-        if ($checkExistence) {
118
+        if ($checkExistence)
119
+        {
116 120
             return file_exists($absPath) && is_dir($absPath);
117 121
         }
118 122
 
@@ -130,7 +134,8 @@  discard block
 block discarded – undo
130 134
     {
131 135
         $absPath = $this->absolutePath;
132 136
 
133
-        if ($checkExistence) {
137
+        if ($checkExistence)
138
+        {
134 139
             return file_exists($absPath) && is_file($absPath);
135 140
         }
136 141
 
@@ -147,8 +152,10 @@  discard block
 block discarded – undo
147 152
     {
148 153
         $paths = [];
149 154
 
150
-        foreach (func_get_args() as $arg) {
151
-            if ($arg !== '') {
155
+        foreach (func_get_args() as $arg)
156
+        {
157
+            if ($arg !== '')
158
+            {
152 159
                 $paths[] = $arg;
153 160
             }
154 161
         }
Please login to merge, or discard this patch.
src/Filesystem/WritableFolder.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
         $this->frozen = false;
30 30
         $this->folder = new FilesystemPath($folderPath);
31 31
 
32
-        if (!$this->folder->isDir()) {
32
+        if (!$this->folder->isDir())
33
+        {
33 34
             throw new FileNotFoundException(sprintf('The folder could not be found: %s', $folderPath));
34 35
         }
35 36
     }
@@ -76,11 +77,13 @@  discard block
 block discarded – undo
76 77
      */
77 78
     public function setTargetDirectory($folderName): void
78 79
     {
79
-        if ($this->isFrozen()) {
80
+        if ($this->isFrozen())
81
+        {
80 82
             throw new Exception('A frozen folder object cannot be modified.');
81 83
         }
82 84
 
83
-        if ($folderName === null || empty($folderName)) {
85
+        if ($folderName === null || empty($folderName))
86
+        {
84 87
             return;
85 88
         }
86 89
 
@@ -115,7 +118,8 @@  discard block
 block discarded – undo
115 118
         $targetFile = $this->folder->generatePath($relativePath);
116 119
         $targetFolderPath = $targetFile->getParentDirectory();
117 120
 
118
-        if (!file_exists($targetFolderPath)) {
121
+        if (!file_exists($targetFolderPath))
122
+        {
119 123
             mkdir($targetFolderPath, 0755, true);
120 124
         }
121 125
 
Please login to merge, or discard this patch.
src/Filesystem/FilesystemLoader.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@
 block discarded – undo
25 25
 
26 26
     public static function __callStatic($name, $arguments)
27 27
     {
28
-        if (self::$fs === null) {
28
+        if (self::$fs === null)
29
+        {
29 30
             self::$fs = new Filesystem();
30 31
         }
31 32
 
Please login to merge, or discard this patch.
src/Filesystem/FileExplorerMatcher.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,9 +20,11 @@
 block discarded – undo
20 20
      */
21 21
     public static function modifiedAfter(DateTime $time): Closure
22 22
     {
23
-        return function ($file) use ($time) {
23
+        return function ($file) use ($time)
24
+        {
24 25
             /** @var File|Folder $file */
25
-            if ($file instanceof Folder) {
26
+            if ($file instanceof Folder)
27
+            {
26 28
                 return true;
27 29
             }
28 30
 
Please login to merge, or discard this patch.
src/Filesystem/BaseFilesystemItem.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      *
25 25
      * @throws FileNotFoundException
26 26
      */
27
-    public function __construct(protected string|FilesystemPath $rawPath)
27
+    public function __construct(protected string | FilesystemPath $rawPath)
28 28
     {
29 29
         $realPath = fs::realpath($rawPath);
30 30
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,8 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $realPath = fs::realpath($rawPath);
30 30
 
31
-        if ($realPath === false) {
31
+        if ($realPath === false)
32
+        {
32 33
             throw $this->buildNotFoundException();
33 34
         }
34 35
 
@@ -112,11 +113,13 @@  discard block
 block discarded – undo
112 113
      */
113 114
     protected function isSafeToRead(): void
114 115
     {
115
-        if (fs::isVFS($this->getAbsolutePath())) {
116
+        if (fs::isVFS($this->getAbsolutePath()))
117
+        {
116 118
             return;
117 119
         }
118 120
 
119
-        if (!str_starts_with($this->getAbsolutePath(), (string)Service::getWorkingDirectory())) {
121
+        if (!str_starts_with($this->getAbsolutePath(), (string)Service::getWorkingDirectory()))
122
+        {
120 123
             throw $this->buildNotFoundException();
121 124
         }
122 125
     }
Please login to merge, or discard this patch.