Skip to content

Commit 6204718

Browse files
authored
Merge pull request #7235 from magento-lynx/AC-1059_Move-PHPCompatibility-rules-from-magento-tests
[IBERIAN LYNX] Move PHPCompatibility rules from Magento tests
2 parents eadd3a9 + 00a6bbe commit 6204718

File tree

5 files changed

+69
-116
lines changed

5 files changed

+69
-116
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"magento/magento-coding-standard": "*",
8989
"magento/magento2-functional-testing-framework": "^3.7",
9090
"pdepend/pdepend": "~2.10.0",
91-
"phpcompatibility/php-compatibility": "^9.3",
9291
"phpmd/phpmd": "^2.9.1",
9392
"phpstan/phpstan": "~1.1.0",
9493
"phpunit/phpunit": "~9.5.0",

composer.lock

Lines changed: 69 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/PhpCompatibility.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -208,43 +208,6 @@ private function getFullWhitelist()
208208
}
209209
}
210210

211-
/**
212-
* Retrieves the lowest and highest PHP version specified in <kbd>composer.json</var> of project.
213-
*
214-
* @return array
215-
*/
216-
private function getTargetPhpVersions(): array
217-
{
218-
$composerJson = json_decode(file_get_contents(BP . '/composer.json'), true);
219-
$versionsRange = [];
220-
221-
if (isset($composerJson['require']['php'])) {
222-
$versions = explode('||', $composerJson['require']['php']);
223-
224-
//normalize version constraints
225-
foreach ($versions as $key => $version) {
226-
$version = ltrim($version, '^~');
227-
$version = str_replace('*', '999', $version);
228-
229-
$versions[$key] = $version;
230-
}
231-
232-
//sort versions
233-
usort($versions, 'version_compare');
234-
235-
$versionsRange[] = array_shift($versions);
236-
if (!empty($versions)) {
237-
$versionsRange[] = array_pop($versions);
238-
}
239-
foreach ($versionsRange as $key => $version) {
240-
$versionParts = explode('.', $versionsRange[$key]);
241-
$versionsRange[$key] = sprintf('%s.%s', $versionParts[0], $versionParts[1] ?? '0');
242-
}
243-
}
244-
245-
return $versionsRange;
246-
}
247-
248211
/**
249212
* Returns whether a full scan was requested.
250213
*
@@ -405,39 +368,6 @@ public function testStrictTypes()
405368
);
406369
}
407370

408-
/**
409-
* Test for compatibility to lowest PHP version declared in <kbd>composer.json</kbd>.
410-
*/
411-
public function testPhpCompatibility()
412-
{
413-
$targetVersions = $this->getTargetPhpVersions();
414-
$this->assertNotEmpty($targetVersions, 'No supported versions information in composer.json');
415-
$reportFile = self::$reportDir . '/phpcompatibility_report.txt';
416-
$rulesetDir = __DIR__ . '/_files/PHPCompatibilityMagento';
417-
418-
if (!file_exists($reportFile)) {
419-
touch($reportFile);
420-
}
421-
422-
$codeSniffer = new PhpCompatibility($rulesetDir, $reportFile, new Wrapper());
423-
if (count($targetVersions) > 1) {
424-
$codeSniffer->setTestVersion($targetVersions[0] . '-' . $targetVersions[1]);
425-
} else {
426-
$codeSniffer->setTestVersion($targetVersions[0]);
427-
}
428-
429-
$result = $codeSniffer->run(
430-
$this->isFullScan() ? $this->getFullWhitelist() : self::getWhitelist(['php', 'phtml'])
431-
);
432-
$report = file_get_contents($reportFile);
433-
434-
$this->assertEquals(
435-
0,
436-
$result,
437-
'PHP Compatibility detected violation(s):' . PHP_EOL . $report
438-
);
439-
}
440-
441371
/**
442372
* Test code quality using PHPStan
443373
*

dev/tests/static/testsuite/Magento/Test/Php/_files/PHPCompatibilityMagento/ruleset.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)