Skip to content

Commit 5c317d0

Browse files
committed
AC-1059: Move PHPCompatibility rules from Magento tests
1 parent 40ceb70 commit 5c317d0

File tree

5 files changed

+31
-121
lines changed

5 files changed

+31
-121
lines changed

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
"preferred-install": "dist",
1111
"sort-packages": true
1212
},
13+
"repositories": [
14+
{
15+
"type": "vcs",
16+
"url": "https://github.com/svera/magento-coding-standard"
17+
}
18+
],
1319
"require": {
1420
"php": "~7.4.0||~8.0.0",
1521
"ext-bcmath": "*",
@@ -85,10 +91,9 @@
8591
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
8692
"friendsofphp/php-cs-fixer": "~3.0.0",
8793
"lusitanian/oauth": "~0.8.10",
88-
"magento/magento-coding-standard": "*",
94+
"magento/magento-coding-standard": "dev-AC-1059_move-phpcompatibility-rules-from-magento-tests",
8995
"magento/magento2-functional-testing-framework": "^3.7",
9096
"pdepend/pdepend": "~2.10.0",
91-
"phpcompatibility/php-compatibility": "^9.3",
9297
"phpmd/phpmd": "^2.9.1",
9398
"phpstan/phpstan": "~1.1.0",
9499
"phpunit/phpunit": "~9.5.0",

composer.lock

Lines changed: 24 additions & 11 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)