Skip to content

Commit 3635758

Browse files
janedbaljmdelehaye
andauthored
PHP baseline: fix path (#32)
* PhpBaselineHandler.php: fix path Add missing slash, because __DIR__ does not have a trailing slash unless it is the root directory, @see https://www.php.net/manual/en/language.constants.magic.php#constant.dir * Fix test --------- Co-authored-by: jmdelehaye <jmdelehaye@gmail.com>
1 parent 3a9107f commit 3635758

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/Handler/PhpBaselineHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function encodeBaseline(string $comment, array $errors, string $indent):
4141
"\$ignoreErrors[] = [\n{$indent}'message' => %s,\n{$indent}'count' => %d,\n{$indent}'path' => __DIR__ . %s,\n];\n",
4242
var_export($error['message'], true),
4343
var_export($error['count'], true),
44-
var_export($error['path'], true),
44+
var_export('/' . $error['path'], true),
4545
);
4646
}
4747

tests/Rule/data/baselines-php/another.identifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$ignoreErrors[] = [
77
'message' => '#^Error to escape \'\\#$#',
88
'count' => 1,
9-
'path' => __DIR__ . '../app/config.php',
9+
'path' => __DIR__ . '/../app/config.php',
1010
];
1111

1212
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

tests/Rule/data/baselines-php/missing-identifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$ignoreErrors[] = [
77
'message' => '#^Error 3$#',
88
'count' => 1,
9-
'path' => __DIR__ . '../app/index.php',
9+
'path' => __DIR__ . '/../app/index.php',
1010
];
1111

1212
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

tests/Rule/data/baselines-php/sample.identifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$ignoreErrors[] = [
77
'message' => '#^Error simple$#',
88
'count' => 1,
9-
'path' => __DIR__ . '../app/file.php',
9+
'path' => __DIR__ . '/../app/file.php',
1010
];
1111

1212
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

0 commit comments

Comments
 (0)