Skip to content

Commit 689bbcb

Browse files
committed
Amend incorrect backport from master to 3.x
We need to use the old (Symfony 3.x) command/console APIs.
1 parent 6c74c6f commit 689bbcb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Command/CodeCheckerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9090
// Show PHPCompatibility backward-compatibility errors for a version or version range.
9191
$testVersion = $input->getOption('test-version');
9292
if (!empty($testVersion)) {
93-
array_push($cmd, '--runtime-set', 'testVersion', $testVersion);
93+
$builder->add('--runtime-set')->add('testVersion')->add(' '.$testVersion);
9494
}
9595

9696
// Add the files to process.

tests/Command/CodeCheckerCommandTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,51 +157,51 @@ public function testExecuteWithTestVersion()
157157
utf8_encode(); // Deprecated in PHP 8.2.
158158

159159
EOT;
160-
$this->fs->dumpFile($this->pluginDir . '/test_versions.php', $content);
160+
$this->fs->dumpFile($this->pluginDir.'/test_versions.php', $content);
161161

162162
// By default, without specify test-version, only reports deprecation warnings and returns 0.
163163
$commandTester = $this->executeCommand($this->pluginDir, -1, null);
164164
$output = $commandTester->getDisplay();
165165
$this->assertSame(0, $commandTester->getStatusCode());
166-
$this->assertMatchesRegularExpression('/FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES/', $output);
166+
$this->assertRegexp('/FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES/', $output);
167167

168168
// With test-version 7.4, reports 2 new errors and <= 7.4 specific warnings and returns 1.
169169
$commandTester = $this->executeCommand($this->pluginDir, -1, '7.4');
170170
$output = $commandTester->getDisplay();
171171
$this->assertSame(1, $commandTester->getStatusCode());
172-
$this->assertMatchesRegularExpression('/FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES/', $output);
172+
$this->assertRegexp('/FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES/', $output);
173173

174174
// With test-version 8.0, reports 1 new errors and <= 8.0 specific warnings and returns 1.
175175
$commandTester = $this->executeCommand($this->pluginDir, -1, '8.0');
176176
$output = $commandTester->getDisplay();
177177
$this->assertSame(1, $commandTester->getStatusCode());
178-
$this->assertMatchesRegularExpression('/FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES/', $output);
178+
$this->assertRegexp('/FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES/', $output);
179179

180180
// With test-version 8.1, reports 0 new errors and <= 8.1 specific warnings and returns 0.
181181
$commandTester = $this->executeCommand($this->pluginDir, -1, '8.1');
182182
$output = $commandTester->getDisplay();
183183
$this->assertSame(0, $commandTester->getStatusCode());
184-
$this->assertMatchesRegularExpression('/FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES/', $output);
184+
$this->assertRegexp('/FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES/', $output);
185185

186186
// With test-version 7.4-8.0, reports 2 new errors and <= 8.0 specific warnings and returns 1.
187187
$commandTester = $this->executeCommand($this->pluginDir, -1, '7.4-8.0');
188188
$output = $commandTester->getDisplay();
189189
$this->assertSame(1, $commandTester->getStatusCode());
190-
$this->assertMatchesRegularExpression('/FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES/', $output);
190+
$this->assertRegexp('/FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES/', $output);
191191

192192
// With test-version 7.4-8.1, reports 2 new errors and <= 8.1 specific warnings and returns 1.
193193
$commandTester = $this->executeCommand($this->pluginDir, -1, '7.4-8.1');
194194
$output = $commandTester->getDisplay();
195195
$this->assertSame(1, $commandTester->getStatusCode());
196-
$this->assertMatchesRegularExpression('/FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES/', $output);
196+
$this->assertRegexp('/FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES/', $output);
197197

198198
// With test-version 7.4- (open range), reports 2 new errors and <= 8.2 specific warnings and returns 1.
199199
// (note that it should be 1 more warning and 1 more error, but the PHPCompatibility sniffs are not
200200
// still ready for many of the PHP 8.2 changes. We'll amend this test when they are ready).
201201
$commandTester = $this->executeCommand($this->pluginDir, -1, '7.4-');
202202
$output = $commandTester->getDisplay();
203203
$this->assertSame(1, $commandTester->getStatusCode());
204-
$this->assertMatchesRegularExpression('/FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES/', $output);
204+
$this->assertRegexp('/FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES/', $output);
205205
}
206206

207207
public function testExecuteNoFiles()

0 commit comments

Comments
 (0)