diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml index bae4b5faef..a5c829ffbb 100644 --- a/.github/workflows/code_checks.yaml +++ b/.github/workflows/code_checks.yaml @@ -73,7 +73,6 @@ jobs: name: Run run: composer rector - binary_files: runs-on: ubuntu-latest diff --git a/.github/workflows/ecs_prefixed.yaml b/.github/workflows/ecs_prefixed.yaml new file mode 100644 index 0000000000..2390e6d488 --- /dev/null +++ b/.github/workflows/ecs_prefixed.yaml @@ -0,0 +1,83 @@ +name: Prefixed ECS Deploy + +on: + pull_request: null + push: + branches: + - master + +jobs: + ecs_phar_compile: + runs-on: ubuntu-latest + + steps: + - + name: Checkout code + uses: actions/checkout@v2 + + - + name: Setup PHP + uses: shivammathur/setup-php@v1 + with: + php-version: 7.2 + coverage: none + + - + name: Install + run: | + # install + cd packages/EasyCodingStandard/compiler + composer install + + - + name: Compile ecs.phar with Box and PHP Scoper + run: | + # compile + cd packages/EasyCodingStandard/compiler + bin/compile + + - + name: Run ecs.phar + run: | + # remove local vendor, to prevent duplicated content + rm -rf packages/EasyCodingStandard/vendor + cd packages/EasyCodingStandard + tmp/ecs.phar + + - + name: Run ecs.phar with PSR-12 set + run: | + cd packages/EasyCodingStandard + # create dummy file + echo "> someFile.php + tmp/ecs.phar check someFile.php --set dead-code + + # Deploy PHAR to https://github.com/Symplify/EasyCodingStandardPrefixed + - + name: Publish ecs.phar to Symplify/EasyCodingStandardPrefixed + run: | + cd packages/EasyCodingStandard + + # reuse tmp/ecs.phar from previous job + git clone https://${ACCESS_TOKEN}@github.com/Symplify/EasyCodingStandardPrefixed.git > /dev/null 2>&1 + + # copy phar files inside cloned repository + cp tmp/ecs.phar EasyCodingStandardPrefixed/ecs.phar + cp tmp/ecs.phar EasyCodingStandardPrefixed/ecs + + # go to clone repository + cd EasyCodingStandardPrefixed + git config user.email "action@github.com" + git config user.name "Github Actions" + git add ecs ecs.phar + + # commit with new tag, if this commit is tagged, or with normal commit + if [ "${TRAVIS_TAG}" != "" ]; then COMMIT_MSG="ECS ${TRAVIS_TAG}"; else COMMIT_MSG="Updated ECS to commit ${TRAVIS_COMMIT}"; fi + git commit -m "${COMMIT_MSG}" + + git push --quiet origin master + + # push tag, if this commit is tagged, or with normal push + if [ "${TRAVIS_TAG}" != "" ]; then git tag "${TRAVIS_TAG}" && git push --quiet origin ${TRAVIS_TAG}; fi + env: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} diff --git a/.gitignore b/.gitignore index 4c7da5d406..ddd9e52c54 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ package-lock.json # phpunit .phpunit.result.cache -packages/EasyCodingStandard/compiler/ \ No newline at end of file +packages/EasyCodingStandard/vendor/ +packages/EasyCodingStandard/tmp/ \ No newline at end of file diff --git a/composer.json b/composer.json index 846f00a0d8..84cc89c3f6 100644 --- a/composer.json +++ b/composer.json @@ -65,6 +65,7 @@ "Symplify\\EasyCodingStandardTester\\": "packages/EasyCodingStandardTester/src", "Symplify\\EasyCodingStandard\\": "packages/EasyCodingStandard/src", "Symplify\\EasyCodingStandard\\ChangedFilesDetector\\": "packages/EasyCodingStandard/packages/ChangedFilesDetector/src", + "Symplify\\EasyCodingStandard\\Compiler\\": "packages/EasyCodingStandard/compiler/src", "Symplify\\EasyCodingStandard\\Configuration\\": "packages/EasyCodingStandard/packages/Configuration/src", "Symplify\\EasyCodingStandard\\FixerRunner\\": "packages/EasyCodingStandard/packages/FixerRunner/src", "Symplify\\EasyCodingStandard\\SniffRunner\\": "packages/EasyCodingStandard/packages/SniffRunner/src", diff --git a/configuration- b/configuration- deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ecs.yaml b/ecs.yaml index 15baa994dd..5c21d090fb 100644 --- a/ecs.yaml +++ b/ecs.yaml @@ -39,6 +39,8 @@ parameters: # tests - 'packages/*/tests/**Source/*.php' - 'packages/CodingStandard/tests/Fixer/Order/MethodOrderByTypeFixer/Wrong/*' + # own scope + - 'packages/EasyCodingStandard/compiler/build/scoper.inc.php' skip: # run form time to time, very slow and making many changes diff --git a/packages/EasyCodingStandard/README.md b/packages/EasyCodingStandard/README.md index 35b6023c64..2e2a741969 100644 --- a/packages/EasyCodingStandard/README.md +++ b/packages/EasyCodingStandard/README.md @@ -11,7 +11,7 @@ - +
@@ -23,6 +23,7 @@ - **2nd run under few seconds** with caching - [Skipping files](#ignore-what-you-cant-fix) for specific checkers - [Prepared checker sets](#use-prepared-checker-sets) - PSR12, Symfony, Common, Symplify and more... +- Use [Prefixed version](https://github.com/Symplify/EasyCodingStandardPrefixed) to prevent conflicts on install Are you already using another tool? diff --git a/packages/EasyCodingStandard/bin/ecs b/packages/EasyCodingStandard/bin/ecs index 39c4a15785..3f841d3f35 100755 --- a/packages/EasyCodingStandard/bin/ecs +++ b/packages/EasyCodingStandard/bin/ecs @@ -17,26 +17,11 @@ use Symplify\EasyCodingStandard\Configuration\Configuration; gc_disable(); # 1. autoload -$possibleAutoloadPaths = [ - // after split package - __DIR__ . '/../vendor', - // dependency - __DIR__ . '/../../..', - // monorepo - __DIR__ . '/../../../vendor', -]; - -foreach ($possibleAutoloadPaths as $possibleAutoloadPath) { - if (is_file($possibleAutoloadPath . '/autoload.php')) { - require_once $possibleAutoloadPath . '/autoload.php'; - require_once $possibleAutoloadPath . '/squizlabs/php_codesniffer/autoload.php'; - - // initalize PHPCS tokens - new Tokens(); - - break; - } -} +$autoloadIncluder = new AutoloadIncluder(); +$autoloadIncluder->includeCwdVendorAutoloadIfExists(); +$autoloadIncluder->autoloadProjectAutoloaderFile('/../../autoload.php'); +$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists(); +$autoloadIncluder->includePhpCodeSnifferAutoloadIfNotInPharAndInitliazeTokens(); # 2. create container $configs = []; @@ -48,20 +33,18 @@ $input = new ArgvInput(); $inputConfig = $configResolver->resolveFromInputWithFallback($input, ['easy-coding-standard.yml', 'easy-coding-standard.yaml', 'ecs.yml', 'ecs.yaml'] ); - if ($inputConfig) { $configs[] = $inputConfig; } // 2. --set CLI option -$setInputConfig = $configResolver->resolveSetFromInputAndDirectory($input, __DIR__ . '/../config/set'); +$setInputConfig = $configResolver->resolveSetFromInputAndDirectory($input, Set::SET_DIRECTORY); if ($setInputConfig) { $configs[] = $setInputConfig; } // 3. "parameters > set" in provided yaml files $parameterSetsConfigs = $configResolver->resolveFromParameterSetsFromConfigFiles($configs, Set::SET_DIRECTORY); - if ($parameterSetsConfigs !== []) { $configs = array_merge($configs, $parameterSetsConfigs); } @@ -89,8 +72,9 @@ foreach ($configs as $config) { } } -$mainConfigShiftedAsLast[] = $inputConfig; - +if ($inputConfig !== null) { + $mainConfigShiftedAsLast[] = $inputConfig; +} $easyCodingStandardKernel = new EasyCodingStandardKernel($environment, InputDetector::isDebug()); if ($configs !== []) { @@ -112,3 +96,127 @@ $configuration->setFirstResolverConfig($configResolver->getFirstResolvedConfig() # 3. run $application = $container->get(EasyCodingStandardConsoleApplication::class); exit($application->run()); + + +/** + * Inspired by https://github.com/rectorphp/rector/pull/2373/files#diff-0fc04a2bb7928cac4ae339d5a8bf67f3 + */ +final class AutoloadIncluder +{ + /** + * @var string[] + */ + private $alreadyLoadedAutoloadFiles = []; + + public function includeCwdVendorAutoloadIfExists(): void + { + $cwdVendorAutoload = getcwd() . '/vendor/autoload.php'; + if (!is_file($cwdVendorAutoload)) { + return; + } + $this->loadIfNotLoadedYet($cwdVendorAutoload, __METHOD__ . '()" on line ' . __LINE__); + } + + public function includeDependencyOrRepositoryVendorAutoloadIfExists(): void + { + // ECS' vendor is already loaded + if (class_exists('\Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel')) { + return; + } + + $devOrPharVendorAutoload = __DIR__ . '/../vendor/autoload.php'; + if (! is_file($devOrPharVendorAutoload)) { + return; + } + + $this->loadIfNotLoadedYet($devOrPharVendorAutoload, __METHOD__ . '()" on line ' . __LINE__); + } + /** + * Inspired by https://github.com/phpstan/phpstan-src/blob/e2308ecaf49a9960510c47f5a992ce7b27f6dba2/bin/phpstan#L19 + */ + public function autoloadProjectAutoloaderFile(string $file): void + { + $path = dirname(__DIR__) . $file; + if (!extension_loaded('phar')) { + if (is_file($path)) { + $this->loadIfNotLoadedYet($path, __METHOD__ . '()" on line ' . __LINE__); + } + } else { + $pharPath = Phar::running(false); + if ($pharPath === '') { + if (is_file($path)) { + $this->loadIfNotLoadedYet($path, __METHOD__ . '()" on line ' . __LINE__); + } + } else { + $path = dirname($pharPath) . $file; + if (is_file($path)) { + $this->loadIfNotLoadedYet($path, __METHOD__ . '()" on line ' . __LINE__); + } + } + } + } + + private function isInPhar(): bool + { + if (!extension_loaded('phar')) { + return false; + } + + if (Phar::running(false) === '') { + return false; + } + + return true; + } + + private function loadIfNotLoadedYet(string $file, string $location): void + { + if (in_array($file, $this->alreadyLoadedAutoloadFiles, true)) { + return; + } + + if ($this->isDebugOption()) { + echo sprintf(sprintf( + 'File "%s" is about to be loaded in "%s"' . PHP_EOL, + $file, + $location + )); + } + + $this->alreadyLoadedAutoloadFiles[] = realpath($file); + require_once $file; + } + + private function isDebugOption(): bool + { + return in_array('--debug', $_SERVER['argv'], true); + } + + public function includePhpCodeSnifferAutoloadIfNotInPharAndInitliazeTokens() + { + // file is autoloaded with classmap in PHAR + // without phar, we still need to autoload it + if (! $this->isInPhar()) { + # 1. autoload + $possibleAutoloadPaths = [ + // after split package + __DIR__ . '/../vendor', + // dependency + __DIR__ . '/../../..', + // monorepo + __DIR__ . '/../../../vendor', + ]; + + foreach ($possibleAutoloadPaths as $possibleAutoloadPath) { + if (!is_file($possibleAutoloadPath . '/autoload.php')) { + continue; + } + + require_once $possibleAutoloadPath . '/squizlabs/php_codesniffer/autoload.php'; + } + } + + // initalize PHPCS tokens + new Tokens(); + } +} diff --git a/packages/EasyCodingStandard/compiler/.gitignore b/packages/EasyCodingStandard/compiler/.gitignore new file mode 100644 index 0000000000..896f3ff84a --- /dev/null +++ b/packages/EasyCodingStandard/compiler/.gitignore @@ -0,0 +1,3 @@ +/temp +!/temp/.gitkeep +/vendor diff --git a/packages/EasyCodingStandard/compiler/README.md b/packages/EasyCodingStandard/compiler/README.md new file mode 100644 index 0000000000..a6212c5ea8 --- /dev/null +++ b/packages/EasyCodingStandard/compiler/README.md @@ -0,0 +1,29 @@ +# PHAR Compiler for EasyCodingStandard + +## Compile the PHAR + +```bash +composer install +bin/compile +``` + +The compiled PHAR will be in `tmp/ecs.phar`. Test it: + +```bash +php ../tmp/ecs.phar +``` + +Please note that running the compiler will change the contents of `composer.json` file and `vendor` directory. Revert those changes after running it. + +## Notes + +This section si needed in `composer.json`, because it was causing autolaoding bugs. +Box aliases existing Symfony stubs to php, see https://ayesh.me/composer-replace-polyfills. + +```json +{ + "replace": { + "symfony/polyfill-php70": "*" + } +} +``` diff --git a/packages/EasyCodingStandard/compiler/bin/compile b/packages/EasyCodingStandard/compiler/bin/compile new file mode 100755 index 0000000000..28df674a4f --- /dev/null +++ b/packages/EasyCodingStandard/compiler/bin/compile @@ -0,0 +1,23 @@ +#!/usr/bin/env php +add($compileCommand); +$application->setDefaultCommand($compileCommand->getName(), true); +$application->run(); diff --git a/packages/EasyCodingStandard/compiler/build/box.json b/packages/EasyCodingStandard/compiler/build/box.json new file mode 100644 index 0000000000..b74013f767 --- /dev/null +++ b/packages/EasyCodingStandard/compiler/build/box.json @@ -0,0 +1,17 @@ +{ + "alias": "ecs.phar", + "banner": false, + "base-path": "../..", + "check-requirements": false, + "compactors": [ + "KevinGH\\Box\\Compactor\\PhpScoper" + ], + "directories": [ + "config", + "src", + "packages", + "vendor" + ], + "output": "tmp/ecs.phar", + "php-scoper": "compiler/build/scoper.inc.php" +} diff --git a/packages/EasyCodingStandard/compiler/build/box.phar b/packages/EasyCodingStandard/compiler/build/box.phar new file mode 100755 index 0000000000..edfa4a7ae4 Binary files /dev/null and b/packages/EasyCodingStandard/compiler/build/box.phar differ diff --git a/packages/EasyCodingStandard/compiler/build/scoper.inc.php b/packages/EasyCodingStandard/compiler/build/scoper.inc.php new file mode 100644 index 0000000000..6d319d71fc --- /dev/null +++ b/packages/EasyCodingStandard/compiler/build/scoper.inc.php @@ -0,0 +1,36 @@ + null, + 'finders' => [], + 'patchers' => [ + function (string $filePath, string $prefix, string $content): string { + if ($filePath !== 'bin/ecs') { + return $content; + } + return str_replace('__DIR__ . \'/..', '\'phar://ecs.phar', $content); + }, + + // scoping stupid string contact class naming from: https://github.com/squizlabs/PHP_CodeSniffer/blob/b477a41ac565dad7a01c8b42f4804280723ad02f/src/Files/File.php#L562 + + function (string $filePath, string $prefix, string $content): string { + if (! Strings::endsWith($filePath, 'src/Files/File.php')) { + return $content; + } + + // $tokenizerClass = 'PHP_CodeSniffer\\Tokenizers\\' . $this->tokenizerType; → + // $tokenizerClass = 'MagicScoperPrefix\\PHP_CodeSniffer\\Tokenizers\\' . $this->tokenizerType; + return Strings::replace($content, '#\'PHP_CodeSniffer#', sprintf("'%s\\\\PHP_CodeSniffer", $prefix)); + }, + ], + 'whitelist' => [ + // needed for autoload, that is not prefixed, since it's in bin/* file + 'Symplify\*', + ], +]; diff --git a/packages/EasyCodingStandard/compiler/composer.json b/packages/EasyCodingStandard/compiler/composer.json new file mode 100644 index 0000000000..5c5ae66e6a --- /dev/null +++ b/packages/EasyCodingStandard/compiler/composer.json @@ -0,0 +1,22 @@ +{ + "name": "symplify/easy-coding-standard-compiler", + "description": "PHAR Compiler for ECS", + "license": "MIT", + "require": { + "php": "^7.2", + "nette/utils": "^3.0", + "phar-io/version": "^2.0.1", + "symfony/console": "^4.4|^5.0", + "symfony/filesystem": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0" + }, + "require-dev": { + "tracy/tracy": "^2.7" + }, + "autoload": { + "psr-4": { + "Symplify\\EasyCodingStandard\\Compiler\\": "src" + } + } +} diff --git a/packages/EasyCodingStandard/compiler/src/Console/CompileCommand.php b/packages/EasyCodingStandard/compiler/src/Console/CompileCommand.php new file mode 100644 index 0000000000..06555087fe --- /dev/null +++ b/packages/EasyCodingStandard/compiler/src/Console/CompileCommand.php @@ -0,0 +1,164 @@ +filesystem = new Filesystem(); + $this->compileProcessFactory = $compileProcessFactory; + $this->dataDir = $dataDir; + $this->buildDir = $buildDir; + $this->symplifyStableVersionProvider = new SymplifyStableVersionProvider(); + } + + protected function configure(): void + { + $this->setName('ecs:compile'); + $this->setDescription('Compile prefixed ecs.phar'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $this->compileProcessFactory->setOutput($output); + + $composerJsonFile = $this->buildDir . '/composer.json'; + + $this->fixComposerJson($composerJsonFile); + // @see https://github.com/dotherightthing/wpdtrt-plugin-boilerplate/issues/52 + $this->compileProcessFactory->create( + ['composer', 'update', '--no-dev', '--prefer-dist', '--no-interaction', '--classmap-authoritative'], + $this->buildDir + ); + + // parallel prevention is just for single less-buggy process + $this->compileProcessFactory->create(['php', 'box.phar', 'compile', '--no-parallel'], $this->dataDir); + + $this->restoreComposerJson($composerJsonFile); + + return 0; + } + + private function fixComposerJson(string $composerJsonFile): void + { + $fileContent = NetteFileSystem::read($composerJsonFile); + $this->originalComposerJsonFileContent = $fileContent; + + $json = Json::decode($fileContent, Json::FORCE_ARRAY); + + $json = $this->replaceDevSymplifyVersionWithLastStableVersion($json); + $json = $this->fixPhpCodeSnifferAutoloading($json); + + $json = $this->removeDevContent($json); + $this->cleanupPhpCsFixerBreakingFiles(); + + $encodedJson = Json::encode($json, Json::PRETTY); + + $this->filesystem->dumpFile($composerJsonFile, $encodedJson); + } + + /** + * This prevent root composer.json constant override + */ + private function restoreComposerJson(string $composerJsonFile): void + { + $this->filesystem->dumpFile($composerJsonFile, $this->originalComposerJsonFileContent); + + // re-run @todo composer update on root + } + + private function replaceDevSymplifyVersionWithLastStableVersion(array $json): array + { + $symplifyVersionToRequire = $this->symplifyStableVersionProvider->provide(); + + foreach (array_keys($json['require']) as $package) { + /** @var string $package */ + if (! Strings::startsWith($package, 'symplify/')) { + continue; + } + + $json['require'][$package] = $symplifyVersionToRequire; + } + return $json; + } + + private function cleanupPhpCsFixerBreakingFiles(): void + { + // cleanup + $filesToRemove = [ + __DIR__ . '/../../../vendor/friendsofphp/php-cs-fixer/src/Test/AbstractIntegrationTestCase.php', + ]; + + foreach ($filesToRemove as $fileToRemove) { + NetteFileSystem::delete($fileToRemove); + } + } + + private function removeDevContent(array $json): array + { + $keysToRemove = ['require-dev', 'autoload-dev', 'minimum-stability', 'prefer-stable', 'extra']; + + foreach ($keysToRemove as $keyToRemove) { + unset($json[$keyToRemove]); + } + + return $json; + } + + /** + * Their autoloader is broken inside the phar :/ + */ + private function fixPhpCodeSnifferAutoloading(array $json): array + { + $json['autoload']['classmap'][] = 'vendor/squizlabs/php_codesniffer/src'; + + return $json; + } +} diff --git a/packages/EasyCodingStandard/compiler/src/Exception/ShouldNotHappenException.php b/packages/EasyCodingStandard/compiler/src/Exception/ShouldNotHappenException.php new file mode 100644 index 0000000000..c355307f72 --- /dev/null +++ b/packages/EasyCodingStandard/compiler/src/Exception/ShouldNotHappenException.php @@ -0,0 +1,11 @@ +symplifyVersionToRequire !== null) { + return $this->symplifyVersionToRequire; + } + + $symplifyPackageContent = file_get_contents('https://repo.packagist.org/p/symplify/symplify.json'); + if ($symplifyPackageContent === null) { + throw new ShouldNotHappenException(); + } + + $symplifyPackageJson = $this->loadContentJsonStringToArray($symplifyPackageContent); + $symplifyPackageVersions = $symplifyPackageJson['packages']['symplify/symplify']; + + $lastStableVersion = $this->getLastKey($symplifyPackageVersions); + + $lastStableVersion = new Version($lastStableVersion); + + $this->symplifyVersionToRequire = '^' . $lastStableVersion->getMajor()->getValue() . '.' . $lastStableVersion->getMinor()->getValue(); + + return $this->symplifyVersionToRequire; + } + + private function loadContentJsonStringToArray(string $jsonContent): array + { + return Json::decode($jsonContent, Json::FORCE_ARRAY); + } + + private function getLastKey(array $items): string + { + end($items); + + return key($items); + } +} diff --git a/packages/EasyCodingStandard/compiler/src/Process/CompileProcessFactory.php b/packages/EasyCodingStandard/compiler/src/Process/CompileProcessFactory.php new file mode 100644 index 0000000000..c9306c297f --- /dev/null +++ b/packages/EasyCodingStandard/compiler/src/Process/CompileProcessFactory.php @@ -0,0 +1,34 @@ +output = new NullOutput(); + } + + /** + * @param string[] $command + */ + public function create(array $command, string $cwd): SymfonyProcess + { + return new SymfonyProcess($command, $cwd, $this->output); + } + + public function setOutput(OutputInterface $output): void + { + $this->output = $output; + } +} diff --git a/packages/EasyCodingStandard/compiler/src/Process/SymfonyProcess.php b/packages/EasyCodingStandard/compiler/src/Process/SymfonyProcess.php new file mode 100644 index 0000000000..35e0d4fbe7 --- /dev/null +++ b/packages/EasyCodingStandard/compiler/src/Process/SymfonyProcess.php @@ -0,0 +1,22 @@ +mustRun(static function (string $type, string $buffer) use ($output): void { + $output->write($buffer); + }); + } +} diff --git a/packages/EasyCodingStandard/composer.json b/packages/EasyCodingStandard/composer.json index c936847459..987ec3a944 100644 --- a/packages/EasyCodingStandard/composer.json +++ b/packages/EasyCodingStandard/composer.json @@ -8,8 +8,14 @@ "require": { "php": "^7.2", "composer/xdebug-handler": "^1.4", + "friendsofphp/php-cs-fixer": "^2.16", + "jean85/pretty-package-versions": "^1.2", "nette/utils": "^3.0", "nette/robot-loader": "^3.2", + "ocramius/package-versions": "^1.4", + "psr/simple-cache": "^1.0", + "squizlabs/php_codesniffer": "^3.5", + "slevomat/coding-standard": "^6.0", "symfony/cache": "^4.4|^5.0", "symfony/console": "^4.4|^5.0", "symfony/config": "^4.4|^5.0", @@ -22,13 +28,7 @@ "symplify/set-config-resolver": "^7.3", "symplify/smart-file-system": "^7.3", "symplify/autowire-array-parameter": "^7.3", - "symplify/auto-bind-parameter": "^7.3", - "slevomat/coding-standard": "^6.0", - "friendsofphp/php-cs-fixer": "^2.16", - "squizlabs/php_codesniffer": "^3.5", - "jean85/pretty-package-versions": "^1.2", - "ocramius/package-versions": "^1.4", - "psr/simple-cache": "^1.0" + "symplify/auto-bind-parameter": "^7.3" }, "require-dev": { "phpunit/phpunit": "^8.5", @@ -51,6 +51,9 @@ "Symplify\\EasyCodingStandard\\Tests\\": "tests" } }, + "replace": { + "symfony/polyfill-php70": "*" + }, "extra": { "branch-alias": { "dev-master": "7.3-dev" diff --git a/packages/EasyCodingStandard/config/services.yaml b/packages/EasyCodingStandard/config/services.yaml index 50685e95b8..52a5f570af 100644 --- a/packages/EasyCodingStandard/config/services.yaml +++ b/packages/EasyCodingStandard/config/services.yaml @@ -9,20 +9,12 @@ services: Symplify\EasyCodingStandard\: resource: '../src' exclude: - - '../src/Contract' - - '../src/DependencyInjection' - - '../src/HttpKernel' - - '../src/Exception' - - '../src/Error/Error.php' - - '../src/Error/FileDiff.php' - - '../src/Yaml' - - _instanceof: - Symplify\EasyCodingStandard\Contract\Application\FileProcessorCollectorInterface: - calls: - # orders matters, so Fixer can cleanup after Sniffer - - ['addFileProcessor', ['@Symplify\EasyCodingStandard\SniffRunner\Application\SniffFileProcessor']] - - ['addFileProcessor', ['@Symplify\EasyCodingStandard\FixerRunner\Application\FixerFileProcessor']] + - '../src/Contract/*' + - '../src/DependencyInjection/*' + - '../src/HttpKernel/*' + - '../src/Exception/*' + - '../src/ValueObject/*' + - '../src/Yaml/*' # Console Symfony\Component\Console\Terminal: ~ diff --git a/packages/EasyCodingStandard/config/set/php_cs_fixer/php-cs-fixer-psr2.yaml b/packages/EasyCodingStandard/config/set/php_cs_fixer/php-cs-fixer-psr2.yaml index cb46d9388b..6c1d69a2ba 100644 --- a/packages/EasyCodingStandard/config/set/php_cs_fixer/php-cs-fixer-psr2.yaml +++ b/packages/EasyCodingStandard/config/set/php_cs_fixer/php-cs-fixer-psr2.yaml @@ -1,4 +1,4 @@ -# updated to PHP CS Fixer v2.11.0 +# updated to PHP CS Fixer v2.11.0 from https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/src/RuleSet.php services: # PSR1 diff --git a/packages/EasyCodingStandard/packages/Configuration/config/services.yaml b/packages/EasyCodingStandard/packages/Configuration/config/services.yaml index c009c6caf3..2e1fb0cdaf 100644 --- a/packages/EasyCodingStandard/packages/Configuration/config/services.yaml +++ b/packages/EasyCodingStandard/packages/Configuration/config/services.yaml @@ -6,4 +6,4 @@ services: Symplify\EasyCodingStandard\Configuration\: resource: '../src' exclude: - - '../src/Exception' + - '../src/Exception/*' diff --git a/packages/EasyCodingStandard/packages/FixerRunner/config/services.yaml b/packages/EasyCodingStandard/packages/FixerRunner/config/services.yaml index f8ea95f9c4..efc62e2ce6 100644 --- a/packages/EasyCodingStandard/packages/FixerRunner/config/services.yaml +++ b/packages/EasyCodingStandard/packages/FixerRunner/config/services.yaml @@ -6,7 +6,7 @@ services: Symplify\EasyCodingStandard\FixerRunner\: resource: '../src' exclude: - - '../src/Exception' + - '../src/Exception/*' # differ PhpCsFixer\Differ\UnifiedDiffer: ~ diff --git a/packages/EasyCodingStandard/packages/SniffRunner/config/services.yaml b/packages/EasyCodingStandard/packages/SniffRunner/config/services.yaml index 7e0c50c449..21f85df7c0 100644 --- a/packages/EasyCodingStandard/packages/SniffRunner/config/services.yaml +++ b/packages/EasyCodingStandard/packages/SniffRunner/config/services.yaml @@ -6,5 +6,5 @@ services: Symplify\EasyCodingStandard\SniffRunner\: resource: '../src' exclude: - - '../src/Exception' - - '../src/File/File.php' + - '../src/Exception/*' + - '../src/ValueObject/*' diff --git a/packages/EasyCodingStandard/packages/SniffRunner/src/Application/SniffFileProcessor.php b/packages/EasyCodingStandard/packages/SniffRunner/src/Application/SniffFileProcessor.php index 2a95418993..c0d8e805ba 100644 --- a/packages/EasyCodingStandard/packages/SniffRunner/src/Application/SniffFileProcessor.php +++ b/packages/EasyCodingStandard/packages/SniffRunner/src/Application/SniffFileProcessor.php @@ -16,8 +16,8 @@ use Symplify\EasyCodingStandard\Contract\Application\DualRunInterface; use Symplify\EasyCodingStandard\Contract\Application\FileProcessorInterface; use Symplify\EasyCodingStandard\Error\ErrorAndDiffCollector; -use Symplify\EasyCodingStandard\SniffRunner\File\File; use Symplify\EasyCodingStandard\SniffRunner\File\FileFactory; +use Symplify\EasyCodingStandard\SniffRunner\ValueObject\File; use Symplify\SmartFileSystem\SmartFileInfo; final class SniffFileProcessor implements FileProcessorInterface, DualRunAwareFileProcessorInterface diff --git a/packages/EasyCodingStandard/packages/SniffRunner/src/File/FileFactory.php b/packages/EasyCodingStandard/packages/SniffRunner/src/File/FileFactory.php index 2dea10aa62..d3547a2f1a 100644 --- a/packages/EasyCodingStandard/packages/SniffRunner/src/File/FileFactory.php +++ b/packages/EasyCodingStandard/packages/SniffRunner/src/File/FileFactory.php @@ -9,6 +9,7 @@ use Symplify\EasyCodingStandard\Console\Style\EasyCodingStandardStyle; use Symplify\EasyCodingStandard\Error\ErrorAndDiffCollector; use Symplify\EasyCodingStandard\Skipper; +use Symplify\EasyCodingStandard\SniffRunner\ValueObject\File; use Symplify\SmartFileSystem\SmartFileInfo; final class FileFactory diff --git a/packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php b/packages/EasyCodingStandard/packages/SniffRunner/src/ValueObject/File.php similarity index 99% rename from packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php rename to packages/EasyCodingStandard/packages/SniffRunner/src/ValueObject/File.php index 0a2308e18e..aecdf58457 100644 --- a/packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php +++ b/packages/EasyCodingStandard/packages/SniffRunner/src/ValueObject/File.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Symplify\EasyCodingStandard\SniffRunner\File; +namespace Symplify\EasyCodingStandard\SniffRunner\ValueObject; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Files\File as BaseFile; diff --git a/packages/EasyCodingStandard/packages/SniffRunner/tests/Application/FixerTest.php b/packages/EasyCodingStandard/packages/SniffRunner/tests/Application/FixerTest.php index c5c6c29980..ebe5409266 100644 --- a/packages/EasyCodingStandard/packages/SniffRunner/tests/Application/FixerTest.php +++ b/packages/EasyCodingStandard/packages/SniffRunner/tests/Application/FixerTest.php @@ -6,8 +6,8 @@ use PHP_CodeSniffer\Fixer; use Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel; -use Symplify\EasyCodingStandard\SniffRunner\File\File; use Symplify\EasyCodingStandard\SniffRunner\File\FileFactory; +use Symplify\EasyCodingStandard\SniffRunner\ValueObject\File; use Symplify\PackageBuilder\Tests\AbstractKernelTestCase; use Symplify\SmartFileSystem\SmartFileInfo; diff --git a/packages/EasyCodingStandard/packages/SniffRunner/tests/Error/ErrorSorterTest.php b/packages/EasyCodingStandard/packages/SniffRunner/tests/Error/ErrorSorterTest.php index 042980e6c3..031bba28c9 100644 --- a/packages/EasyCodingStandard/packages/SniffRunner/tests/Error/ErrorSorterTest.php +++ b/packages/EasyCodingStandard/packages/SniffRunner/tests/Error/ErrorSorterTest.php @@ -4,10 +4,10 @@ namespace Symplify\EasyCodingStandard\SniffRunner\Tests\Error; -use Symplify\EasyCodingStandard\Error\Error; use Symplify\EasyCodingStandard\Error\ErrorFactory; use Symplify\EasyCodingStandard\Error\ErrorSorter; use Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel; +use Symplify\EasyCodingStandard\ValueObject\Error\Error; use Symplify\PackageBuilder\Tests\AbstractKernelTestCase; use Symplify\SmartFileSystem\SmartFileInfo; diff --git a/packages/EasyCodingStandard/packages/SniffRunner/tests/File/FileFactoryTest.php b/packages/EasyCodingStandard/packages/SniffRunner/tests/File/FileFactoryTest.php index 72e2165c38..7acd374e51 100644 --- a/packages/EasyCodingStandard/packages/SniffRunner/tests/File/FileFactoryTest.php +++ b/packages/EasyCodingStandard/packages/SniffRunner/tests/File/FileFactoryTest.php @@ -7,8 +7,8 @@ use PHP_CodeSniffer\Files\File as PhpCodeSnifferFile; use PHP_CodeSniffer\Fixer; use Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel; -use Symplify\EasyCodingStandard\SniffRunner\File\File; use Symplify\EasyCodingStandard\SniffRunner\File\FileFactory; +use Symplify\EasyCodingStandard\SniffRunner\ValueObject\File; use Symplify\PackageBuilder\Tests\AbstractKernelTestCase; use Symplify\SmartFileSystem\SmartFileInfo; diff --git a/packages/EasyCodingStandard/packages/SniffRunner/tests/ValueObject/FileSource/SomeFile.php b/packages/EasyCodingStandard/packages/SniffRunner/tests/ValueObject/FileSource/SomeFile.php new file mode 100644 index 0000000000..174d7fd709 --- /dev/null +++ b/packages/EasyCodingStandard/packages/SniffRunner/tests/ValueObject/FileSource/SomeFile.php @@ -0,0 +1,3 @@ +errorAndDiffCollector = self::$container->get(ErrorAndDiffCollector::class); $fileFactory = self::$container->get(FileFactory::class); - $fileInfo = new SmartFileInfo(__DIR__ . '/FileFactorySource/SomeFile.php'); + $fileInfo = new SmartFileInfo(__DIR__ . '/FileSource/SomeFile.php'); $this->file = $fileFactory->createFromFileInfo($fileInfo); $this->file->processWithTokenListenersAndFileInfo([], $fileInfo); diff --git a/packages/EasyCodingStandard/src/Application/EasyCodingStandardApplication.php b/packages/EasyCodingStandard/src/Application/EasyCodingStandardApplication.php index a6c6a110d0..697c37bd3d 100644 --- a/packages/EasyCodingStandard/src/Application/EasyCodingStandardApplication.php +++ b/packages/EasyCodingStandard/src/Application/EasyCodingStandardApplication.php @@ -8,19 +8,12 @@ use Symplify\EasyCodingStandard\Configuration\Configuration; use Symplify\EasyCodingStandard\Console\Style\EasyCodingStandardStyle; use Symplify\EasyCodingStandard\Contract\Application\DualRunAwareFileProcessorInterface; -use Symplify\EasyCodingStandard\Contract\Application\FileProcessorCollectorInterface; -use Symplify\EasyCodingStandard\Contract\Application\FileProcessorInterface; use Symplify\EasyCodingStandard\FileSystem\FileFilter; use Symplify\EasyCodingStandard\Finder\SourceFinder; use Symplify\SmartFileSystem\SmartFileInfo; -final class EasyCodingStandardApplication implements FileProcessorCollectorInterface +final class EasyCodingStandardApplication { - /** - * @var FileProcessorInterface[] - */ - private $fileProcessors = []; - /** * @var EasyCodingStandardStyle */ @@ -51,13 +44,19 @@ final class EasyCodingStandardApplication implements FileProcessorCollectorInter */ private $singleFileProcessor; + /** + * @var FileProcessorCollector + */ + private $fileProcessorCollector; + public function __construct( EasyCodingStandardStyle $easyCodingStandardStyle, SourceFinder $sourceFinder, ChangedFilesDetector $changedFilesDetector, Configuration $configuration, FileFilter $fileFilter, - SingleFileProcessor $singleFileProcessor + SingleFileProcessor $singleFileProcessor, + FileProcessorCollector $fileProcessorCollector ) { $this->easyCodingStandardStyle = $easyCodingStandardStyle; $this->sourceFinder = $sourceFinder; @@ -65,11 +64,7 @@ public function __construct( $this->configuration = $configuration; $this->fileFilter = $fileFilter; $this->singleFileProcessor = $singleFileProcessor; - } - - public function addFileProcessor(FileProcessorInterface $fileProcessor): void - { - $this->fileProcessors[] = $fileProcessor; + $this->fileProcessorCollector = $fileProcessorCollector; } public function run(): int @@ -109,7 +104,7 @@ public function getCheckerCount(): int { $checkerCount = 0; - foreach ($this->fileProcessors as $fileProcessor) { + foreach ($this->fileProcessorCollector->getFileProcessors() as $fileProcessor) { $checkerCount += count($fileProcessor->getCheckers()); } @@ -118,7 +113,7 @@ public function getCheckerCount(): int private function isDualRunEnabled(): bool { - foreach ($this->fileProcessors as $fileProcessor) { + foreach ($this->fileProcessorCollector->getFileProcessors() as $fileProcessor) { if (! $fileProcessor instanceof DualRunAwareFileProcessorInterface) { continue; } @@ -150,7 +145,7 @@ private function processFoundFilesSecondRun(array $fileInfos): void { foreach ($fileInfos as $fileInfo) { $this->processFileInfoWithCallable($fileInfo, function (SmartFileInfo $smartFileInfo): void { - foreach ($this->fileProcessors as $fileProcessor) { + foreach ($this->fileProcessorCollector->getFileProcessors() as $fileProcessor) { if ($fileProcessor instanceof DualRunAwareFileProcessorInterface) { $fileProcessor->processFileSecondRun($smartFileInfo); } diff --git a/packages/EasyCodingStandard/src/Application/FileProcessorCollector.php b/packages/EasyCodingStandard/src/Application/FileProcessorCollector.php new file mode 100644 index 0000000000..e196edd4b8 --- /dev/null +++ b/packages/EasyCodingStandard/src/Application/FileProcessorCollector.php @@ -0,0 +1,34 @@ +fileProcessors[] = $sniffFileProcessor; + $this->fileProcessors[] = $fixerFileProcessor; + } + + /** + * @return FileProcessorInterface[] + */ + public function getFileProcessors(): array + { + return $this->fileProcessors; + } +} diff --git a/packages/EasyCodingStandard/src/Application/SingleFileProcessor.php b/packages/EasyCodingStandard/src/Application/SingleFileProcessor.php index 07695e5b13..fda6c245cd 100644 --- a/packages/EasyCodingStandard/src/Application/SingleFileProcessor.php +++ b/packages/EasyCodingStandard/src/Application/SingleFileProcessor.php @@ -6,19 +6,12 @@ use ParseError; use Symplify\EasyCodingStandard\ChangedFilesDetector\ChangedFilesDetector; -use Symplify\EasyCodingStandard\Contract\Application\FileProcessorCollectorInterface; -use Symplify\EasyCodingStandard\Contract\Application\FileProcessorInterface; use Symplify\EasyCodingStandard\Error\ErrorAndDiffCollector; use Symplify\EasyCodingStandard\Skipper; use Symplify\SmartFileSystem\SmartFileInfo; -final class SingleFileProcessor implements FileProcessorCollectorInterface +final class SingleFileProcessor { - /** - * @var FileProcessorInterface[] - */ - private $fileProcessors = []; - /** * @var Skipper */ @@ -34,26 +27,28 @@ final class SingleFileProcessor implements FileProcessorCollectorInterface */ private $errorAndDiffCollector; + /** + * @var FileProcessorCollector + */ + private $fileProcessorCollector; + public function __construct( Skipper $skipper, ChangedFilesDetector $changedFilesDetector, - ErrorAndDiffCollector $errorAndDiffCollector + ErrorAndDiffCollector $errorAndDiffCollector, + FileProcessorCollector $fileProcessorCollector ) { $this->skipper = $skipper; $this->changedFilesDetector = $changedFilesDetector; $this->errorAndDiffCollector = $errorAndDiffCollector; - } - - public function addFileProcessor(FileProcessorInterface $fileProcessor): void - { - $this->fileProcessors[] = $fileProcessor; + $this->fileProcessorCollector = $fileProcessorCollector; } public function processFileInfo(SmartFileInfo $smartFileInfo): void { try { $this->changedFilesDetector->addFileInfo($smartFileInfo); - foreach ($this->fileProcessors as $fileProcessor) { + foreach ($this->fileProcessorCollector->getFileProcessors() as $fileProcessor) { if ($fileProcessor->getCheckers() === []) { continue; } diff --git a/packages/EasyCodingStandard/src/Console/Output/ConsoleOutputFormatter.php b/packages/EasyCodingStandard/src/Console/Output/ConsoleOutputFormatter.php index a59646cad4..434f4be764 100644 --- a/packages/EasyCodingStandard/src/Console/Output/ConsoleOutputFormatter.php +++ b/packages/EasyCodingStandard/src/Console/Output/ConsoleOutputFormatter.php @@ -8,7 +8,7 @@ use Symplify\EasyCodingStandard\Console\Style\EasyCodingStandardStyle; use Symplify\EasyCodingStandard\Contract\Console\Output\OutputFormatterInterface; use Symplify\EasyCodingStandard\Error\ErrorAndDiffCollector; -use Symplify\EasyCodingStandard\Error\FileDiff; +use Symplify\EasyCodingStandard\ValueObject\Error\FileDiff; use Symplify\PackageBuilder\Console\ShellCode; final class ConsoleOutputFormatter implements OutputFormatterInterface diff --git a/packages/EasyCodingStandard/src/Console/Output/JsonOutputFormatter.php b/packages/EasyCodingStandard/src/Console/Output/JsonOutputFormatter.php index 7e0ba82fad..18d5d0bc90 100644 --- a/packages/EasyCodingStandard/src/Console/Output/JsonOutputFormatter.php +++ b/packages/EasyCodingStandard/src/Console/Output/JsonOutputFormatter.php @@ -8,9 +8,9 @@ use Symplify\EasyCodingStandard\Configuration\Configuration; use Symplify\EasyCodingStandard\Console\Style\EasyCodingStandardStyle; use Symplify\EasyCodingStandard\Contract\Console\Output\OutputFormatterInterface; -use Symplify\EasyCodingStandard\Error\Error; use Symplify\EasyCodingStandard\Error\ErrorAndDiffCollector; -use Symplify\EasyCodingStandard\Error\FileDiff; +use Symplify\EasyCodingStandard\ValueObject\Error\Error; +use Symplify\EasyCodingStandard\ValueObject\Error\FileDiff; use Symplify\PackageBuilder\Console\ShellCode; final class JsonOutputFormatter implements OutputFormatterInterface diff --git a/packages/EasyCodingStandard/src/Console/Style/EasyCodingStandardStyle.php b/packages/EasyCodingStandard/src/Console/Style/EasyCodingStandardStyle.php index d3a824dadf..1def668d89 100644 --- a/packages/EasyCodingStandard/src/Console/Style/EasyCodingStandardStyle.php +++ b/packages/EasyCodingStandard/src/Console/Style/EasyCodingStandardStyle.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Terminal; -use Symplify\EasyCodingStandard\Error\Error; +use Symplify\EasyCodingStandard\ValueObject\Error\Error; final class EasyCodingStandardStyle extends SymfonyStyle { diff --git a/packages/EasyCodingStandard/src/Contract/Application/FileProcessorCollectorInterface.php b/packages/EasyCodingStandard/src/Contract/Application/FileProcessorCollectorInterface.php deleted file mode 100644 index 540e2a8e63..0000000000 --- a/packages/EasyCodingStandard/src/Contract/Application/FileProcessorCollectorInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -createFromContainerBuilderAndFileLocator($containerBuilder, new FileLocator($kernel)); + $kernelFileLocator = new FileLocator($kernel); + + return $this->createFromContainerBuilderAndFileLocator($containerBuilder, $kernelFileLocator); } /** @@ -29,7 +31,8 @@ public function createContainerBuilderAndConfig( ContainerBuilder $containerBuilder, string $config ): DelegatingLoader { - $fileLocator = new SimpleFileLocator(dirname($config)); + $directory = dirname($config); + $fileLocator = new SimpleFileLocator($directory); return $this->createFromContainerBuilderAndFileLocator($containerBuilder, $fileLocator); } diff --git a/packages/EasyCodingStandard/src/Error/ErrorAndDiffCollector.php b/packages/EasyCodingStandard/src/Error/ErrorAndDiffCollector.php index 14037cb01a..eebf5f0814 100644 --- a/packages/EasyCodingStandard/src/Error/ErrorAndDiffCollector.php +++ b/packages/EasyCodingStandard/src/Error/ErrorAndDiffCollector.php @@ -6,6 +6,8 @@ use Nette\Utils\Arrays; use Symplify\EasyCodingStandard\ChangedFilesDetector\ChangedFilesDetector; +use Symplify\EasyCodingStandard\ValueObject\Error\Error; +use Symplify\EasyCodingStandard\ValueObject\Error\FileDiff; use Symplify\SmartFileSystem\SmartFileInfo; final class ErrorAndDiffCollector diff --git a/packages/EasyCodingStandard/src/Error/ErrorFactory.php b/packages/EasyCodingStandard/src/Error/ErrorFactory.php index 747fa4aab3..ad09a26045 100644 --- a/packages/EasyCodingStandard/src/Error/ErrorFactory.php +++ b/packages/EasyCodingStandard/src/Error/ErrorFactory.php @@ -4,6 +4,7 @@ namespace Symplify\EasyCodingStandard\Error; +use Symplify\EasyCodingStandard\ValueObject\Error\Error; use Symplify\SmartFileSystem\SmartFileInfo; final class ErrorFactory diff --git a/packages/EasyCodingStandard/src/Error/ErrorSorter.php b/packages/EasyCodingStandard/src/Error/ErrorSorter.php index d7f20aa0c8..26076b22de 100644 --- a/packages/EasyCodingStandard/src/Error/ErrorSorter.php +++ b/packages/EasyCodingStandard/src/Error/ErrorSorter.php @@ -4,6 +4,8 @@ namespace Symplify\EasyCodingStandard\Error; +use Symplify\EasyCodingStandard\ValueObject\Error\Error; + final class ErrorSorter { /** diff --git a/packages/EasyCodingStandard/src/Error/FileDiffFactory.php b/packages/EasyCodingStandard/src/Error/FileDiffFactory.php index 0ab1b705f7..18f9755b2e 100644 --- a/packages/EasyCodingStandard/src/Error/FileDiffFactory.php +++ b/packages/EasyCodingStandard/src/Error/FileDiffFactory.php @@ -4,6 +4,8 @@ namespace Symplify\EasyCodingStandard\Error; +use Symplify\EasyCodingStandard\ValueObject\Error\FileDiff; + final class FileDiffFactory { /** diff --git a/packages/EasyCodingStandard/src/HttpKernel/EasyCodingStandardKernel.php b/packages/EasyCodingStandard/src/HttpKernel/EasyCodingStandardKernel.php index acb90d386e..78c076e95a 100644 --- a/packages/EasyCodingStandard/src/HttpKernel/EasyCodingStandardKernel.php +++ b/packages/EasyCodingStandard/src/HttpKernel/EasyCodingStandardKernel.php @@ -105,6 +105,8 @@ protected function build(ContainerBuilder $containerBuilder): void */ protected function getContainerLoader(ContainerInterface $container): DelegatingLoader { - return (new DelegatingLoaderFactory())->createFromContainerBuilderAndKernel($container, $this); + $delegatingLoaderFactory = new DelegatingLoaderFactory(); + + return $delegatingLoaderFactory->createFromContainerBuilderAndKernel($container, $this); } } diff --git a/packages/EasyCodingStandard/src/Error/Error.php b/packages/EasyCodingStandard/src/ValueObject/Error/Error.php similarity index 94% rename from packages/EasyCodingStandard/src/Error/Error.php rename to packages/EasyCodingStandard/src/ValueObject/Error/Error.php index 2a2270c4d9..052f197ee3 100644 --- a/packages/EasyCodingStandard/src/Error/Error.php +++ b/packages/EasyCodingStandard/src/ValueObject/Error/Error.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Symplify\EasyCodingStandard\Error; +namespace Symplify\EasyCodingStandard\ValueObject\Error; use Symplify\SmartFileSystem\SmartFileInfo; diff --git a/packages/EasyCodingStandard/src/Error/FileDiff.php b/packages/EasyCodingStandard/src/ValueObject/Error/FileDiff.php similarity index 95% rename from packages/EasyCodingStandard/src/Error/FileDiff.php rename to packages/EasyCodingStandard/src/ValueObject/Error/FileDiff.php index a51a9789b1..8a94476ff0 100644 --- a/packages/EasyCodingStandard/src/Error/FileDiff.php +++ b/packages/EasyCodingStandard/src/ValueObject/Error/FileDiff.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Symplify\EasyCodingStandard\Error; +namespace Symplify\EasyCodingStandard\ValueObject\Error; use PhpCsFixer\Differ\DiffConsoleFormatter; diff --git a/packages/MonorepoBuilder/src/ComposerJsonDecorator/ReplaceSectionJsonDecorator.php b/packages/MonorepoBuilder/src/ComposerJsonDecorator/ReplaceSectionJsonDecorator.php index b146bde281..81bc807fa5 100644 --- a/packages/MonorepoBuilder/src/ComposerJsonDecorator/ReplaceSectionJsonDecorator.php +++ b/packages/MonorepoBuilder/src/ComposerJsonDecorator/ReplaceSectionJsonDecorator.php @@ -29,6 +29,11 @@ public function decorate(array $composerJson): array sort($mergedPackages); foreach ($mergedPackages as $mergedPackage) { + // prevent value override + if (isset($composerJson['replace'][$mergedPackage])) { + continue; + } + $composerJson['replace'][$mergedPackage] = 'self.version'; } diff --git a/phpstan.neon b/phpstan.neon index 94e81ed5f0..570af8c527 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -18,9 +18,10 @@ parameters: # Symfony workaround - packages/ChangelogLinker/src/DependencyInjection/Dummy/ResolveAutowiringExceptionHelper.php # 3rd party - - packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php + - packages/EasyCodingStandard/packages/SniffRunner/src/ValueObject/File.php # tests - packages/PHPStanExtensions/tests/Rules/ClassMethod/Source/* + - packages/EasyCodingStandard/compiler/vendor/* autoload_files: - %currentWorkingDirectory%/tests/bootstrap.php @@ -132,3 +133,8 @@ parameters: - '#in iterable type#' - '#Method Symplify\\PHPStanExtensions\\Tests\\Rules\\Classes\\MatchingTypeConstantRuleTest\:\:getRule\(\) return type with generic interface PHPStan\\Rules\\Rule does not specify its types\: TNodeType#' - '#Class Symplify\\PHPStanExtensions\\Rules\\ClassMethod\\BoolishClassMethodPrefixRule implements generic interface PHPStan\\Rules\\Rule but does not specify its types\: TNodeType#' + + - '#Strict comparison using \=\=\= between string\|false and null will always evaluate to false#' + - '#Parameter \#1 \$json of static method Nette\\Utils\\Json\:\:decode\(\) expects string, string\|false given#' + - '#Parameter \#1 \$jsonContent of method Symplify\\EasyCodingStandard\\Compiler\\Packagist\\SymplifyStableVersionProvider\:\:loadContentJsonStringToArray\(\) expects string, string\|false given#' + - '#Method Symplify\\EasyCodingStandard\\Compiler\\Packagist\\SymplifyStableVersionProvider\:\:getLastKey\(\) should return string but returns int\|string\|null#'