Skip to content

Commit 0812168

Browse files
committed
fix php 8.2 string interpolation warnings
Using ${var} in strings is deprecated, use {$var} instead [1] [1]: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
1 parent 4eb514e commit 0812168

27 files changed

+50
-47
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ The format is based on [Keep a Changelog] and Pipelines adheres to
1111
### Add
1212
- PHP 8.2 Alpine based build container
1313
### Fix
14+
- PHP 8.2 Using ${var} in strings deprecations (#24) (thanks
15+
[Brad Kent][Brad Kent])
1416
- Eager substr_replace() use in updateTimestamps() (thanks [Jan Tvrdík])
1517
- Fix type annotation and add support for DateTimeImmutable (thanks
1618
[Jordi Boggiano])
1719

20+
[Brad Kent]: https://github.com/bkdotcom
1821
[Jan Tvrdík]: https://github.com/JanTvrdik
1922
[Jordi Boggiano]: https://github.com/Seldaek
2023

lib/build/coverage-checker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
$fMetrics = function ($s) use ($xml) {
5151
return array_sum(array_map(
5252
'intval',
53-
$xml->xpath(".//metrics/@${s}elements")
53+
$xml->xpath(".//metrics/@{$s}elements")
5454
));
5555
};
5656

src/Cli/Docker/ProcessManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function findAllContainerIdsByName($name)
3636
'docker',
3737
array(
3838
'ps', '--no-trunc', '-qa', '--filter',
39-
"name=^/\\Q${name}\\E$",
39+
"name=^/\\Q{$name}\\E$",
4040
),
4141
$result
4242
);
@@ -150,7 +150,7 @@ private function psPrefixImpl($prefix, $all = false)
150150
'docker',
151151
array(
152152
'ps', '-q' . ($all ? 'a' : ''), '--no-trunc', '--filter',
153-
"name=^/${prefix}[-.]",
153+
"name=^/{$prefix}[-.]",
154154
),
155155
$result
156156
);

src/Cli/Exec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function pass($command, array $arguments)
4949
}
5050

5151
':' === $buffer ? $status = 0 : passthru($buffer, $status);
52-
$this->debug("exit status: ${status}");
52+
$this->debug("exit status: {$status}");
5353

5454
return $status;
5555
}
@@ -80,7 +80,7 @@ public function capture($command, array $arguments, &$out = null, &$err = null)
8080

8181
$proc = new Proc($buffer);
8282
$status = $proc->run();
83-
$this->debug("exit status: ${status}");
83+
$this->debug("exit status: {$status}");
8484
$out = $proc->getStandardOutput();
8585
$err = $proc->getStandardError();
8686

src/File/Definitions/Caches.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ private function parse(array $array)
9292
{
9393
foreach ($array as $name => $path) {
9494
if (!is_string($name)) {
95-
throw new ParseException("cache definition invalid cache name: ${name}");
95+
throw new ParseException("cache definition invalid cache name: {$name}");
9696
}
9797

9898
if (null === $path) {
99-
throw new ParseException("cache '${name}' should be a string value (it is currently null or empty)");
99+
throw new ParseException("cache '{$name}' should be a string value (it is currently null or empty)");
100100
}
101101

102102
if (is_bool($path)) {
103-
throw new ParseException("cache '${name}' should be a string (it is currently defined as a boolean)");
103+
throw new ParseException("cache '{$name}' should be a string (it is currently defined as a boolean)");
104104
}
105105

106106
// Fixme(tk): more importantly is that $path is not array or object

src/File/Definitions/Service.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ private function parseVariables(array $array)
100100

101101
foreach ($variables as $name => $value) {
102102
if (null === $value) {
103-
throw new ParseException("variable ${name} should be a string value (it is currently null or empty)");
103+
throw new ParseException("variable {$name} should be a string value (it is currently null or empty)");
104104
}
105105
if (is_bool($value)) {
106-
throw new ParseException("variable ${name} should be a string (it is currently defined as a boolean)");
106+
throw new ParseException("variable {$name} should be a string (it is currently defined as a boolean)");
107107
}
108108
}
109109

src/File/Pipeline/StepParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function parseAfterScript(array $step)
8989
private function parseNamedScript($name, array $script)
9090
{
9191
if (!is_array($script[$name]) || !count($script[$name])) {
92-
throw new ParseException("'${name}' requires a list of commands");
92+
throw new ParseException("'{$name}' requires a list of commands");
9393
}
9494

9595
foreach ($script[$name] as $index => $line) {

src/File/Pipelines.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private function parseValidatePipelines(array $array)
237237
if (!$count && !isset($array['default'])) {
238238
$middle = implode(', ', array_slice($sections, 0, -1));
239239

240-
throw new ParseException("'pipelines' requires at least a default, ${middle} or custom section");
240+
throw new ParseException("'pipelines' requires at least a default, {$middle} or custom section");
241241
}
242242
}
243243

@@ -259,7 +259,7 @@ private function referencesDefault(array &$array)
259259
}
260260

261261
if (!is_array($array[$default])) {
262-
throw new ParseException("'${default}' requires a list of steps");
262+
throw new ParseException("'{$default}' requires a list of steps");
263263
}
264264

265265
$references[$default] = array($default, null, &$array[$default]);
@@ -285,10 +285,10 @@ private function referencesAddSections(array $references, array &$array)
285285
continue; // not a section for references
286286
}
287287
if (!is_array($refs)) {
288-
throw new ParseException("'${section}' requires a list");
288+
throw new ParseException("'{$section}' requires a list");
289289
}
290290
foreach ($refs as $pattern => $pipeline) {
291-
$references["${section}/${pattern}"] = array(
291+
$references["{$section}/{$pattern}"] = array(
292292
(string)$section,
293293
(string)$pattern,
294294
&$array[$section][$pattern],

src/File/PipelinesReferences.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private static function idNonPatternMatch(Pipelines $pipelines, $section, $refer
130130

131131
# check for direct (non-pattern) match
132132
if (isset($pipelines->array[$section][$reference])) {
133-
return array(true, "${section}/${reference}");
133+
return array(true, "{$section}/{$reference}");
134134
}
135135

136136
return array(false, null);
@@ -158,6 +158,6 @@ private static function idPattern(Pipelines $pipelines, $section, $reference)
158158
}
159159
}
160160

161-
return array('' !== $match, "${section}/${match}");
161+
return array('' !== $match, "{$section}/{$match}");
162162
}
163163
}

src/Lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function quoteArg($argument)
105105
foreach ($parts as $index => $part) {
106106
$index && $buffer .= "\\'";
107107
$safe = preg_match('~^[a-zA-Z0-9,._+@%/-]*$~D', $part);
108-
$buffer .= $safe ? $part : "'${part}'";
108+
$buffer .= $safe ? $part : "'{$part}'";
109109
}
110110

111111
if ('' === $buffer) {

0 commit comments

Comments
 (0)