Skip to content

Commit 251ddde

Browse files
authored
Fix misc issues (#33)
* Remove "continue-on-error" * Replace ... better * Use "\n" over PHP_EOL
1 parent fc9ae78 commit 251ddde

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

.github/workflows/static.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ jobs:
77
phpstan:
88
name: PHPStan
99
runs-on: Ubuntu-20.04
10-
continue-on-error: true
1110

1211
steps:
1312
- name: Checkout code
@@ -40,7 +39,6 @@ jobs:
4039
php-cs-fixer:
4140
name: PHP-CS-Fixer
4241
runs-on: Ubuntu-20.04
43-
continue-on-error: true
4442

4543
steps:
4644
- name: Checkout code
@@ -73,7 +71,6 @@ jobs:
7371
psalm:
7472
name: Psalm
7573
runs-on: Ubuntu-20.04
76-
continue-on-error: true
7774

7875
steps:
7976
- name: Checkout code
@@ -106,7 +103,6 @@ jobs:
106103
composer-normalize:
107104
name: Composer Normalize
108105
runs-on: Ubuntu-20.04
109-
continue-on-error: true
110106

111107
steps:
112108
- name: Set up PHP

src/Issue/Issue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function getLocalLine(): int
7777
public function getErroredLine()
7878
{
7979
if (null === $this->erroredLine) {
80-
$lines = explode(PHP_EOL, $this->node->getValue());
80+
$lines = explode("\n", $this->node->getValue());
8181
// We do -1 because the $lines array is zero-index and the error message is 1-index
8282
$this->erroredLine = $lines[max(0, $this->localLine - 1)];
8383
}

src/Service/CodeNodeRunner.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ private function warmupCache(CodeNode $node, IssueCollection $issues, string $ap
7070
return;
7171
}
7272

73-
$issues->addIssue(new Issue($node, trim($process->getErrorOutput()), 'Cache Warmup', $node->getEnvironment()->getCurrentFileName(), count(explode(PHP_EOL, $node->getValue())) - 1));
73+
$issues->addIssue(new Issue($node, trim($process->getErrorOutput()), 'Cache Warmup', $node->getEnvironment()->getCurrentFileName(), count(explode("\n", $node->getValue())) - 1));
7474
}
7575

7676
private function getFile(CodeNode $node): string
7777
{
78-
$contents = explode(PHP_EOL, $node->getValue());
78+
$contents = explode("\n", $node->getValue());
7979
$regex = match ($node->getLanguage()) {
8080
'php' => '|^// ?([a-z1-9A-Z_\-/]+\.php)$|',
8181
'yaml' => '|^# ?([a-z1-9A-Z_\-/]+\.yaml)$|',
@@ -94,14 +94,14 @@ private function getNodeContents(CodeNode $node): string
9494
{
9595
$language = $node->getLanguage();
9696
if ('php' === $language) {
97-
return '<?php'.PHP_EOL.$node->getValue();
97+
return '<?php'."\n".$node->getValue();
9898
}
9999

100100
if ('xml' === $language) {
101-
$contents = explode(PHP_EOL, $node->getValue());
101+
$contents = explode("\n", $node->getValue());
102102
unset($contents[0]);
103103

104-
return implode(PHP_EOL, $contents);
104+
return implode("\n", $contents);
105105
}
106106

107107
return $node->getValue();

src/Service/CodeValidator/PhpValidator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ private function getContents(CodeNode $node, string $language): string
4747
}
4848

4949
// Allow us to use "..." as a placeholder
50-
$contents = str_replace('...', 'null', $contents);
50+
$contents = str_replace(['...,', '...)', '...;'], ['null,', 'null)', 'null;'], $contents);
5151

52-
$lines = explode(PHP_EOL, $contents);
52+
$lines = explode("\n", $contents);
5353
if (!str_contains($lines[0] ?? '', '<?php') && !str_contains($lines[1] ?? '', '<?php') && !str_contains($lines[2] ?? '', '<?php')) {
54-
$contents = '<?php'.PHP_EOL.$contents;
54+
$contents = '<?php'."\n".$contents;
5555
}
5656

5757
return $contents;

src/Service/LineDetector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public static function find(CodeNode $node): int
2222
}
2323

2424
$file = sprintf('%s/%s.rst', $environment->getCurrentDirectory(), $environment->getCurrentFileName());
25-
$contents = explode(PHP_EOL, file_get_contents($file));
26-
$codeBlock = explode(PHP_EOL, $node->getValue());
25+
$contents = explode("\n", file_get_contents($file));
26+
$codeBlock = explode("\n", $node->getValue());
2727

2828
foreach ($contents as $i => $line) {
2929
foreach ($codeBlock as $j => $needle) {

0 commit comments

Comments
 (0)