make creation of ServiceMap and ParameterMap lazy#390
make creation of ServiceMap and ParameterMap lazy#390RobertMe wants to merge 1 commit intophpstan:1.3.xfrom
Conversation
Currently one can not use PHPStans `bootstrapFiles` to create the container (dump) which could then be ready by `symfony.containerXmlPath`. This as the order of initialization results in the `XmlServiceMapFactory` / `XmlParameterMapFactory` `create` methods being called before the `bootstrapFiles` are executed. By making the `ServiceMap` / `ParameterMap` lazy these will only be created when actually used, which is after the `bootstrapFiles` have been executed.
| * @return array<string> | ||
| */ | ||
| public static function getParameterKeysFromNode(Expr $node, Scope $scope): array; | ||
| public function getParameterKeysFromNode(Expr $node, Scope $scope): array; |
There was a problem hiding this comment.
This might be considered a breaking change and thus require a major version bump?
| public function getService(string $id): ?ServiceDefinition; | ||
|
|
||
| public static function getServiceIdFromNode(Expr $node, Scope $scope): ?string; | ||
| public function getServiceIdFromNode(Expr $node, Scope $scope): ?string; |
There was a problem hiding this comment.
Same as above for ParameterMap change, this might be considered a breaking change and thus require a major version bump?
|
Whoops, changes are PHP 7.2 and 7.3 incompatible. I will fix them if considered mergable etc. But if the changes to the interface are decided to be a breaking change and require a major version bump it might be considered to bump the minimum versions as well? |
this is okay. I’m not willing to merge anything that would make the code more complex, because you can generate the container dump before running PHPStan. It’s been done like that for many years and people don’t have a problem with that. For example you can use make or Composer scripts to still invoke a single command. |
Currently one can not use PHPStans
bootstrapFilesto create the container (dump) which could then be ready bysymfony.containerXmlPath. This as the order of initialization results in theXmlServiceMapFactory/XmlParameterMapFactorycreatemethods being called before thebootstrapFilesare executed. By making theServiceMap/ParameterMaplazy these will only be created when actually used, which is after thebootstrapFileshave been executed.