Skip to content

Commit 31a7597

Browse files
committed
bug #480 Allow Symfony 5 + many cleanups (nicolas-grekas)
This PR was merged into the 1.0-dev branch. Discussion ---------- Allow Symfony 5 + many cleanups Note that having php-cs-fixer in the deps blocks installing Symfony 5 (did I already mention it's a bad practice to add tools as deps? ;) ) But locally when I remove php-cs-fixer (and patch the code to use my local version), all is green, with SF5 deps. Commits ------- 2cf9460 Allow Symfony 5 + many cleanups
2 parents 3e3651e + 2cf9460 commit 31a7597

File tree

87 files changed

+629
-463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+629
-463
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/vendor/
44
/tests/tmp/*
55
/.php_cs.cache
6+
/.phpunit.result.cache

.php_cs.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ return PhpCsFixer\Config::create()
1919
->setRules(array(
2020
'@Symfony' => true,
2121
'@Symfony:risky' => true,
22+
'@PHPUnit75Migration:risky' => true,
2223
'array_syntax' => ['syntax' => 'short'],
2324
'protected_to_private' => false,
2425
'semicolon_after_instruction' => false,

composer.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,29 @@
1111
"homepage": "https://symfony.com/contributors"
1212
}
1313
],
14+
"minimum-stability": "dev",
1415
"require": {
1516
"php": "^7.0.8",
1617
"doctrine/inflector": "^1.2",
1718
"nikic/php-parser": "^4.0",
18-
"symfony/config": "^3.4|^4.0",
19-
"symfony/console": "^3.4|^4.0",
20-
"symfony/dependency-injection": "^3.4|^4.0",
21-
"symfony/filesystem": "^3.4|^4.0",
22-
"symfony/finder": "^3.4|^4.0",
23-
"symfony/framework-bundle": "^3.4|^4.0",
24-
"symfony/http-kernel": "^3.4|^4.0"
19+
"symfony/config": "^3.4|^4.0|^5.0",
20+
"symfony/console": "^3.4|^4.0|^5.0",
21+
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
22+
"symfony/filesystem": "^3.4|^4.0|^5.0",
23+
"symfony/finder": "^3.4|^4.0|^5.0",
24+
"symfony/framework-bundle": "^3.4|^4.0|^5.0",
25+
"symfony/http-kernel": "^3.4|^4.0|^5.0"
2526
},
2627
"require-dev": {
27-
"doctrine/doctrine-bundle": "^1.8",
28+
"doctrine/doctrine-bundle": "^1.8|^2.0",
2829
"doctrine/orm": "^2.3",
2930
"friendsofphp/php-cs-fixer": "^2.8",
3031
"friendsoftwig/twigcs": "^3.1.2",
31-
"symfony/http-client": "^4.3",
32-
"symfony/phpunit-bridge": "^3.4.19|^4.0",
33-
"symfony/process": "^3.4|^4.0",
34-
"symfony/security-core": "^3.4|^4.0",
35-
"symfony/yaml": "^3.4|^4.0"
32+
"symfony/http-client": "^4.3|^5.0",
33+
"symfony/phpunit-bridge": "^4.3|^5.0",
34+
"symfony/process": "^3.4|^4.0|^5.0",
35+
"symfony/security-core": "^3.4|^4.0|^5.0",
36+
"symfony/yaml": "^3.4|^4.0|^5.0"
3637
},
3738
"config": {
3839
"preferred-install": "dist",

phpunit.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
backupGlobals="false"
77
colors="true"
88
bootstrap="vendor/autoload.php"
9+
failOnRisky="true"
10+
failOnWarning="true"
911
>
1012
<php>
1113
<ini name="error_reporting" value="-1" />

src/Command/MakerCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,16 @@ protected function interact(InputInterface $input, OutputInterface $output)
9999
$this->maker->interact($input, $this->io, $this);
100100
}
101101

102-
protected function execute(InputInterface $input, OutputInterface $output)
102+
protected function execute(InputInterface $input, OutputInterface $output): int
103103
{
104104
$this->maker->generate($input, $this->io, $this->generator);
105105

106106
// sanity check for custom makers
107107
if ($this->generator->hasPendingOperations()) {
108108
throw new \LogicException('Make sure to call the writeChanges() method on the generator.');
109109
}
110+
111+
return 0;
110112
}
111113

112114
public function setApplication(Application $application = null)

src/Doctrine/DoctrineHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
namespace Symfony\Bundle\MakerBundle\Doctrine;
1313

1414
use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory;
15+
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
1516
use Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver;
1617
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
1718
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
19+
use Doctrine\Common\Persistence\Mapping\MappingException as PersistenceMappingException;
1820
use Doctrine\ORM\EntityManagerInterface;
19-
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
2021
use Doctrine\ORM\Mapping\MappingException as ORMMappingException;
21-
use Doctrine\Common\Persistence\Mapping\MappingException as PersistenceMappingException;
2222
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
2323
use Symfony\Bridge\Doctrine\ManagerRegistry;
2424
use Symfony\Bundle\MakerBundle\Util\ClassNameDetails;

src/EventRegistry.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
use Symfony\Component\Console\Event\ConsoleCommandEvent;
1515
use Symfony\Component\Console\Event\ConsoleErrorEvent;
1616
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
17+
use Symfony\Component\EventDispatcher\Event as LegacyEvent;
1718
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
19+
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
20+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
21+
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
1822
use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent;
1923
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
2024
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
@@ -23,17 +27,15 @@
2327
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2428
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
2529
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
26-
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
27-
use Symfony\Component\HttpKernel\Event\ControllerEvent;
28-
use Symfony\Component\HttpKernel\Event\ResponseEvent;
2930
use Symfony\Component\HttpKernel\Event\RequestEvent;
30-
use Symfony\Component\HttpKernel\Event\ViewEvent;
31-
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
31+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
3232
use Symfony\Component\HttpKernel\Event\TerminateEvent;
33+
use Symfony\Component\HttpKernel\Event\ViewEvent;
3334
use Symfony\Component\Security\Core\Event\AuthenticationEvent;
3435
use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;
3536
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
3637
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
38+
use Symfony\Contracts\EventDispatcher\Event;
3739

3840
/**
3941
* @internal
@@ -76,10 +78,10 @@ public function __construct(EventDispatcherInterface $eventDispatcher)
7678
$this->eventDispatcher = $eventDispatcher;
7779

7880
// Loop through the new event classes
79-
foreach (self::$newEventsMap as $oldEventName => $newEventClass) {
81+
foreach (self::$newEventsMap as $eventName => $newEventClass) {
8082
//Check if the new event classes exist, if so replace the old one with the new.
81-
if (isset(self::$eventsMap[$oldEventName]) && class_exists($newEventClass)) {
82-
unset(self::$eventsMap[$oldEventName]);
83+
if (isset(self::$eventsMap[$eventName]) && class_exists($newEventClass)) {
84+
unset(self::$eventsMap[$eventName]);
8385
self::$eventsMap[$newEventClass] = $newEventClass;
8486
}
8587
}
@@ -141,7 +143,13 @@ public function getEventClassName(string $event)
141143
}
142144

143145
if (null !== $type = $args[0]->getType()) {
144-
return (string) $type;
146+
$type = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();
147+
148+
if (LegacyEvent::class === $type && class_exists(Event::class)) {
149+
return Event::class;
150+
}
151+
152+
return $type;
145153
}
146154
}
147155

src/Maker/MakeAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
use Symfony\Component\Console\Input\InputInterface;
3434
use Symfony\Component\Console\Input\InputOption;
3535
use Symfony\Component\Console\Question\Question;
36+
use Symfony\Component\Form\Form;
3637
use Symfony\Component\HttpKernel\Kernel;
3738
use Symfony\Component\Yaml\Yaml;
38-
use Symfony\Component\Form\Form;
3939

4040
/**
4141
* @author Ryan Weaver <[email protected]>

src/Maker/MakeEntity.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
use Symfony\Bundle\MakerBundle\DependencyBuilder;
1919
use Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper;
2020
use Symfony\Bundle\MakerBundle\Doctrine\EntityClassGenerator;
21+
use Symfony\Bundle\MakerBundle\Doctrine\EntityRegenerator;
22+
use Symfony\Bundle\MakerBundle\Doctrine\EntityRelation;
2123
use Symfony\Bundle\MakerBundle\Doctrine\ORMDependencyBuilder;
2224
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
25+
use Symfony\Bundle\MakerBundle\FileManager;
2326
use Symfony\Bundle\MakerBundle\Generator;
2427
use Symfony\Bundle\MakerBundle\InputAwareMakerInterface;
2528
use Symfony\Bundle\MakerBundle\InputConfiguration;
2629
use Symfony\Bundle\MakerBundle\Str;
27-
use Symfony\Bundle\MakerBundle\Doctrine\EntityRegenerator;
28-
use Symfony\Bundle\MakerBundle\FileManager;
2930
use Symfony\Bundle\MakerBundle\Util\ClassDetails;
3031
use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator;
31-
use Symfony\Bundle\MakerBundle\Doctrine\EntityRelation;
3232
use Symfony\Bundle\MakerBundle\Validator;
3333
use Symfony\Component\Console\Command\Command;
3434
use Symfony\Component\Console\Input\InputArgument;

src/Maker/MakeFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\MakerBundle\Maker;
1313

14+
use Symfony\Bundle\FrameworkBundle\Test\WebTestAssertionsTrait;
1415
use Symfony\Bundle\MakerBundle\ConsoleStyle;
1516
use Symfony\Bundle\MakerBundle\DependencyBuilder;
1617
use Symfony\Bundle\MakerBundle\Generator;
@@ -20,7 +21,6 @@
2021
use Symfony\Component\Console\Input\InputArgument;
2122
use Symfony\Component\Console\Input\InputInterface;
2223
use Symfony\Component\CssSelector\CssSelectorConverter;
23-
use Symfony\Bundle\FrameworkBundle\Test\WebTestAssertionsTrait;
2424
use Symfony\Component\Panther\PantherTestCaseTrait;
2525

2626
/**

0 commit comments

Comments
 (0)