Skip to content

Commit

Permalink
PHP baseline: fix path (#32)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
janedbal and jmdelehaye authored Dec 31, 2024
1 parent 3a9107f commit 3635758
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Handler/PhpBaselineHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function encodeBaseline(string $comment, array $errors, string $indent):
"\$ignoreErrors[] = [\n{$indent}'message' => %s,\n{$indent}'count' => %d,\n{$indent}'path' => __DIR__ . %s,\n];\n",
var_export($error['message'], true),
var_export($error['count'], true),
var_export($error['path'], true),
var_export('/' . $error['path'], true),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Rule/data/baselines-php/another.identifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$ignoreErrors[] = [
'message' => '#^Error to escape \'\\#$#',
'count' => 1,
'path' => __DIR__ . '../app/config.php',
'path' => __DIR__ . '/../app/config.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
2 changes: 1 addition & 1 deletion tests/Rule/data/baselines-php/missing-identifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$ignoreErrors[] = [
'message' => '#^Error 3$#',
'count' => 1,
'path' => __DIR__ . '../app/index.php',
'path' => __DIR__ . '/../app/index.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
2 changes: 1 addition & 1 deletion tests/Rule/data/baselines-php/sample.identifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$ignoreErrors[] = [
'message' => '#^Error simple$#',
'count' => 1,
'path' => __DIR__ . '../app/file.php',
'path' => __DIR__ . '/../app/file.php',
];

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

0 comments on commit 3635758

Please sign in to comment.