From b3e6ae4fe3abe502fd9d93a808457d86119cdeb6 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Fri, 20 Aug 2021 11:04:47 -0700 Subject: [PATCH 1/2] Make sure we are compatible with sf6 --- .github/workflows/ci.yml | 21 ++++++--------------- Readme.md | 2 +- src/AppKernel.php | 10 +++++----- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc3c519..c699173 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,51 +16,42 @@ jobs: - '' - 'lowest' symfony: - - '3.4.*' - '4.4.*' - - '5.0.*' + - '5.3.*' - '6.0.*' exclude: - - php: '7.2' - symfony: '3.4.*' - dependency: 'lowest' - php: '7.2' symfony: '4.4.*' dependency: 'lowest' - php: '7.2' symfony: '6.0.*' - - php: '7.3' - symfony: '3.4.*' - php: '7.3' symfony: '4.4.*' - php: '7.3' symfony: '6.0.*' - - php: '7.4' - symfony: '3.4.*' - php: '7.4' symfony: '4.4.*' - php: '7.4' symfony: '6.0.*' - - php: '8.0' - symfony: '3.4.*' - php: '8.0' symfony: '4.4.*' fail-fast: false steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: composer, flex, pcov + extensions: pcov + tools: flex - name: Configure Symfony run: composer config extra.symfony.require "${{ matrix.symfony }}" - name: Prefer unstable Composer dependencies if Symfony 6.0 - if: matrix.symfony == '6.0.x' + if: matrix.symfony == '6.0.*' run: composer config prefer-stable false - name: Get Composer Cache Directory @@ -68,7 +59,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/Readme.md b/Readme.md index 38e7e54..de25fc6 100644 --- a/Readme.md +++ b/Readme.md @@ -118,7 +118,7 @@ jobs: matrix: operating-system: [ ubuntu-latest, windows-latest ] php: [ '7.4', '8.0' ] - symfony: ['4.4', '5.3'] + symfony: ['^4.4', '^5.3'] steps: - uses: actions/checkout@master diff --git a/src/AppKernel.php b/src/AppKernel.php index 6a6446b..250626f 100644 --- a/src/AppKernel.php +++ b/src/AppKernel.php @@ -78,17 +78,17 @@ public function addConfigFile($configFile) $this->configFiles[] = $configFile; } - public function getCacheDir() + public function getCacheDir(): string { return sys_get_temp_dir().'/NyholmBundleTest/'.$this->cachePrefix; } - public function getLogDir() + public function getLogDir(): string { return sys_get_temp_dir().'/NyholmBundleTest/log'; } - public function getProjectDir() + public function getProjectDir(): string { if (null === $this->fakedProjectDir) { return realpath(__DIR__.'/../../../../'); @@ -113,7 +113,7 @@ public function setProjectDir($projectDir) $this->fakedProjectDir = $projectDir; } - public function registerBundles() + public function registerBundles(): iterable { $this->bundlesToRegister = array_unique($this->bundlesToRegister); $bundles = []; @@ -182,7 +182,7 @@ public function loadRoutes(LoaderInterface $loader) /** * {@inheritdoc} */ - protected function buildContainer() + protected function buildContainer(): ContainerBuilder { $container = parent::buildContainer(); From 5d82bed8c40537fb0d56a26c47a72acd1be67416 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 20 Aug 2021 11:27:27 -0700 Subject: [PATCH 2/2] Release 1.8.1 (#52) * Release 1.8.1 * Fixed routes * fix --- Changelog.md | 6 ++++++ psalm.baseline.xml | 14 ++++++++++++++ src/AppKernel.php | 34 ++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index ba65045..30ea150 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,12 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. +## 1.8.1 + +### Fixed + +- Symfony 6 compatibility issues + ## 1.8.0 ### Added diff --git a/psalm.baseline.xml b/psalm.baseline.xml index eaaae28..260b1e0 100644 --- a/psalm.baseline.xml +++ b/psalm.baseline.xml @@ -1,5 +1,19 @@ + + + $bundles + + + iterable + + + $loader->getResolver()->resolve($file, 'php') + + + RouteCollectionBuilder + + ResettableContainerInterface diff --git a/src/AppKernel.php b/src/AppKernel.php index 250626f..d2d7dcb 100644 --- a/src/AppKernel.php +++ b/src/AppKernel.php @@ -8,6 +8,9 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; +use Symfony\Component\Routing\Loader\PhpFileLoader as RoutingPhpFileLoader; +use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouteCollectionBuilder; /** @@ -168,15 +171,34 @@ public function registerContainerConfiguration(LoaderInterface $loader) */ public function loadRoutes(LoaderInterface $loader) { - $routes = new RouteCollectionBuilder($loader); + if (class_exists(RoutingConfigurator::class)) { + $file = (new \ReflectionObject($this))->getFileName(); + /** @var RoutingPhpFileLoader $kernelLoader */ + $kernelLoader = $loader->getResolver()->resolve($file, 'php'); + $kernelLoader->setCurrentDir(\dirname($file)); + + $collection = new RouteCollection(); + $configurator = new RoutingConfigurator($collection, $kernelLoader, $file, $file, $this->getEnvironment()); + + if ($this->routingFile) { + $configurator->import($this->routingFile); + } else { + $configurator->import(__DIR__.'/config/routing.yml'); + } - if ($this->routingFile) { - $routes->import($this->routingFile); + return $collection; } else { - $routes->import(__DIR__.'/config/routing.yml'); - } + // Legacy + $routes = new RouteCollectionBuilder($loader); - return $routes->build(); + if ($this->routingFile) { + $routes->import($this->routingFile); + } else { + $routes->import(__DIR__.'/config/routing.yml'); + } + + return $routes->build(); + } } /**