Skip to content

Commit

Permalink
drop symfony 5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Feb 19, 2024
1 parent 6eedd07 commit d409941
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 164 deletions.
27 changes: 9 additions & 18 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,18 @@ jobs:
symfony-version:
- '*'
include:
- php-version: '7.1'
- php-version: '8.1'
dependencies: 'lowest'
symfony-version: '^3.4'
symfony-deprecation-helper: 'weak'

- php-version: '7.2'
- php-version: '7.3'
- php-version: '7.4'
symfony-version: '^4.4'
- php-version: '7.4'
symfony-version: '5.0.*'
- php-version: '8.0'
- php-version: '8.0'
symfony-version: '6.0.*'
- php-version: '8.1'
symfony-version: '6.4.*'
- php-version: '8.2'
- php-version: '8.3'
symfony-version: '7.0.*'

steps:
- name: Checkout project
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
Expand All @@ -52,13 +44,12 @@ jobs:
tools: 'composer:v2'

- name: Install Symfony Flex
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex

- name: Allow Symfony Flex Plugin
run: composer global config --no-plugins allow-plugins.symfony/flex true
run: |
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer global config --no-plugins allow-plugins.symfony/flex true
- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Changelog

5.0.0 (unreleased)

* Support Symfony 7, drop support for Symfony < 5.4
* Support Symfony 7, drop support for Symfony < 6.4
* The default framework configuration no longer enables validation attributes.
* The phpcr-odm additional namespace is expected to use attributes rather than annotations.

Expand Down
18 changes: 0 additions & 18 deletions bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@
exit(1);
}

use Doctrine\Common\Annotations\AnnotationRegistry;

if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader(function ($class) use ($loader) {
$loader->loadClass($class);

// this was class_exists($class, false) i.e. do not autoload.
// this is required so that custom annotations (e.g. TreeUiBundle
// annotations) are autoloaded - but they should be found by the
// composer loader above.
//
// This probably slows things down.
//
// @todo: Fix me.
return class_exists($class);
});
}

if (!defined('CMF_TEST_ROOT_DIR')) {
define('CMF_TEST_ROOT_DIR', realpath(__DIR__.'/..'));
}
Expand Down
23 changes: 13 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@
}
],
"require": {
"php": "^7.1|^8.0",
"php": "^8.1",
"doctrine/data-fixtures": "^1.2",
"symfony/browser-kit": "^5.4 || ^6.4 || ^7.0"
"symfony/browser-kit": "^6.4 || ^7.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
"doctrine/phpcr-bundle": "^1.3 || ^2.0.0 || ^3.0@beta",
"symfony/console": "^5.4 || ^6.4 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.4 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0",
"doctrine/phpcr-bundle": "^3.0@beta",
"symfony/console": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/doctrine-bridge": "^6.4 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0",
"symfony/monolog-bundle": "^3.5",
"symfony/security-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"symfony/phpunit-bridge": "^7.0.3"
},
"conflict": {
"doctrine/phpcr-bundle": "<3.0"
},
"autoload": {
"psr-4": {
"Symfony\\Cmf\\Component\\Testing\\": "src/"
Expand Down
23 changes: 0 additions & 23 deletions resources/.travis.yml

This file was deleted.

12 changes: 1 addition & 11 deletions resources/config/dist/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
* file that was distributed with this source code.
*/

use Symfony\Component\HttpKernel\Kernel;

$routerPath = '%kernel.root_dir%/config/routing.php';
if ($container->hasParameter('kernel.project_dir')) {
$routerPath = '%kernel.project_dir%/config/routing.php';
}

$config = [
'secret' => 'test',
'test' => null,
Expand All @@ -24,7 +17,7 @@
'enabled' => true,
],
'router' => [
'resource' => $routerPath,
'resource' => '%kernel.project_dir%/config/routing.php',
],
'default_locale' => 'en',
'translator' => [
Expand All @@ -34,9 +27,6 @@
'storage_factory_id' => 'session.storage.factory.mock_file',
]
];
if (Kernel::MAJOR_VERSION < 6) {
$config['validation']['enable_annotations'] = true;
}

$container->loadFromExtension('framework', $config);

Expand Down
12 changes: 3 additions & 9 deletions resources/config/dist/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,11 @@
],
];

if (class_exists(\Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider::class)) {
// Symfony <=5.4
if (class_exists(\Symfony\Component\Security\Core\Security::class)) {
$config = array_merge($config, [
'firewall' => ['main' => ['anonymous' => null]],
'encoders' => ['Symfony\Component\Security\Core\User\User' => 'plaintext'],
'enable_authenticator_manager' => true,
'password_hashers' => ['Symfony\Component\Security\Core\User\User' => 'plaintext'],
]);
} elseif (class_exists(\Symfony\Component\Security\Core\Security::class)) {
$config = array_merge($config, [
'enable_authenticator_manager' => true,
'password_hashers' => ['Symfony\Component\Security\Core\User\User' => 'plaintext'],
]);
}

$container->loadFromExtension('security', $config);
36 changes: 6 additions & 30 deletions src/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
namespace Symfony\Cmf\Component\Testing\Functional;

use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Cmf\Component\Testing\Functional\DbManager\ORM;
use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR;
use Symfony\Cmf\Component\Testing\Functional\DbManager\PhpcrDecorator;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;

Expand All @@ -32,15 +30,10 @@ abstract class BaseTestCase extends WebTestCase
{
/**
* Use this property to save the DbManagers.
*
* @var array
*/
protected $dbManagers = [];
protected array $dbManagers = [];

/**
* @var Client
*/
protected $client;
protected ?KernelBrowser $client = null;

/**
* Return the configuration to use when creating the Kernel.
Expand Down Expand Up @@ -80,18 +73,6 @@ protected static function bootKernel(array $options = []): KernelInterface
return parent::bootKernel(static::getKernelConfiguration());
}

/**
* BC with Symfony < 5.3 - when minimum version raises to ^5.3, we can remove this method.
*/
protected static function getContainer(): Container
{
if (method_exists(KernelTestCase::class, 'getContainer')) {
return parent::getContainer();
}

return self::getKernel()->getContainer();
}

protected static function getKernel(): KernelInterface
{
if (null === static::$kernel) {
Expand All @@ -100,9 +81,7 @@ protected static function getKernel(): KernelInterface

if (static::$kernel instanceof KernelInterface) {
$kernelEnvironment = static::$kernel->getEnvironment();
$expectedEnvironment = isset(static::getKernelConfiguration()['environment'])
? static::getKernelConfiguration()['environment']
: 'phpcr';
$expectedEnvironment = static::getKernelConfiguration()['environment'] ?? 'phpcr';
if ($kernelEnvironment !== $expectedEnvironment) {
var_dump($kernelEnvironment, $expectedEnvironment);
static::bootKernel();
Expand All @@ -116,17 +95,14 @@ protected static function getKernel(): KernelInterface
return static::$kernel;
}

/**
* @return Client|KernelBrowser
*/
protected function getFrameworkBundleClient()
protected function getFrameworkBundleClient(): KernelBrowser
{
if (null === $this->client) {
// property does not exist in all symfony versions
if (property_exists(self::class, 'booted') && self::$booted) {
self::ensureKernelShutdown();
}
$this->client = self::createClient($this->getKernelConfiguration());
$this->client = self::createClient(self::getKernelConfiguration());
}

return $this->client;
Expand Down Expand Up @@ -174,7 +150,7 @@ protected function getDbManager(string $type)
return $dbManager;
}

protected static function assertResponseSuccess(Response $response)
protected static function assertResponseSuccess(Response $response): void
{
libxml_use_internal_errors(true);

Expand Down
6 changes: 2 additions & 4 deletions src/Functional/DbManager/ORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\Common\DataFixtures\ProxyReferenceRepository;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
Expand Down Expand Up @@ -53,15 +51,15 @@ public function __construct(ContainerInterface $container)
}

/**
* @return ManagerRegistry|LegacyManagerRegistry
* @return ManagerRegistry
*/
public function getRegistry()
{
return $this->container->get('doctrine');
}

/**
* @return ObjectManager|LegacyObjectManager
* @return ObjectManager
*/
public function getOm($managerName = null)
{
Expand Down
18 changes: 4 additions & 14 deletions src/Functional/DbManager/PHPCR.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\Common\DataFixtures\ProxyReferenceRepository;
use Doctrine\Common\DataFixtures\Purger\PHPCRPurger;
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
Expand All @@ -26,25 +25,16 @@ class PHPCR
{
protected $container;

/**
* @var DocumentManager
*/
protected $om;
protected ?DocumentManager $om=null;

/**
* @var PHPCRExecutor
*/
private $executor;
private ?PHPCRExecutor $executor = null;

public function __construct(ContainerInterface $container)
{
$this->container = $container;
}

/**
* @return ManagerRegistry|LegacyManagerRegistry
*/
public function getRegistry()
public function getRegistry(): ManagerRegistry
{
return $this->container->get('doctrine_phpcr');
}
Expand Down Expand Up @@ -78,7 +68,7 @@ public function loadFixtures(array $classNames, bool $initialize = false): void
$this->getExecutor($initialize)->execute($loader->getFixtures(), false);
}

public function loadFixtureClass(Loader $loader, string $className)
public function loadFixtureClass(Loader $loader, string $className): void
{
if (!class_exists($className)) {
throw new \InvalidArgumentException(sprintf(
Expand Down
8 changes: 1 addition & 7 deletions src/Functional/DbManager/PhpcrDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ class PhpcrDecorator extends RepositoryManager
{
public function __construct(ContainerInterface $container)
{
// BC with DoctrinePHPCRBundle 2.*
$refl = new \ReflectionClass(RepositoryManager::class);
if (1 === $refl->getConstructor()->getNumberOfParameters()) {
parent::__construct($container);
} else {
parent::__construct($container->get('doctrine_phpcr'), $container->get('doctrine_phpcr.initializer_manager'));
}
parent::__construct($container->get('doctrine_phpcr'), $container->get('doctrine_phpcr.initializer_manager'));
}

public function getOm(string $managerName = null): DocumentManagerInterface
Expand Down
Loading

0 comments on commit d409941

Please sign in to comment.