Skip to content

Commit

Permalink
feature: introduce ahead-of-time factory compiler
Browse files Browse the repository at this point in the history
There are projects out there which do want to have "autowiring". Since the service manager is not build with that kind of autowiring compatibility, some developers started to use `ReflectionBasedAbstractFactory` so that they can prevent themselves from writing factories.

Since this project does already provide a CLI command to generate factories, having another CLI command which scans the project configuration for services registered via `ReflectionBasedAbstractFactory` should work.

With this change, both `ReflectionBasedAbstractFactory` and `FactoryCreator`-Command do use the same constructor parameter resolving logic. Due to this, we can safely assume that all services registered with a `ReflectionBasedAbstractFactory` can also be generated during CI.

Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Feb 24, 2023
1 parent 0fe2d78 commit c7f87d6
Show file tree
Hide file tree
Showing 23 changed files with 951 additions and 285 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"brick/varexporter": "^0.3.8",
"laminas/laminas-stdlib": "^3.2.1",
"psr/container": "^1.0"
},
Expand All @@ -49,6 +50,7 @@
"laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-container-config-test": "^0.8",
"laminas/laminas-dependency-plugin": "^2.2",
"lctrs/psalm-psr-container-plugin": "^1.9",
"mikey179/vfsstream": "^1.6.11@alpha",
"ocramius/proxy-manager": "^2.14.1",
"phpbench/phpbench": "^1.2.7",
Expand Down Expand Up @@ -79,7 +81,8 @@
"psr-4": {
"LaminasTest\\ServiceManager\\": "test/",
"LaminasBench\\ServiceManager\\": "benchmarks/"
}
},
"classmap": ["tmp"]
},
"bin": [
"bin/generate-deps-for-config-factory",
Expand Down
241 changes: 184 additions & 57 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
</InternalClass>
<InternalMethod>
<errorLevel type="suppress">
<referencedMethod name="Laminas\ServiceManager\Tool\FactoryCreator::__construct"/>
<referencedMethod name="Laminas\ServiceManager\Tool\FactoryCreator::createFactory"/>
<referencedMethod name="Laminas\ServiceManager\Tool\ConfigDumper::createDependencyConfig"/>
<referencedMethod name="Laminas\ServiceManager\Tool\ConfigDumper::dumpConfigFile"/>
Expand All @@ -67,5 +68,6 @@
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
<pluginClass class="Boesing\PsalmPluginStringf\Plugin"/>
<pluginClass class="Lctrs\PsalmPsrContainerPlugin\Plugin"/>
</plugins>
</psalm>
Loading

0 comments on commit c7f87d6

Please sign in to comment.