Skip to content

Commit

Permalink
Bumping min php + symfony versions & removing legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Sep 12, 2023
1 parent 826b4f2 commit 4da6e4a
Show file tree
Hide file tree
Showing 56 changed files with 158 additions and 1,250 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- '8.0'
- '8.1'

steps:
-
Expand Down Expand Up @@ -92,22 +92,19 @@ jobs:
php-version:
- '8.2'
symfony-version:
- '5.4.*'
- '5.4.x-dev'
- '6.0.x-dev'
- '6.3.x-dev'
- '6.4.x-dev'
- '7.0.x-dev'
dependency-versions: ['highest']
allow-dev-deps-in-apps: ['0']
include:
# testing lowest PHP version with LTS
- php-version: '8.0.0'
symfony-version: '5.4.*'
# testing lowest PHP+dependencies with lowest Symfony
- php-version: '8.1'
symfony-version: '6.3.*'
dependency-versions: 'lowest'
# testing lowest php version with highest 5.x stable
- php-version: '8.0.0'
symfony-version: '5.4.*'
# testing lowest PHP+dependencies with highest Symfony
- php-version: '8.1'
symfony-version: '6.3.*'
dependency-versions: 'highest'

steps:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ environment:
TEST_DATABASE_DSN: mysql://root:Password12!@127.0.0.1:3306/test_maker
matrix:
- dependencies: highest
php_ver_target: 8.0.19
php_ver_target: 8.1.23

install:
- choco install sqlite --params "/NoTools"
Expand Down
31 changes: 15 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
],
"minimum-stability": "dev",
"require": {
"php": ">=8.0",
"php": ">=8.1",
"doctrine/inflector": "^2.0",
"nikic/php-parser": "^4.11",
"symfony/config": "^5.4.7|^6.0|^7.0",
"symfony/console": "^5.4.7|^6.0|^7.0",
"symfony/dependency-injection": "^5.4.7|^6.0|^7.0",
"symfony/config": "^6.3|^7.0",
"symfony/console": "^6.3|^7.0",
"symfony/dependency-injection": "^6.3|^7.0",
"symfony/deprecation-contracts": "^2.2|^3",
"symfony/filesystem": "^5.4.7|^6.0|^7.0",
"symfony/finder": "^5.4.3|^6.0|^7.0",
"symfony/framework-bundle": "^5.4.7|^6.0|^7.0",
"symfony/http-kernel": "^5.4.7|^6.0|^7.0",
"symfony/process": "^5.4.7|^6.0|^7.0"
"symfony/filesystem": "^6.3|^7.0",
"symfony/finder": "^6.3|^7.0",
"symfony/framework-bundle": "^6.3|^7.0",
"symfony/http-kernel": "^6.3|^7.0",
"symfony/process": "^6.3|^7.0"
},
"require-dev": {
"composer/semver": "^3.0",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/doctrine-bundle": "^2.4.3",
"doctrine/orm": "^2.10.0",
"symfony/http-client": "^5.4.7|^6.0|^7.0",
"symfony/phpunit-bridge": "^5.4.17|^6.0|^7.0",
"symfony/http-client": "^6.3|^7.0",
"symfony/phpunit-bridge": "^6.3|^7.0",
"symfony/polyfill-php80": "^1.16.0",
"symfony/security-core": "^5.4.7|^6.0|^7.0",
"symfony/yaml": "^5.4.3|^6.0|^7.0",
"symfony/security-core": "^6.3|^7.0",
"symfony/yaml": "^6.3|^7.0",
"twig/twig": "^2.0|^3.0"
},
"config": {
Expand All @@ -43,8 +43,7 @@
},
"conflict": {
"doctrine/orm": "<2.10",
"doctrine/doctrine-bundle": "<2.4",
"symfony/doctrine-bridge": "<5.4"
"doctrine/doctrine-bundle": "<2.4"
},
"autoload": {
"psr-4": { "Symfony\\Bundle\\MakerBundle\\": "src/" }
Expand Down
49 changes: 14 additions & 35 deletions src/Console/MigrationDiffFilteredOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,7 @@
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Output\OutputInterface;

// look for the "string|iterable" type on OutputInterface::write()
// @legacy - Use MigrationDiffFilteredOutput_php8 when Symfony 5.4 is no longer supported
if (!(new \ReflectionMethod(OutputInterface::class, 'write'))->getParameters()[0]->getType()) {
class MigrationDiffFilteredOutput implements OutputInterface
{
use BaseMakerMigrationDiffFilteredOuputTrait;

public function write($messages, $newline = false, $options = 0)
{
$this->_write($messages, $newline, $options);
}

public function writeln($messages, $options = 0)
{
$this->_writeln($messages, $options);
}

public function setVerbosity($level)
{
$this->output->setVerbosity($level);
}

public function setDecorated($decorated)
{
$this->output->setDecorated($decorated);
}
}
} else {
require __DIR__.'/MigrationDiffFilteredOutput_php8';
}

trait BaseMakerMigrationDiffFilteredOuputTrait
class MigrationDiffFilteredOutput implements OutputInterface
{
private string $buffer = '';
private bool $previousLineWasRemoved = false;
Expand All @@ -55,20 +24,30 @@ public function __construct(
) {
}

public function _write($messages, bool $newline = false, $options = 0)
public function write($messages, bool $newline = false, $options = 0): void
{
$messages = $this->filterMessages($messages, $newline);

$this->output->write($messages, $newline, $options);
}

public function _writeln($messages, int $options = 0)
public function writeln($messages, int $options = 0): void
{
$messages = $this->filterMessages($messages, true);

$this->output->writeln($messages, $options);
}

public function setVerbosity(int $level): void
{
$this->output->setVerbosity($level);
}

public function setDecorated(bool $decorated): void
{
$this->output->setDecorated($decorated);
}

public function getVerbosity(): int
{
return $this->output->getVerbosity();
Expand Down Expand Up @@ -99,7 +78,7 @@ public function isDecorated(): bool
return $this->output->isDecorated();
}

public function setFormatter(OutputFormatterInterface $formatter)
public function setFormatter(OutputFormatterInterface $formatter): void
{
$this->output->setFormatter($formatter);
}
Expand Down
39 changes: 0 additions & 39 deletions src/Console/MigrationDiffFilteredOutput_php8

This file was deleted.

3 changes: 1 addition & 2 deletions src/Doctrine/EntityClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $
}

if ($apiResource) {
// @legacy Drop annotation class when annotations are no longer supported.
$useStatements->addUseStatement(class_exists(ApiResource::class) ? ApiResource::class : \ApiPlatform\Core\Annotation\ApiResource::class);
$useStatements->addUseStatement(ApiResource::class);
}

$entityPath = $this->generator->generateClass(
Expand Down
3 changes: 1 addition & 2 deletions src/Doctrine/EntityDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Bundle\MakerBundle\Doctrine;

use Doctrine\Common\Persistence\Mapping\ClassMetadata as LegacyClassMetadata;
use Doctrine\Persistence\Mapping\ClassMetadata;

/**
Expand All @@ -22,7 +21,7 @@
final class EntityDetails
{
public function __construct(
private ClassMetadata|LegacyClassMetadata $metadata,
private ClassMetadata $metadata,
) {
}

Expand Down
3 changes: 1 addition & 2 deletions src/Doctrine/EntityRegenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Bundle\MakerBundle\Doctrine;

use Doctrine\Common\Persistence\Mapping\MappingException as LegacyCommonMappingException;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\MappingException as PersistenceMappingException;
Expand All @@ -38,7 +37,7 @@ public function regenerateEntities(string $classOrNamespace): void
{
try {
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace);
} catch (MappingException|LegacyCommonMappingException|PersistenceMappingException) {
} catch (MappingException|PersistenceMappingException) {
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace, true);
}

Expand Down
8 changes: 1 addition & 7 deletions src/EventRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Event\ConsoleErrorEvent;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\EventDispatcher\Event as LegacyEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
Expand All @@ -35,7 +34,6 @@
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
use Symfony\Contracts\EventDispatcher\Event;

/**
* @internal
Expand Down Expand Up @@ -148,11 +146,7 @@ public function getEventClassName(string $event): ?string
}

if (null !== $type = $args[0]->getType()) {
$type = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();

if (LegacyEvent::class === $type && class_exists(Event::class)) {
return Event::class;
}
$type = $type instanceof \ReflectionNamedType ? $type->getName() : null;

// ignore an "object" type-hint
if ('object' === $type) {
Expand Down
17 changes: 2 additions & 15 deletions src/Maker/MakeAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Symfony\Bundle\MakerBundle\Util\YamlManipulationFailedException;
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
use Symfony\Bundle\MakerBundle\Validator;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Console\Command\Command;
Expand All @@ -43,8 +42,6 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Security as LegacySecurity;
use Symfony\Component\Security\Guard\AuthenticatorInterface as GuardAuthenticatorInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
Expand All @@ -53,6 +50,7 @@
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\SecurityRequestAttributes;
use Symfony\Component\Security\Http\Util\TargetPathTrait;
use Symfony\Component\Yaml\Yaml;

Expand Down Expand Up @@ -103,11 +101,6 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
$manipulator = new YamlSourceManipulator($this->fileManager->getFileContents($path));
$securityData = $manipulator->getData();

// @legacy - Can be removed when Symfony 5.4 support is dropped
if (interface_exists(GuardAuthenticatorInterface::class) && !($securityData['security']['enable_authenticator_manager'] ?? false)) {
throw new RuntimeCommandException('MakerBundle only supports the new authenticator based security system. See https://symfony.com/doc/current/security.html');
}

// authenticator type
$authenticatorTypeValues = [
'Empty authenticator' => self::AUTH_TYPE_EMPTY_AUTHENTICATOR,
Expand Down Expand Up @@ -320,15 +313,9 @@ private function generateAuthenticatorClass(array $securityData, string $authent
UserBadge::class,
PasswordCredentials::class,
TargetPathTrait::class,
SecurityRequestAttributes::class,
]);

// @legacy - Can be removed when Symfony 5.4 support is dropped
if (class_exists(Security::class)) {
$useStatements->addUseStatement(Security::class);
} else {
$useStatements->addUseStatement(LegacySecurity::class);
}

if ($supportRememberMe) {
$useStatements->addUseStatement(RememberMeBadge::class);
}
Expand Down
12 changes: 0 additions & 12 deletions src/Maker/MakeCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Doctrine\Inflector\InflectorFactory;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
Expand All @@ -38,7 +36,6 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Csrf\CsrfTokenManager;
use Symfony\Component\Validator\Validation;
Expand Down Expand Up @@ -184,8 +181,6 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
'entity_var_singular' => $entityVarSingular,
'entity_twig_var_singular' => $entityTwigVarSingular,
'entity_identifier' => $entityDoctrineDetails->getIdentifier(),
// @legacy - Remove when support for Symfony <6 is dropped
'use_render_form' => Kernel::VERSION_ID < 60200,
],
$repositoryVars
)
Expand Down Expand Up @@ -327,12 +322,5 @@ public function configureDependencies(DependencyBuilder $dependencies): void
CsrfTokenManager::class,
'security-csrf'
);

// @legacy - Remove dependency when support for Symfony <6.2 is dropped
$dependencies->addClassDependency(
ParamConverter::class,
'annotations',
!class_exists(EntityValueResolver::class) // sensio/framework-extra-bundle dependency is not required when using symfony 6.2+
);
}
}
Loading

0 comments on commit 4da6e4a

Please sign in to comment.