Skip to content

drop PHP 7.x support #1122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 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:
- '7.4'
- '8.0'

steps:
-
Expand Down Expand Up @@ -99,11 +99,11 @@ jobs:
allow-dev-deps-in-apps: ['0']
include:
# testing lowest PHP version with LTS
- php-version: '7.2.5'
- php-version: '8.0.0'
symfony-version: '5.4.*'
dependency-versions: 'lowest'
# testing lowest php version with highest 5.x stable
- php-version: '7.2.5'
- php-version: '8.0.0'
symfony-version: '5.4.*'
dependency-versions: 'highest'
# testing bleeding edge PHP with highest 5.x stable
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:[email protected]:3306/test_maker
matrix:
- dependencies: highest
php_ver_target: 7.2.5
php_ver_target: 8.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests failing, looks like we may need to bump this to 8.0.SOMETHING that actually works, which is fine.


install:
- ps: Set-Service wuauserv -StartupType Manual
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"minimum-stability": "dev",
"require": {
"php": ">=7.2.5",
"php": ">=8.0",
"doctrine/inflector": "^2.0",
"nikic/php-parser": "^4.11",
"symfony/config": "^5.4.7|^6.0",
Expand Down
17 changes: 5 additions & 12 deletions src/Command/MakerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,13 @@
*/
final class MakerCommand extends Command
{
private $maker;
private $fileManager;
private $inputConfig;
/** @var ConsoleStyle */
private $io;
private $checkDependencies = true;
private $generator;

public function __construct(MakerInterface $maker, FileManager $fileManager, Generator $generator)
private InputConfiguration $inputConfig;
private ConsoleStyle $io;
private bool $checkDependencies = true;

public function __construct(private MakerInterface $maker, private FileManager $fileManager, private Generator $generator)
{
$this->maker = $maker;
$this->fileManager = $fileManager;
$this->inputConfig = new InputConfiguration();
$this->generator = $generator;

parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/DoctrineHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function doesClassUsesAttributes(string $className): bool

public function isDoctrineSupportingAttributes(): bool
{
return $this->isDoctrineInstalled() && $this->attributeMappingSupport && $this->phpCompatUtil->canUseAttributes();
return $this->isDoctrineInstalled() && $this->attributeMappingSupport;
}

Comment on lines 146 to 150
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will handle bringing doctrine related makers up to PHP8 standards in a separate PR to avoid too much bloat in this one.

public function getEntitiesForAutocomplete(): array
Expand Down
3 changes: 0 additions & 3 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ private function addOperation(string $targetPath, string $templateName, array $v
}

$variables['relative_path'] = $this->fileManager->relativizePath($targetPath);
$variables['use_attributes'] = $this->phpCompatUtil->canUseAttributes();
$variables['use_typed_properties'] = $this->phpCompatUtil->canUseTypedProperties();
$variables['use_union_types'] = $this->phpCompatUtil->canUseUnionTypes();

$templatePath = $templateName;
if (!file_exists($templatePath)) {
Expand Down
20 changes: 7 additions & 13 deletions src/Maker/MakeAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,13 @@ final class MakeAuthenticator extends AbstractMaker
private const AUTH_TYPE_EMPTY_AUTHENTICATOR = 'empty-authenticator';
private const AUTH_TYPE_FORM_LOGIN = 'form-login';

private $fileManager;
private $configUpdater;
private $generator;
private $doctrineHelper;
private $securityControllerBuilder;

public function __construct(FileManager $fileManager, SecurityConfigUpdater $configUpdater, Generator $generator, DoctrineHelper $doctrineHelper, SecurityControllerBuilder $securityControllerBuilder)
{
$this->fileManager = $fileManager;
$this->configUpdater = $configUpdater;
$this->generator = $generator;
$this->doctrineHelper = $doctrineHelper;
$this->securityControllerBuilder = $securityControllerBuilder;
public function __construct(
private FileManager $fileManager,
private SecurityConfigUpdater $configUpdater,
private Generator $generator,
private DoctrineHelper $doctrineHelper,
private SecurityControllerBuilder $securityControllerBuilder
) {
}

public static function getCommandName(): string
Expand Down
10 changes: 2 additions & 8 deletions src/Maker/MakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@
*/
final class MakeCommand extends AbstractMaker
{
private $phpCompatUtil;

public function __construct(PhpCompatUtil $phpCompatUtil)
public function __construct(private PhpCompatUtil $phpCompatUtil)
{
$this->phpCompatUtil = $phpCompatUtil;
}

public static function getCommandName(): string
Expand Down Expand Up @@ -77,12 +74,9 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
InputOption::class,
OutputInterface::class,
SymfonyStyle::class,
AsCommand::class,
]);

if ($this->phpCompatUtil->canUseAttributes()) {
$useStatements->addUseStatement(AsCommand::class);
}

$generator->generateClass(
$commandClassNameDetails->getFullName(),
'command/Command.tpl.php',
Expand Down
4 changes: 2 additions & 2 deletions src/Maker/MakeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
final class MakeController extends AbstractMaker
{
private $phpCompatUtil;
private PhpCompatUtil $phpCompatUtil;

public function __construct(PhpCompatUtil $phpCompatUtil = null)
{
Expand Down Expand Up @@ -116,7 +116,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
public function configureDependencies(DependencyBuilder $dependencies): void
{
// @legacy - Remove method when support for Symfony 5.4 is dropped
if (null !== $this->phpCompatUtil && 60000 <= Kernel::VERSION_ID && $this->phpCompatUtil->canUseAttributes()) {
if (null !== $this->phpCompatUtil && 60000 <= Kernel::VERSION_ID) {
return;
}

Expand Down
13 changes: 5 additions & 8 deletions src/Maker/MakeCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\MakerBundle\Maker;

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
Expand Down Expand Up @@ -45,16 +46,12 @@
*/
final class MakeCrud extends AbstractMaker
{
private $doctrineHelper;
private $formTypeRenderer;
private $inflector;
private $controllerClassName;
private $generateTests = false;
private Inflector $inflector;
private string $controllerClassName;
private bool $generateTests = false;

public function __construct(DoctrineHelper $doctrineHelper, FormTypeRenderer $formTypeRenderer)
public function __construct(private DoctrineHelper $doctrineHelper, private FormTypeRenderer $formTypeRenderer)
{
$this->doctrineHelper = $doctrineHelper;
$this->formTypeRenderer = $formTypeRenderer;
$this->inflector = InflectorFactory::create()->build();
}

Expand Down
19 changes: 5 additions & 14 deletions src/Maker/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,18 @@
*/
final class MakeEntity extends AbstractMaker implements InputAwareMakerInterface
{
private $fileManager;
private $doctrineHelper;
private $generator;
private $entityClassGenerator;
private $phpCompatUtil;
private Generator $generator;
private EntityClassGenerator $entityClassGenerator;
private PhpCompatUtil $phpCompatUtil;

public function __construct(
FileManager $fileManager,
DoctrineHelper $doctrineHelper,
private FileManager $fileManager,
private DoctrineHelper $doctrineHelper,
string $projectDirectory = null,
Generator $generator = null,
EntityClassGenerator $entityClassGenerator = null,
PhpCompatUtil $phpCompatUtil = null
) {
$this->fileManager = $fileManager;
$this->doctrineHelper = $doctrineHelper;

if (null !== $projectDirectory) {
@trigger_error('The $projectDirectory constructor argument is no longer used since 1.41.0', \E_USER_DEPRECATED);
}
Expand Down Expand Up @@ -877,10 +872,6 @@ private function doesEntityUseAnnotationMapping(string $className): bool
/** @legacy Drop when Annotations are no longer supported */
private function doesEntityUseAttributeMapping(string $className): bool
{
if (!$this->phpCompatUtil->canUseAttributes()) {
return false;
}

Comment on lines 872 to -883
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled under a separate PR dedicated to doctrine.

if (!class_exists($className)) {
$otherClassMetadatas = $this->doctrineHelper->getMetadata(Str::getNamespace($className).'\\', true);

Expand Down
7 changes: 1 addition & 6 deletions src/Maker/MakeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@
*/
final class MakeForm extends AbstractMaker
{
private $entityHelper;
private $formTypeRenderer;

public function __construct(DoctrineHelper $entityHelper, FormTypeRenderer $formTypeRenderer)
public function __construct(private DoctrineHelper $entityHelper, private FormTypeRenderer $formTypeRenderer)
{
$this->entityHelper = $entityHelper;
$this->formTypeRenderer = $formTypeRenderer;
}

public static function getCommandName(): string
Expand Down
5 changes: 1 addition & 4 deletions src/Maker/MakeMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@
*/
final class MakeMessage extends AbstractMaker
{
private $fileManager;

public function __construct(FileManager $fileManager)
public function __construct(private FileManager $fileManager)
{
$this->fileManager = $fileManager;
}

public static function getCommandName(): string
Expand Down
10 changes: 2 additions & 8 deletions src/Maker/MakeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@
*/
final class MakeMigration extends AbstractMaker implements ApplicationAwareMakerInterface
{
private $projectDir;
private Application $application;

/**
* @var Application
*/
private $application;

public function __construct(string $projectDir)
public function __construct(private string $projectDir)
{
$this->projectDir = $projectDir;
}

public static function getCommandName(): string
Expand Down
17 changes: 6 additions & 11 deletions src/Maker/MakeRegistrationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@
*/
final class MakeRegistrationForm extends AbstractMaker
{
private $fileManager;
private $formTypeRenderer;
private $router;
private $doctrineHelper;

private $userClass;
private $usernameField;
private $passwordField;
Expand All @@ -87,12 +82,12 @@ final class MakeRegistrationForm extends AbstractMaker
private $addUniqueEntityConstraint;
private $useNewAuthenticatorSystem = false;

public function __construct(FileManager $fileManager, FormTypeRenderer $formTypeRenderer, RouterInterface $router, DoctrineHelper $doctrineHelper)
{
$this->fileManager = $fileManager;
$this->formTypeRenderer = $formTypeRenderer;
$this->router = $router;
$this->doctrineHelper = $doctrineHelper;
public function __construct(
private FileManager $fileManager,
private FormTypeRenderer $formTypeRenderer,
private RouterInterface $router,
private DoctrineHelper $doctrineHelper
) {
}

public static function getCommandName(): string
Expand Down
30 changes: 13 additions & 17 deletions src/Maker/MakeResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,19 @@
*/
class MakeResetPassword extends AbstractMaker
{
private $fileManager;
private $doctrineHelper;
private $entityClassGenerator;

private $fromEmailAddress;
private $fromEmailName;
private $controllerResetSuccessRedirect;
private $userClass;
private $emailPropertyName;
private $emailGetterMethodName;
private $passwordSetterMethodName;

public function __construct(FileManager $fileManager, DoctrineHelper $doctrineHelper, EntityClassGenerator $entityClassGenerator)
{
$this->fileManager = $fileManager;
$this->doctrineHelper = $doctrineHelper;
$this->entityClassGenerator = $entityClassGenerator;
private string $fromEmailAddress;
private string $fromEmailName;
private string $controllerResetSuccessRedirect;
private string $userClass;
private string $emailPropertyName;
private string $emailGetterMethodName;
private string $passwordSetterMethodName;

public function __construct(
private FileManager $fileManager,
private DoctrineHelper $doctrineHelper,
private EntityClassGenerator $entityClassGenerator
) {
}

public static function getCommandName(): string
Expand Down
5 changes: 1 addition & 4 deletions src/Maker/MakeSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
*/
final class MakeSubscriber extends AbstractMaker
{
private $eventRegistry;

public function __construct(EventRegistry $eventRegistry)
public function __construct(private EventRegistry $eventRegistry)
{
$this->eventRegistry = $eventRegistry;
}

public static function getCommandName(): string
Expand Down
20 changes: 7 additions & 13 deletions src/Maker/MakeUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,13 @@
*/
final class MakeUser extends AbstractMaker
{
private $fileManager;
private $userClassBuilder;
private $configUpdater;
private $entityClassGenerator;
private $doctrineHelper;

public function __construct(FileManager $fileManager, UserClassBuilder $userClassBuilder, SecurityConfigUpdater $configUpdater, EntityClassGenerator $entityClassGenerator, DoctrineHelper $doctrineHelper)
{
$this->fileManager = $fileManager;
$this->userClassBuilder = $userClassBuilder;
$this->configUpdater = $configUpdater;
$this->entityClassGenerator = $entityClassGenerator;
$this->doctrineHelper = $doctrineHelper;
public function __construct(
private FileManager $fileManager,
private UserClassBuilder $userClassBuilder,
private SecurityConfigUpdater $configUpdater,
private EntityClassGenerator $entityClassGenerator,
private DoctrineHelper $doctrineHelper
) {
}

public static function getCommandName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ class <?= $class_name; ?> extends AbstractLoginFormAuthenticator

public const LOGIN_ROUTE = 'app_login';

private <?= $use_typed_properties ? 'UrlGeneratorInterface ' : null ?>$urlGenerator;

public function __construct(UrlGeneratorInterface $urlGenerator)
public function __construct(private UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}

public function authenticate(Request $request): Passport
Expand Down
Loading