Skip to content

Commit e9ca9cb

Browse files
committed
Updated ECS to commit fa59fd61d7e9a706fb1d8081b4bd5ae3b1f86338
deprecated-packages/symplify@fa59fd6 [ESC] Rebuild cache just once per release (#3359)
1 parent 3a3c599 commit e9ca9cb

File tree

12 files changed

+91
-30
lines changed

12 files changed

+91
-30
lines changed

.gitattributes

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
/tests export-ignore
2-
.gitattributes export-ignore
3-
.gitignore export-ignore
4-
*.md export-ignore
5-
docs/ export-ignore

.github/workflows/bare_run.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ jobs:
2121
coverage: none
2222

2323
- run: php bin/ecs list --ansi --debug
24+
25+
- run: php bin/ecs init --ansi --debug
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check Command Run
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
check_command_run:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0']
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
-
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php_version }}
21+
coverage: none
22+
23+
- run: php bin/ecs check tests/Fixture --config tests/config/some_ecs.php --ansi

config/config.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
namespace ECSPrefix20210628;
55

66
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
7-
use Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel;
7+
use Symplify\EasyCodingStandard\Application\Version\VersionResolver;
88
use Symplify\EasyCodingStandard\ValueObject\Option;
99
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) {
1010
$containerConfigurator->import(__DIR__ . '/services.php');
1111
$containerConfigurator->import(__DIR__ . '/packages.php');
1212
$parameters = $containerConfigurator->parameters();
1313
$parameters->set(\Symplify\EasyCodingStandard\ValueObject\Option::INDENTATION, \Symplify\EasyCodingStandard\ValueObject\Option::INDENTATION_SPACES);
1414
$parameters->set(\Symplify\EasyCodingStandard\ValueObject\Option::LINE_ENDING, \PHP_EOL);
15-
$parameters->set(\Symplify\EasyCodingStandard\ValueObject\Option::CACHE_DIRECTORY, \sys_get_temp_dir() . '/changed_files_detector%env(TEST_SUFFIX)%' . \Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel::CONTAINER_VERSION);
15+
$cacheDirectory = \sys_get_temp_dir() . '/changed_files_detector%env(TEST_SUFFIX)%';
16+
if (\Symplify\EasyCodingStandard\Application\Version\VersionResolver::PACKAGE_VERSION !== '@package_version@') {
17+
$cacheDirectory .= '_' . \Symplify\EasyCodingStandard\Application\Version\VersionResolver::PACKAGE_VERSION;
18+
}
19+
$parameters->set(\Symplify\EasyCodingStandard\ValueObject\Option::CACHE_DIRECTORY, $cacheDirectory);
1620
$cacheNamespace = \str_replace(\DIRECTORY_SEPARATOR, '_', \getcwd());
1721
$parameters->set(\Symplify\EasyCodingStandard\ValueObject\Option::CACHE_NAMESPACE, $cacheNamespace);
1822
// parallel

src/DependencyInjection/EasyCodingStandardContainerFactory.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use ECSPrefix20210628\Symfony\Component\Console\Input\InputInterface;
77
use ECSPrefix20210628\Symfony\Component\DependencyInjection\ContainerInterface;
8+
use Symplify\EasyCodingStandard\Application\Version\VersionResolver;
89
use Symplify\EasyCodingStandard\Caching\ChangedFilesDetector;
910
use Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel;
1011
use ECSPrefix20210628\Symplify\PackageBuilder\Console\Input\StaticInputDetector;
@@ -13,7 +14,7 @@ final class EasyCodingStandardContainerFactory
1314
{
1415
public function createFromFromInput(\ECSPrefix20210628\Symfony\Component\Console\Input\InputInterface $input) : \ECSPrefix20210628\Symfony\Component\DependencyInjection\ContainerInterface
1516
{
16-
$environment = 'easy_coding_standard_version_' . \Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel::CONTAINER_VERSION;
17+
$environment = $this->resolveEnvironment();
1718
$easyCodingStandardKernel = new \Symplify\EasyCodingStandard\HttpKernel\EasyCodingStandardKernel($environment, \ECSPrefix20210628\Symplify\PackageBuilder\Console\Input\StaticInputDetector::isDebug());
1819
$inputConfigFileInfos = [];
1920
$rootECSConfig = \getcwd() . \DIRECTORY_SEPARATOR . '/ecs.php';
@@ -38,4 +39,11 @@ public function createFromFromInput(\ECSPrefix20210628\Symfony\Component\Console
3839
}
3940
return $container;
4041
}
42+
private function resolveEnvironment() : string
43+
{
44+
if (\Symplify\EasyCodingStandard\Application\Version\VersionResolver::PACKAGE_VERSION === '@package_version@') {
45+
return 'dev';
46+
}
47+
return 'prod_' . \Symplify\EasyCodingStandard\Application\Version\VersionResolver::PACKAGE_VERSION;
48+
}
4149
}

src/HttpKernel/EasyCodingStandardKernel.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,38 @@
99
use ECSPrefix20210628\Symfony\Component\HttpKernel\Bundle\BundleInterface;
1010
use Symplify\CodingStandard\Bundle\SymplifyCodingStandardBundle;
1111
use ECSPrefix20210628\Symplify\ConsoleColorDiff\Bundle\ConsoleColorDiffBundle;
12+
use Symplify\EasyCodingStandard\Application\Version\VersionResolver;
1213
use Symplify\EasyCodingStandard\Bundle\EasyCodingStandardBundle;
1314
use Symplify\EasyCodingStandard\DependencyInjection\DelegatingLoaderFactory;
1415
use ECSPrefix20210628\Symplify\Skipper\Bundle\SkipperBundle;
1516
use ECSPrefix20210628\Symplify\SymplifyKernel\Bundle\SymplifyKernelBundle;
1617
use ECSPrefix20210628\Symplify\SymplifyKernel\HttpKernel\AbstractSymplifyKernel;
1718
final class EasyCodingStandardKernel extends \ECSPrefix20210628\Symplify\SymplifyKernel\HttpKernel\AbstractSymplifyKernel
1819
{
19-
/**
20-
* To enable Kernel cache that is changed only when new services are needed.
21-
*
22-
* @var string
23-
*/
24-
const CONTAINER_VERSION = 'v1';
2520
/**
2621
* @return mixed[]
2722
*/
2823
public function registerBundles()
2924
{
3025
return [new \Symplify\EasyCodingStandard\Bundle\EasyCodingStandardBundle(), new \Symplify\CodingStandard\Bundle\SymplifyCodingStandardBundle(), new \ECSPrefix20210628\Symplify\ConsoleColorDiff\Bundle\ConsoleColorDiffBundle(), new \ECSPrefix20210628\Symplify\SymplifyKernel\Bundle\SymplifyKernelBundle(), new \ECSPrefix20210628\Symplify\Skipper\Bundle\SkipperBundle()];
3126
}
27+
public function getCacheDir() : string
28+
{
29+
// the PACKAGE_VERSION constant helps to rebuild cache on new release, but just once
30+
$cacheDirectory = \sys_get_temp_dir() . '/ecs_' . \get_current_user();
31+
if (\Symplify\EasyCodingStandard\Application\Version\VersionResolver::PACKAGE_VERSION !== '@package_version@') {
32+
$cacheDirectory .= '_' . \Symplify\EasyCodingStandard\Application\Version\VersionResolver::PACKAGE_VERSION;
33+
}
34+
return $cacheDirectory;
35+
}
36+
public function getLogDir() : string
37+
{
38+
$logDirectory = \sys_get_temp_dir() . '/ecs_log_' . \get_current_user();
39+
if (\Symplify\EasyCodingStandard\Application\Version\VersionResolver::PACKAGE_VERSION !== '@package_version@') {
40+
$logDirectory .= '_' . \Symplify\EasyCodingStandard\Application\Version\VersionResolver::PACKAGE_VERSION;
41+
}
42+
return $logDirectory;
43+
}
3244
/**
3345
* @return void
3446
*/

tests/Fixture/SomeClass.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
4+
namespace App;
5+
6+
class SomeClass {}

tests/config/some_ecs.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
6+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
7+
8+
return static function (ContainerConfigurator $containerConfigurator): void {
9+
$containerConfigurator->import(SetList::PSR_12);
10+
};

vendor/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
require_once __DIR__ . '/composer/autoload_real.php';
66

7-
return ComposerAutoloaderInit18695cc0dfce4bcda568d48cddb6e6d1::getLoader();
7+
return ComposerAutoloaderInit42923fe255792072bb55ad9fa9212317::getLoader();

vendor/composer/autoload_real.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit18695cc0dfce4bcda568d48cddb6e6d1
5+
class ComposerAutoloaderInit42923fe255792072bb55ad9fa9212317
66
{
77
private static $loader;
88

@@ -22,15 +22,15 @@ public static function getLoader()
2222
return self::$loader;
2323
}
2424

25-
spl_autoload_register(array('ComposerAutoloaderInit18695cc0dfce4bcda568d48cddb6e6d1', 'loadClassLoader'), true, true);
25+
spl_autoload_register(array('ComposerAutoloaderInit42923fe255792072bb55ad9fa9212317', 'loadClassLoader'), true, true);
2626
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
27-
spl_autoload_unregister(array('ComposerAutoloaderInit18695cc0dfce4bcda568d48cddb6e6d1', 'loadClassLoader'));
27+
spl_autoload_unregister(array('ComposerAutoloaderInit42923fe255792072bb55ad9fa9212317', 'loadClassLoader'));
2828

2929
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
3030
if ($useStaticLoader) {
3131
require __DIR__ . '/autoload_static.php';
3232

33-
call_user_func(\Composer\Autoload\ComposerStaticInit18695cc0dfce4bcda568d48cddb6e6d1::getInitializer($loader));
33+
call_user_func(\Composer\Autoload\ComposerStaticInit42923fe255792072bb55ad9fa9212317::getInitializer($loader));
3434
} else {
3535
$classMap = require __DIR__ . '/autoload_classmap.php';
3636
if ($classMap) {
@@ -42,19 +42,19 @@ public static function getLoader()
4242
$loader->register(true);
4343

4444
if ($useStaticLoader) {
45-
$includeFiles = Composer\Autoload\ComposerStaticInit18695cc0dfce4bcda568d48cddb6e6d1::$files;
45+
$includeFiles = Composer\Autoload\ComposerStaticInit42923fe255792072bb55ad9fa9212317::$files;
4646
} else {
4747
$includeFiles = require __DIR__ . '/autoload_files.php';
4848
}
4949
foreach ($includeFiles as $fileIdentifier => $file) {
50-
composerRequire18695cc0dfce4bcda568d48cddb6e6d1($fileIdentifier, $file);
50+
composerRequire42923fe255792072bb55ad9fa9212317($fileIdentifier, $file);
5151
}
5252

5353
return $loader;
5454
}
5555
}
5656

57-
function composerRequire18695cc0dfce4bcda568d48cddb6e6d1($fileIdentifier, $file)
57+
function composerRequire42923fe255792072bb55ad9fa9212317($fileIdentifier, $file)
5858
{
5959
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
6060
require $file;

0 commit comments

Comments
 (0)