Completed
Push — chore/php-8-migration ( 0b97e4...588942 )
by Vladimir
09:24
created
src/Templating/Twig/Extension/WordWrapFilter.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,10 @@
 block discarded – undo
30 30
         $pieces = mb_split((string)$separator, (string)$value);
31 31
         mb_regex_encoding($previous);
32 32
 
33
-        foreach ($pieces as $piece) {
34
-            while (!$preserve && mb_strlen((string)$piece, $env->getCharset()) > $length) {
33
+        foreach ($pieces as $piece)
34
+        {
35
+            while (!$preserve && mb_strlen((string)$piece, $env->getCharset()) > $length)
36
+            {
35 37
                 $sentences[] = mb_substr((string)$piece, 0, $length, $env->getCharset());
36 38
                 $piece = mb_substr((string)$piece, $length, 2048, $env->getCharset());
37 39
             }
Please login to merge, or discard this patch.
src/Templating/Twig/Extension/GroupByFilter.php 1 patch
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,16 +16,21 @@
 block discarded – undo
16 16
     {
17 17
         $arr = [];
18 18
 
19
-        foreach ($array as $key => $item) {
19
+        foreach ($array as $key => $item)
20
+        {
20 21
             $groupBy = __::get($item, $sortKey);
21 22
 
22
-            if ($groupBy === null) {
23
+            if ($groupBy === null)
24
+            {
23 25
                 continue;
24 26
             }
25 27
 
26
-            if (is_bool($groupBy)) {
28
+            if (is_bool($groupBy))
29
+            {
27 30
                 $groupBy = $groupBy ? 'true' : 'false';
28
-            } elseif (!is_scalar($groupBy)) {
31
+            }
32
+            elseif (!is_scalar($groupBy))
33
+            {
29 34
                 trigger_error('You cannot group by a non-scalar value', E_USER_WARNING);
30 35
 
31 36
                 continue;
Please login to merge, or discard this patch.
src/Templating/Twig/Extension/TruncateFilter.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,10 +22,13 @@
 block discarded – undo
22 22
 {
23 23
     public function __invoke(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...')
24 24
     {
25
-        if (mb_strlen((string)$value, $env->getCharset()) > $length) {
26
-            if ($preserve) {
25
+        if (mb_strlen((string)$value, $env->getCharset()) > $length)
26
+        {
27
+            if ($preserve)
28
+            {
27 29
                 // If breakpoint is on the last word, return the value without separator.
28
-                if (($breakpoint = mb_strpos((string)$value, ' ', $length, $env->getCharset())) === false) {
30
+                if (($breakpoint = mb_strpos((string)$value, ' ', $length, $env->getCharset())) === false)
31
+                {
29 32
                     return $value;
30 33
                 }
31 34
 
Please login to merge, or discard this patch.
src/Templating/Twig/Extension/BaseUrlFunction.php 1 patch
Braces   +25 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function __invoke(Environment $env, $assetPath, $absolute = false, $params = []): string
23 23
     {
24
-        if ($this->isExternalUrl($assetPath)) {
24
+        if ($this->isExternalUrl($assetPath))
25
+        {
25 26
             return $assetPath;
26 27
         }
27 28
 
@@ -46,11 +47,13 @@  discard block
 block discarded – undo
46 47
     {
47 48
         $url = '/';
48 49
 
49
-        if (!$absolute) {
50
+        if (!$absolute)
51
+        {
50 52
             return $url;
51 53
         }
52 54
 
53
-        if (isset($this->site['url'])) {
55
+        if (isset($this->site['url']))
56
+        {
54 57
             $url = $this->site['url'];
55 58
         }
56 59
 
@@ -61,9 +64,12 @@  discard block
 block discarded – undo
61 64
     {
62 65
         $base = '';
63 66
 
64
-        if (isset($this->site['baseurl'])) {
67
+        if (isset($this->site['baseurl']))
68
+        {
65 69
             $base = $this->site['baseurl'];
66
-        } elseif (isset($this->site['base'])) {
70
+        }
71
+        elseif (isset($this->site['base']))
72
+        {
67 73
             $base = $this->site['base'];
68 74
         }
69 75
 
@@ -72,16 +78,20 @@  discard block
 block discarded – undo
72 78
 
73 79
     private function guessAssetPath($assetPath, $params): string
74 80
     {
75
-        if ($assetPath instanceof JailedDocument && $assetPath->_coreInstanceOf(RepeaterPageView::class)) {
81
+        if ($assetPath instanceof JailedDocument && $assetPath->_coreInstanceOf(RepeaterPageView::class))
82
+        {
76 83
             return ($link = $assetPath->_getPermalinkWhere($params)) ? $link : '/';
77 84
         }
78
-        if (is_array($assetPath) || ($assetPath instanceof ArrayAccess)) {
85
+        if (is_array($assetPath) || ($assetPath instanceof ArrayAccess))
86
+        {
79 87
             return $assetPath['permalink'] ?? '/';
80 88
         }
81
-        if (is_null($assetPath)) {
89
+        if (is_null($assetPath))
90
+        {
82 91
             return '/';
83 92
         }
84
-        if ($assetPath instanceof SplFileInfo) {
93
+        if ($assetPath instanceof SplFileInfo)
94
+        {
85 95
             return str_replace(Service::getWorkingDirectory(), '', $assetPath);
86 96
         }
87 97
 
@@ -99,7 +109,8 @@  discard block
 block discarded – undo
99 109
      */
100 110
     private function isExternalUrl(mixed $str): bool
101 111
     {
102
-        if (!is_string($str)) {
112
+        if (!is_string($str))
113
+        {
103 114
             return false;
104 115
         }
105 116
 
@@ -113,8 +124,10 @@  discard block
 block discarded – undo
113 124
     {
114 125
         $paths = [];
115 126
 
116
-        foreach (func_get_args() as $arg) {
117
-            if ($arg !== '') {
127
+        foreach (func_get_args() as $arg)
128
+        {
129
+            if ($arg !== '')
130
+            {
118 131
                 $paths[] = $arg;
119 132
             }
120 133
         }
Please login to merge, or discard this patch.
src/Templating/Twig/Extension/WhereFilter.php 1 patch
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,8 +45,10 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $results = [];
47 47
 
48
-        foreach ($array as $item) {
49
-            if ($this->compare($item, $key, $comparison, $value)) {
48
+        foreach ($array as $item)
49
+        {
50
+            if ($this->compare($item, $key, $comparison, $value))
51
+            {
50 52
                 $results[] = $item;
51 53
             }
52 54
         }
@@ -71,13 +73,15 @@  discard block
 block discarded – undo
71 73
      */
72 74
     private function compare(mixed $item, string $key, string $comparison, mixed $value): bool
73 75
     {
74
-        if ($this->compareNullValues($item, $key, $comparison, $value)) {
76
+        if ($this->compareNullValues($item, $key, $comparison, $value))
77
+        {
75 78
             return true;
76 79
         }
77 80
 
78 81
         $lhsValue = __::get($item, $key);
79 82
 
80
-        if ($lhsValue === null) {
83
+        if ($lhsValue === null)
84
+        {
81 85
             return false;
82 86
         }
83 87
 
@@ -94,15 +98,19 @@  discard block
 block discarded – undo
94 98
      */
95 99
     private function compareNullValues($item, $key, $operator, mixed $value): bool
96 100
     {
97
-        if ($operator !== '==' && $operator !== '!=') {
101
+        if ($operator !== '==' && $operator !== '!=')
102
+        {
98 103
             return false;
99 104
         }
100 105
 
101
-        if (!__::has($item, $key)) {
102
-            if ($operator === '==' && $value === null) {
106
+        if (!__::has($item, $key))
107
+        {
108
+            if ($operator === '==' && $value === null)
109
+            {
103 110
                 return true;
104 111
             }
105
-            if ($operator === '!=' && $value !== null) {
112
+            if ($operator === '!=' && $value !== null)
113
+            {
106 114
                 return true;
107 115
             }
108 116
         }
@@ -138,7 +146,8 @@  discard block
 block discarded – undo
138 146
 
139 147
     private function containsCaseInsensitive($haystack, $needle): bool
140 148
     {
141
-        if (is_array($haystack)) {
149
+        if (is_array($haystack))
150
+        {
142 151
             $downCase = array_combine(array_map('strtolower', $haystack), $haystack);
143 152
 
144 153
             return isset($downCase[strtolower((string)$needle)]);
Please login to merge, or discard this patch.
src/Templating/Twig/Extension/TableOfContentsFilter.php 1 patch
Braces   +25 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function __invoke($html, $id = null, $class = null, $hMin = 1, $hMax = 6): string
27 27
     {
28
-        if (!function_exists('simplexml_load_string')) {
28
+        if (!function_exists('simplexml_load_string'))
29
+        {
29 30
             trigger_error('XML support is not available with the current PHP installation.', E_USER_WARNING);
30 31
 
31 32
             return '';
@@ -38,24 +39,35 @@  discard block
 block discarded – undo
38 39
         $curr = $last = 0;
39 40
 
40 41
         /** @var DOMElement $heading */
41
-        foreach ($headings as $index => $heading) {
42
-            if ($heading->attributes->getNamedItem('id') === null) {
42
+        foreach ($headings as $index => $heading)
43
+        {
44
+            if ($heading->attributes->getNamedItem('id') === null)
45
+            {
43 46
                 continue;
44 47
             }
45 48
 
46 49
             sscanf($heading->tagName, 'h%u', $curr);
47 50
 
48
-            if (!($hMin <= $curr && $curr <= $hMax)) {
51
+            if (!($hMin <= $curr && $curr <= $hMax))
52
+            {
49 53
                 continue;
50 54
             }
51 55
 
52 56
             $headingID = $heading->attributes->getNamedItem('id');
53 57
 
54
-            if ($curr > $last) { // If the current level is greater than the last level indent one level
58
+            if ($curr > $last)
59
+            {
60
+// If the current level is greater than the last level indent one level
55 61
                 $toc .= '<ul>';
56
-            } elseif ($curr < $last) { // If the current level is less than the last level go up appropriate amount.
62
+            }
63
+            elseif ($curr < $last)
64
+            {
65
+// If the current level is less than the last level go up appropriate amount.
57 66
                 $toc .= str_repeat('</li></ul>', $last - $curr) . '</li>';
58
-            } else { // If the current level is equal to the last.
67
+            }
68
+            else
69
+            {
70
+// If the current level is equal to the last.
59 71
                 $toc .= '</li>';
60 72
             }
61 73
 
@@ -65,14 +77,17 @@  discard block
 block discarded – undo
65 77
 
66 78
         $toc .= str_repeat('</li></ul>', $last - ($hMin - 1));
67 79
 
68
-        if ($id !== null || $class !== null) {
80
+        if ($id !== null || $class !== null)
81
+        {
69 82
             $attributes = [];
70 83
 
71
-            if ($id !== null) {
84
+            if ($id !== null)
85
+            {
72 86
                 $attributes[] = sprintf('id="%s"', $id);
73 87
             }
74 88
 
75
-            if ($class !== null) {
89
+            if ($class !== null)
90
+            {
76 91
                 $attributes[] = sprintf('class="%s"', $class);
77 92
             }
78 93
 
Please login to merge, or discard this patch.
src/Templating/Twig/TwigStakxBridge.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,9 +54,12 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function createTemplate($templateContent): TemplateInterface
56 56
     {
57
-        try {
57
+        try
58
+        {
58 59
             $template = $this->twig->createTemplate($templateContent);
59
-        } catch (Error $e) {
60
+        }
61
+        catch (Error $e)
62
+        {
60 63
             throw new TwigError($e);
61 64
         }
62 65
 
@@ -89,7 +92,8 @@  discard block
 block discarded – undo
89 92
 
90 93
         preg_match_all($regex, $bodyContent, $results);
91 94
 
92
-        if (empty($results[1])) {
95
+        if (empty($results[1]))
96
+        {
93 97
             return [];
94 98
         }
95 99
 
Please login to merge, or discard this patch.
src/Templating/Twig/TwigStakxBridgeFactory.php 1 patch
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,10 +32,14 @@  discard block
 block discarded – undo
32 32
         $theme = $configuration->getTheme();
33 33
 
34 34
         // Only load a theme if one is specified and actually exists
35
-        if ($theme !== null) {
36
-            try {
35
+        if ($theme !== null)
36
+        {
37
+            try
38
+            {
37 39
                 $loader->addPath(fs::absolutePath('_themes', $theme), 'theme');
38
-            } catch (LoaderError $e) {
40
+            }
41
+            catch (LoaderError $e)
42
+            {
39 43
                 $logger->error('The following theme could not be loaded: {theme}', [
40 44
                     'theme' => $theme,
41 45
                 ]);
@@ -53,12 +57,14 @@  discard block
 block discarded – undo
53 57
 
54 58
         $profiler = null;
55 59
 
56
-        if (Service::hasRunTimeFlag(RuntimeStatus::IN_PROFILE_MODE)) {
60
+        if (Service::hasRunTimeFlag(RuntimeStatus::IN_PROFILE_MODE))
61
+        {
57 62
             $profiler = new Profile();
58 63
             $twig->addExtension(new ProfilerExtension($profiler));
59 64
         }
60 65
 
61
-        if ($configuration->isDebug()) {
66
+        if ($configuration->isDebug())
67
+        {
62 68
             $twig->addExtension(new DebugExtension());
63 69
             $twig->enableDebug();
64 70
         }
Please login to merge, or discard this patch.
src/Templating/Twig/TwigExtension.php 1 patch
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,7 +32,8 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $tag = lcfirst(str_replace('parseMarkup', '', (string)$name));
34 34
 
35
-        if (!$tag) {
35
+        if (!$tag)
36
+        {
36 37
             throw new BadMethodCallException("No method {$name} found in this class.");
37 38
         }
38 39
 
@@ -47,8 +48,10 @@  discard block
 block discarded – undo
47 48
     public function addFilters(/* iterable */ $filters): void
48 49
     {
49 50
         /** @var AbstractTwigExtension|TwigFilterInterface $filter */
50
-        foreach ($filters as $filter) {
51
-            if (Service::hasRunTimeFlag(RuntimeStatus::IN_SAFE_MODE) && $filter::disableInSafeMode()) {
51
+        foreach ($filters as $filter)
52
+        {
53
+            if (Service::hasRunTimeFlag(RuntimeStatus::IN_SAFE_MODE) && $filter::disableInSafeMode())
54
+            {
52 55
                 continue;
53 56
             }
54 57
 
@@ -59,8 +62,10 @@  discard block
 block discarded – undo
59 62
     public function addFunctions(/* iterable */ $functions): void
60 63
     {
61 64
         /** @var AbstractTwigExtension|TwigFunctionInterface $fxn */
62
-        foreach ($functions as $fxn) {
63
-            if (Service::hasRunTimeFlag(RuntimeStatus::IN_SAFE_MODE) && $fxn::disableInSafeMode()) {
65
+        foreach ($functions as $fxn)
66
+        {
67
+            if (Service::hasRunTimeFlag(RuntimeStatus::IN_SAFE_MODE) && $fxn::disableInSafeMode())
68
+            {
64 69
                 continue;
65 70
             }
66 71
 
@@ -72,7 +77,8 @@  discard block
 block discarded – undo
72 77
     {
73 78
         $filters = $this->filters;
74 79
 
75
-        foreach ($this->markupManager->getTemplateTags() as $tag) {
80
+        foreach ($this->markupManager->getTemplateTags() as $tag)
81
+        {
76 82
             // Since we can't pass what tag/markup language we're using to the callable, let's make the callable to a
77 83
             // non-existent method that will be handled by __call()
78 84
             $filters[] = new TwigFilter(
@@ -94,7 +100,8 @@  discard block
 block discarded – undo
94 100
     {
95 101
         $tokenParsers = [];
96 102
 
97
-        foreach ($this->markupManager->getTemplateTags() as $tag) {
103
+        foreach ($this->markupManager->getTemplateTags() as $tag)
104
+        {
98 105
             $tokenParsers[] = new TokenParser($tag);
99 106
         }
100 107
 
Please login to merge, or discard this patch.