From 358d4c6c126653bba04945ab6d2c0c70f570be87 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 31 Dec 2019 11:44:40 -0600 Subject: [PATCH] Rewriting as Laminas Project package --- .gitattributes | 18 +- .gitignore | 25 +- .travis.yml | 16 +- CHANGELOG.md | 122 ++++----- CONDUCT.md | 43 ---- CONTRIBUTING.md | 233 ------------------ COPYRIGHT.md | 2 + LICENSE.md | 17 +- README.md | 18 +- benchmarks/BenchAsset/AbstractFactoryFoo.php | 11 +- benchmarks/BenchAsset/Bar.php | 9 +- benchmarks/BenchAsset/Dependency.php | 9 +- benchmarks/BenchAsset/FactoryFoo.php | 11 +- benchmarks/BenchAsset/Foo.php | 9 +- .../BenchAsset/ServiceDependingOnConfig.php | 9 +- .../BenchAsset/ServiceWithDependency.php | 9 +- benchmarks/FetchCachedServicesBench.php | 11 +- benchmarks/FetchNewServiceManagerBench.php | 11 +- ...ingConfigAbstractFactoryAsFactoryBench.php | 13 +- ...eflectionAbstractFactoryAsFactoryBench.php | 13 +- ...ewServiceViaConfigAbstractFactoryBench.php | 13 +- ...rviceViaReflectionAbstractFactoryBench.php | 13 +- benchmarks/FetchNewServicesBench.php | 11 +- benchmarks/SetNewServicesBench.php | 11 +- bin/generate-deps-for-config-factory | 9 +- bin/generate-factory-for-class | 9 +- composer.json | 59 +++-- doc/book/config-abstract-factory.md | 10 +- doc/book/configuring-the-service-manager.md | 32 +-- doc/book/console-tools.md | 4 +- .../factories-vs-abstract-factories.md | 6 +- doc/book/delegators.md | 16 +- doc/book/index.html | 4 +- doc/book/lazy-services.md | 14 +- doc/book/migration.md | 134 +++++----- doc/book/plugin-managers.md | 6 +- doc/book/quick-start.md | 8 +- doc/book/reflection-abstract-factory.md | 76 +++--- mkdocs.yml | 9 +- phpcs.xml | 4 +- phpunit.xml.dist | 2 +- src/AbstractFactory/ConfigAbstractFactory.php | 13 +- .../ReflectionBasedAbstractFactory.php | 21 +- src/AbstractFactoryInterface.php | 15 +- src/AbstractPluginManager.php | 13 +- src/Config.php | 19 +- src/ConfigInterface.php | 9 +- src/DelegatorFactoryInterface.php | 15 +- ...tainerModificationsNotAllowedException.php | 9 +- src/Exception/CyclicAliasException.php | 9 +- src/Exception/ExceptionInterface.php | 11 +- src/Exception/InvalidArgumentException.php | 9 +- src/Exception/InvalidServiceException.php | 9 +- src/Exception/ServiceNotCreatedException.php | 9 +- src/Exception/ServiceNotFoundException.php | 9 +- src/Factory/AbstractFactoryInterface.php | 9 +- src/Factory/DelegatorFactoryInterface.php | 13 +- src/Factory/FactoryInterface.php | 13 +- src/Factory/InvokableFactory.php | 9 +- src/FactoryInterface.php | 15 +- src/Initializer/InitializerInterface.php | 9 +- src/InitializerInterface.php | 15 +- src/PluginManagerInterface.php | 11 +- src/Proxy/LazyServiceFactory.php | 13 +- src/ServiceLocatorInterface.php | 9 +- src/ServiceManager.php | 21 +- src/Test/CommonPluginManagerTrait.php | 13 +- src/Tool/ConfigDumper.php | 14 +- src/Tool/ConfigDumperCommand.php | 13 +- src/Tool/FactoryCreator.php | 13 +- src/Tool/FactoryCreatorCommand.php | 13 +- .../ConfigAbstractFactoryTest.php | 23 +- .../ReflectionBasedAbstractFactoryTest.php | 14 +- .../ClassAcceptingConfigToConstructor.php | 9 +- ...llKnownServicesAsConstructorParameters.php | 9 +- .../TestAsset/ClassWithEmptyConstructor.php | 9 +- .../ClassWithMixedConstructorParameters.php | 9 +- .../TestAsset/ClassWithNoConstructor.php | 9 +- ...thScalarDependencyDefiningDefaultValue.php | 9 +- .../TestAsset/ClassWithScalarParameters.php | 9 +- ...lassWithTypeHintedConstructorParameter.php | 9 +- .../TestAsset/SampleInterface.php | 9 +- .../TestAsset/ValidatorPluginManager.php | 11 +- test/AbstractPluginManagerTest.php | 35 +-- test/CommonServiceLocatorBehaviorsTrait.php | 67 ++--- test/ConfigTest.php | 15 +- test/ExamplePluginManagerTest.php | 17 +- test/Exception/CyclicAliasExceptionTest.php | 13 +- test/Factory/InvokableFactoryTest.php | 15 +- test/LazyServiceIntegrationTest.php | 31 +-- test/Proxy/LazyServiceFactoryTest.php | 19 +- test/ServiceManagerTest.php | 25 +- test/TestAsset/CallTimesAbstractFactory.php | 11 +- .../TestAsset/ClassDependingOnAnInterface.php | 11 +- test/TestAsset/ComplexDependencyObject.php | 9 +- test/TestAsset/DoubleDependencyObject.php | 9 +- test/TestAsset/ExceptionWithStringAsCode.php | 9 +- test/TestAsset/ExtendedConfig.php | 11 +- test/TestAsset/FactoryObject.php | 9 +- test/TestAsset/FailingAbstractFactory.php | 11 +- ...ailingExceptionWithStringAsCodeFactory.php | 11 +- test/TestAsset/FailingFactory.php | 11 +- test/TestAsset/InvokableObject.php | 9 +- test/TestAsset/LenientPluginManager.php | 11 +- .../NonAutoInvokablePluginManager.php | 11 +- .../ObjectWithObjectScalarDependency.php | 9 +- test/TestAsset/ObjectWithScalarDependency.php | 9 +- test/TestAsset/PreDelegator.php | 11 +- test/TestAsset/SampleFactory.php | 11 +- .../SecondComplexDependencyObject.php | 9 +- test/TestAsset/SimpleAbstractFactory.php | 11 +- test/TestAsset/SimpleDependencyObject.php | 9 +- test/TestAsset/SimpleInitializer.php | 11 +- test/TestAsset/SimplePluginManager.php | 11 +- test/TestAsset/SimpleServiceManager.php | 13 +- test/TestAsset/V2ValidationPluginManager.php | 11 +- test/TestAsset/V2v3PluginManager.php | 23 +- test/TestAsset/config/invalid.config.php | 7 +- test/TestAsset/config/test.config.php | 7 +- .../factories/ComplexDependencyObject.php | 10 +- test/TestAsset/factories/InvokableObject.php | 6 +- .../factories/SimpleDependencyObject.php | 8 +- test/Tool/ConfigDumperCommandTest.php | 23 +- test/Tool/ConfigDumperTest.php | 35 +-- test/Tool/FactoryCreatorCommandTest.php | 19 +- test/Tool/FactoryCreatorTest.php | 17 +- 126 files changed, 1018 insertions(+), 1183 deletions(-) delete mode 100644 CONDUCT.md delete mode 100644 CONTRIBUTING.md create mode 100644 COPYRIGHT.md diff --git a/.gitattributes b/.gitattributes index 7325c690..459bfe20 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,10 @@ -/test export-ignore -/vendor export-ignore -.coveralls.yml export-ignore -.gitattributes export-ignore -.gitignore export-ignore -.travis.yml export-ignore -.php_cs export-ignore -phpunit.xml.dist export-ignore +/.coveralls.yml export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/benchmarks/ export-ignore +/doc/ export-ignore +/mkdocs.yml export-ignore +/phpcs.xml export-ignore +/phpunit.xml.dist export-ignore +/test/ export-ignore diff --git a/.gitignore b/.gitignore index f146c861..8078c7d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,8 @@ -.buildpath -.DS_Store -.idea -.project -.settings/ -.*.sw* -.*.un~ -nbproject -doc/html/ -tmp/ -zf-mkdoc-theme/ - -clover.xml -composer.lock -coveralls-upload.json -phpunit.xml -vendor +/clover.xml +/composer.lock +/coveralls-upload.json +/doc/html/ +/laminas-mkdoc-theme.tgz +/laminas-mkdoc-theme/ +/phpunit.xml +/vendor/ diff --git a/.travis.yml b/.travis.yml index ad367a30..d25ea1f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -sudo: false - language: php branches: @@ -11,17 +9,18 @@ cache: directories: - $HOME/.composer/cache - $HOME/.local - - zf-mkdoc-theme + - laminas-mkdoc-theme env: global: - - SITE_URL: https://zendframework.github.io/zend-servicemanager + - SITE_URL: https://docs.laminas.dev/laminas-servicemanager - GH_USER_NAME: "Matthew Weier O'Phinney" - GH_USER_EMAIL: matthew@weierophinney.net - - GH_REF: github.com/zendframework/zend-servicemanager.git - - secure: "KoLcNj22t668IhAhm5ej6DNf23waoGrZpQ1kmuq5ptTqsXjFjy/cjOJCvWOeRX62Tl2kjc7co9UeK0f91osZ2Wq7HLb+1bIXX5SrB6SfyPUajCQtCtu0xGgEKZfuQwzLWSYoR3tsaD6vqgMjKwwst10d+AyICjdLNu9dHtdu9HpozZtK3kM9+0FwMOiRqFEND2GY05oVYXOrzgu1xNmE1YEGpjKzqqBNpqFOP4W+OnTMRTQcyrlbFzOFvAip7X3GGw9iUSnSzZTnIOWJgMdah8/eFqhrPO8O73faW+/v3ZTxdwupOEZyg7s3TD6+W9rjmN+TgOZEP484PcSlUc6sXA4QM4iL8xthG3bWk8+CDrsnuQmunrXz7T5xUEHs/7B8NuGJ8yT89fMCYGySERKIfCx17+N9kP/848A/+39LE1NIlTxnaPISfm9WMNG67xsEKyJluC/YataPGl0zZ6/7Q7w1oDYvjhsqooUsxKRD2/psd1zrVDJurDa7Ayv/E21u2dIDtbp6w9Zl+he+kwRItMNhtCdzyShqtuY0V/JRmn2lZY2PsfbICRXXAbQnDveNFYz5tE2K40Qm4RWrdZ4cnaLiNJeukdYKVJCFHtZr9rdx1uVeK78Pf5o3rt4S8S1aat35eMZQunc6s4gmeXU5+wIxwXiyOtkdlL3LztSox9s=" + - GH_REF: github.com/laminas/laminas-servicemanager.git + - secure: "KoLcNj22t668IhAhm5ej6DNf23waoGrZpQ1kmuq5ptTqsXjFjy/cjOJCvWOeRX62Tl2kjc7co9UeK0f91osZ2Wq7HLb+1bIXX5SrB6SfyPUajCQtCtu0xGgEKLaminasuQwzLWSYoR3tsaD6vqgMjKwwst10d+AyICjdLNu9dHtdu9HpozZtK3kM9+0FwMOiRqFEND2GY05oVYXOrzgu1xNmE1YEGpjKzqqBNpqFOP4W+OnTMRTQcyrlbFzOFvAip7X3GGw9iUSnSzZTnIOWJgMdah8/eFqhrPO8O73faW+/v3ZTxdwupOEZyg7s3TD6+W9rjmN+TgOZEP484PcSlUc6sXA4QM4iL8xthG3bWk8+CDrsnuQmunrXz7T5xUEHs/7B8NuGJ8yT89fMCYGySERKIfCx17+N9kP/848A/+39LE1NIlTxnaPISfm9WMNG67xsEKyJluC/YataPGl0zZ6/7Q7w1oDYvjhsqooUsxKRD2/psd1zrVDJurDa7Ayv/E21u2dIDtbp6w9Zl+he+kwRItMNhtCdzyShqtuY0V/JRmn2lZY2PsfbICRXXAbQnDveNFYz5tE2K40Qm4RWrdZ4cnaLiNJeukdYKVJCFHtZr9rdx1uVeK78Pf5o3rt4S8S1aat35eMZQunc6s4gmeXU5+wIxwXiyOtkdlL3LztSox9s=" matrix: + fast_finish: true include: - php: 5.6 env: @@ -37,7 +36,6 @@ matrix: - php: hhvm notifications: - irc: "irc.freenode.org#zftalk.dev" email: false before_install: @@ -52,10 +50,10 @@ script: - if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi - if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi - if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi - - if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi + - if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/laminas/laminas-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi after_success: - - if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi + - if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./laminas-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi after_script: - if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 36ef2ce5..086437c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file, in reverse ### Added -- [#176](https://github.com/zendframework/zend-servicemanager/pull/176) adds +- [zendframework/zend-servicemanager#176](https://github.com/zendframework/zend-servicemanager/pull/176) adds the options `-i` or `--ignore-unresolved` to the shipped `generate-deps-for-config-factory` command. This flag allows it to build configuration for classes resolved by the `ConfigAbstractFactory` that @@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- [#174](https://github.com/zendframework/zend-servicemanager/pull/174) updates +- [zendframework/zend-servicemanager#174](https://github.com/zendframework/zend-servicemanager/pull/174) updates the `ConfigAbstractFactory` to allow the `config` service to be either an `array` or an `ArrayObject`; previously, only `array` was supported. @@ -30,24 +30,24 @@ All notable changes to this project will be documented in this file, in reverse ### Added -- [#146](https://github.com/zendframework/zend-servicemanager/pull/146) adds - `Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory`, which enables a +- [zendframework/zend-servicemanager#146](https://github.com/zendframework/zend-servicemanager/pull/146) adds + `Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory`, which enables a configuration-based approach to providing class dependencies when all dependencies are services known to the `ServiceManager`. Please see [the documentation](doc/book/config-abstract-factory.md) for details. -- [#154](https://github.com/zendframework/zend-servicemanager/pull/154) adds - `Zend\ServiceManager\Tool\ConfigDumper`, which will introspect a given class +- [zendframework/zend-servicemanager#154](https://github.com/zendframework/zend-servicemanager/pull/154) adds + `Laminas\ServiceManager\Tool\ConfigDumper`, which will introspect a given class to determine dependencies, and then create configuration for - `Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory`, merging it with + `Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory`, merging it with the provided configuration file. It also adds a vendor binary, `generate-deps-for-config-factory`, for generating these from the command line. -- [#154](https://github.com/zendframework/zend-servicemanager/pull/154) adds - `Zend\ServiceManager\Tool\FactoryCreator`, which will introspect a given class +- [zendframework/zend-servicemanager#154](https://github.com/zendframework/zend-servicemanager/pull/154) adds + `Laminas\ServiceManager\Tool\FactoryCreator`, which will introspect a given class and generate a factory for it. It also adds a vendor binary, `generate-factory-for-class`, for generating these from the command line. -- [#153](https://github.com/zendframework/zend-servicemanager/pull/153) adds - `Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory`. This +- [zendframework/zend-servicemanager#153](https://github.com/zendframework/zend-servicemanager/pull/153) adds + `Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory`. This class may be used as either a mapped factory or an abstract factory, and will use reflection in order to determine which dependencies to use from the container when instantiating the requested service, with the following rules: @@ -56,7 +56,7 @@ All notable changes to this project will be documented in this file, in reverse `config` service, if present. - All other array values will be provided an empty array. - Class/interface typehints will be pulled from the container. -- [#150](https://github.com/zendframework/zend-servicemanager/pull/150) adds +- [zendframework/zend-servicemanager#150](https://github.com/zendframework/zend-servicemanager/pull/150) adds a "cookbook" section to the documentation, with an initial document detailing the pros and cons of abstract factory usage. @@ -70,7 +70,7 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- [#106](https://github.com/zendframework/zend-servicemanager/pull/106) adds +- [zendframework/zend-servicemanager#106](https://github.com/zendframework/zend-servicemanager/pull/106) adds detection of multiple attempts to register the same instance or named abstract factory, using a previous instance when detected. You may still use multiple discrete instances, however. @@ -91,7 +91,7 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- [#167](https://github.com/zendframework/zend-servicemanager/pull/167) fixes +- [zendframework/zend-servicemanager#167](https://github.com/zendframework/zend-servicemanager/pull/167) fixes how exception codes are provided to ServiceNotCreatedException. Previously, the code was provided as-is. However, some PHP internal exception classes, notably PDOException, can sometimes return other values (such as strings), @@ -114,7 +114,7 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- [#136](https://github.com/zendframework/zend-servicemanager/pull/136) removes +- [zendframework/zend-servicemanager#136](https://github.com/zendframework/zend-servicemanager/pull/136) removes several imports to classes in subnamespaces within the `ServiceManager` classfile, removing potential name resolution conflicts that occurred in edge cases when testing. @@ -123,16 +123,16 @@ All notable changes to this project will be documented in this file, in reverse ### Added -- [#103](https://github.com/zendframework/zend-servicemanager/pull/103) Allowing +- [zendframework/zend-servicemanager#103](https://github.com/zendframework/zend-servicemanager/pull/103) Allowing installation of `ocramius/proxy-manager` `^2.0` together with `zendframework/zend-servicemanager`. -- [#103](https://github.com/zendframework/zend-servicemanager/pull/103) Disallowing +- [zendframework/zend-servicemanager#103](https://github.com/zendframework/zend-servicemanager/pull/103) Disallowing test failures when running tests against PHP `7.0.*`. -- [#113](https://github.com/zendframework/zend-servicemanager/pull/113) Improved performance +- [zendframework/zend-servicemanager#113](https://github.com/zendframework/zend-servicemanager/pull/113) Improved performance when dealing with registering aliases and factories via `ServiceManager#setFactory()` and `ServiceManager#setAlias()` -- [#120](https://github.com/zendframework/zend-servicemanager/pull/120) The - `zendframework/zend-servicemanager` component now provides a +- [zendframework/zend-servicemanager#120](https://github.com/zendframework/zend-servicemanager/pull/120) The + `laminas/laminas-servicemanager` component now provides a `container-interop/container-interop-implementation` implementation ### Deprecated @@ -145,9 +145,9 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- [#97](https://github.com/zendframework/zend-servicemanager/pull/97) Typo corrections +- [zendframework/zend-servicemanager#97](https://github.com/zendframework/zend-servicemanager/pull/97) Typo corrections in the delegator factories documentation. -- [#98](https://github.com/zendframework/zend-servicemanager/pull/98) Using coveralls ^1.0 +- [zendframework/zend-servicemanager#98](https://github.com/zendframework/zend-servicemanager/pull/98) Using coveralls ^1.0 for tracking test code coverage changes. ## 3.0.4 - TBD @@ -172,15 +172,15 @@ All notable changes to this project will be documented in this file, in reverse ### Added -- [#89](https://github.com/zendframework/zend-servicemanager/pull/89) adds +- [zendframework/zend-servicemanager#89](https://github.com/zendframework/zend-servicemanager/pull/89) adds cyclic alias detection to the `ServiceManager`; it now raises a - `Zend\ServiceManager\Exception\CyclicAliasException` when one is detected, + `Laminas\ServiceManager\Exception\CyclicAliasException` when one is detected, detailing the cycle detected. -- [#95](https://github.com/zendframework/zend-servicemanager/pull/95) adds +- [zendframework/zend-servicemanager#95](https://github.com/zendframework/zend-servicemanager/pull/95) adds GitHub Pages publication automation, and moves the documentation to - https://zendframework.github.io/zend-servicemanager/ -- [#93](https://github.com/zendframework/zend-servicemanager/pull/93) adds - `Zend\ServiceManager\Test\CommonPluginManagerTrait`, which can be used to + https://docs.laminas.dev/laminas-servicemanager/ +- [zendframework/zend-servicemanager#93](https://github.com/zendframework/zend-servicemanager/pull/93) adds + `Laminas\ServiceManager\Test\CommonPluginManagerTrait`, which can be used to validate that a plugin manager instance is ready for version 3. ### Deprecated @@ -193,19 +193,19 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- [#90](https://github.com/zendframework/zend-servicemanager/pull/90) fixes +- [zendframework/zend-servicemanager#90](https://github.com/zendframework/zend-servicemanager/pull/90) fixes several examples in the configuration chapter of the documentation, ensuring that the signatures are correct. -- [#92](https://github.com/zendframework/zend-servicemanager/pull/92) ensures +- [zendframework/zend-servicemanager#92](https://github.com/zendframework/zend-servicemanager/pull/92) ensures that alias resolution is skipped during configuration if no aliases are - present, and forward-ports the test from [#81](https://github.com/zendframework/zend-servicemanager/pull/81) + present, and forward-ports the test from [zendframework/zend-servicemanager#81](https://github.com/zendframework/zend-servicemanager/pull/81) to validate v2/v3 compatibility for plugin managers. ## 3.0.2 - 2016-01-24 ### Added -- [#64](https://github.com/zendframework/zend-servicemanager/pull/64) performance optimizations +- [zendframework/zend-servicemanager#64](https://github.com/zendframework/zend-servicemanager/pull/64) performance optimizations when dealing with alias resolution during service manager instantiation ### Deprecated @@ -218,14 +218,14 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- [#62](https://github.com/zendframework/zend-servicemanager/pull/62) - [#64](https://github.com/zendframework/zend-servicemanager/pull/64) corrected benchmark assets signature -- [#72](https://github.com/zendframework/zend-servicemanager/pull/72) corrected link to the Proxy Pattern Wikipedia +- [zendframework/zend-servicemanager#62](https://github.com/zendframework/zend-servicemanager/pull/62) + [zendframework/zend-servicemanager#64](https://github.com/zendframework/zend-servicemanager/pull/64) corrected benchmark assets signature +- [zendframework/zend-servicemanager#72](https://github.com/zendframework/zend-servicemanager/pull/72) corrected link to the Proxy Pattern Wikipedia page in the documentation -- [#78](https://github.com/zendframework/zend-servicemanager/issues/78) - [#79](https://github.com/zendframework/zend-servicemanager/pull/79) creation context was not being correctly passed +- [zendframework/zend-servicemanager#78](https://github.com/zendframework/zend-servicemanager/issues/78) + [zendframework/zend-servicemanager#79](https://github.com/zendframework/zend-servicemanager/pull/79) creation context was not being correctly passed to abstract factories when using plugin managers -- [#82](https://github.com/zendframework/zend-servicemanager/pull/82) corrected migration guide in the DocBlock of +- [zendframework/zend-servicemanager#82](https://github.com/zendframework/zend-servicemanager/pull/82) corrected migration guide in the DocBlock of the `InitializerInterface` ## 3.0.1 - 2016-01-19 @@ -240,9 +240,9 @@ All notable changes to this project will be documented in this file, in reverse ### Removed -- [#68](https://github.com/zendframework/zend-servicemanager/pull/68) removes - the dependency on zend-stdlib by inlining the `ArrayUtils::merge()` routine - as a private method of `Zend\ServiceManager\Config`. +- [zendframework/zend-servicemanager#68](https://github.com/zendframework/zend-servicemanager/pull/68) removes + the dependency on laminas-stdlib by inlining the `ArrayUtils::merge()` routine + as a private method of `Laminas\ServiceManager\Config`. ### Fixed @@ -250,21 +250,21 @@ All notable changes to this project will be documented in this file, in reverse ## 3.0.0 - 2016-01-11 -First stable release of version 3 of zend-servicemanager. +First stable release of version 3 of laminas-servicemanager. -Documentation is now available at http://zend-servicemanager.rtfd.org +Documentation is now available at http://laminas-servicemanager.rtfd.org ### Added - You can now map multiple key names to the same factory. It was previously - possible in ZF2 but it was not enforced by the `FactoryInterface` interface. + possible in Laminas but it was not enforced by the `FactoryInterface` interface. Now the interface receives the `$requestedName` as the *second* parameter (previously, it was the third). Example: ```php - $sm = new \Zend\ServiceManager\ServiceManager([ + $sm = new \Laminas\ServiceManager\ServiceManager([ 'factories' => [ MyClassA::class => MyFactory::class, MyClassB::class => MyFactory::class, @@ -279,7 +279,7 @@ Documentation is now available at http://zend-servicemanager.rtfd.org longer need to implement the complete `validate` method. In versions 2.x, if your plugin manager only allows creating instances that - implement `Zend\Validator\ValidatorInterface`, you needed to write the + implement `Laminas\Validator\ValidatorInterface`, you needed to write the following code: ```php @@ -287,14 +287,14 @@ Documentation is now available at http://zend-servicemanager.rtfd.org { public function validate($instance) { - if ($instance instanceof \Zend\Validator\ValidatorInterface) { + if ($instance instanceof \Laminas\Validator\ValidatorInterface) { return; } throw new InvalidServiceException(sprintf( 'Plugin manager "%s" expected an instance of type "%s", but "%s" was received', __CLASS__, - \Zend\Validator\ValidatorInterface::class, + \Laminas\Validator\ValidatorInterface::class, is_object($instance) ? get_class($instance) : gettype($instance) )); } @@ -304,8 +304,8 @@ Documentation is now available at http://zend-servicemanager.rtfd.org In version 3, this becomes: ```php - use Zend\ServiceManager\AbstractPluginManager; - use Zend\Validator\ValidatorInterface; + use Laminas\ServiceManager\AbstractPluginManager; + use Laminas\Validator\ValidatorInterface; class MyPluginManager extends AbstractPluginManager { @@ -337,7 +337,7 @@ Documentation is now available at http://zend-servicemanager.rtfd.org - Peering has been removed. It was a complex and rarely used feature that was misunderstood most of the time. -- Integration with `Zend\Di` has been removed. It may be re-integrated later. +- Integration with `Laminas\Di` has been removed. It may be re-integrated later. - `MutableCreationOptionsInterface` has been removed, as options can now be passed directly through factories. @@ -352,23 +352,23 @@ v3 of the ServiceManager component is a completely rewritten, more efficient implementation of the service locator pattern. It includes a number of breaking changes, outlined in this section. -- You no longer need a `Zend\ServiceManager\Config` object to configure the +- You no longer need a `Laminas\ServiceManager\Config` object to configure the service manager; you can pass the configuration array directly instead. In version 2.x: ```php - $config = new \Zend\ServiceManager\Config([ + $config = new \Laminas\ServiceManager\Config([ 'factories' => [...] ]); - $sm = new \Zend\ServiceManager\ServiceManager($config); + $sm = new \Laminas\ServiceManager\ServiceManager($config); ``` - In ZF 3.x: + In Laminas 3.x: ```php - $sm = new \Zend\ServiceManager\ServiceManager([ + $sm = new \Laminas\ServiceManager\ServiceManager([ 'factories' => [...] ]); ``` @@ -492,7 +492,7 @@ changes, outlined in this section. ### Added -- [#60](https://github.com/zendframework/zend-servicemanager/pull/60) adds +- [zendframework/zend-servicemanager#60](https://github.com/zendframework/zend-servicemanager/pull/60) adds forward compatibility features for `AbstractPluingManager` and introduces `InvokableFactory` to help forward migration to version 3. @@ -506,11 +506,11 @@ changes, outlined in this section. ### Fixed -- [#46](https://github.com/zendframework/zend-servicemanager/pull/46) updates +- [zendframework/zend-servicemanager#46](https://github.com/zendframework/zend-servicemanager/pull/46) updates the exception hierarchy to inherit from the container-interop exceptions. This ensures that all exceptions thrown by the component follow the recommendations of that project. -- [#52](https://github.com/zendframework/zend-servicemanager/pull/52) fixes +- [zendframework/zend-servicemanager#52](https://github.com/zendframework/zend-servicemanager/pull/52) fixes the exception message thrown by `ServiceManager::setFactory()` to remove references to abstract factories. @@ -518,7 +518,7 @@ changes, outlined in this section. ### Added -- [#4](https://github.com/zendframework/zend-servicemanager/pull/4) updates the +- [zendframework/zend-servicemanager#4](https://github.com/zendframework/zend-servicemanager/pull/4) updates the `ServiceManager` to [implement the container-interop interface](https://github.com/container-interop/container-interop), allowing interoperability with applications that consume that interface. @@ -532,7 +532,7 @@ changes, outlined in this section. ### Fixed -- [#3](https://github.com/zendframework/zend-servicemanager/pull/3) properly updates the +- [zendframework/zend-servicemanager#3](https://github.com/zendframework/zend-servicemanager/pull/3) properly updates the codebase to PHP 5.5, by taking advantage of the default closure binding (`$this` in a closure is the invoking object when created within a method). It also removes several `@requires PHP 5.4.0` annotations. diff --git a/CONDUCT.md b/CONDUCT.md deleted file mode 100644 index c663d2be..00000000 --- a/CONDUCT.md +++ /dev/null @@ -1,43 +0,0 @@ -# Contributor Code of Conduct - -The Zend Framework project adheres to [The Code Manifesto](http://codemanifesto.com) -as its guidelines for contributor interactions. - -## The Code Manifesto - -We want to work in an ecosystem that empowers developers to reach their -potential — one that encourages growth and effective collaboration. A space that -is safe for all. - -A space such as this benefits everyone that participates in it. It encourages -new developers to enter our field. It is through discussion and collaboration -that we grow, and through growth that we improve. - -In the effort to create such a place, we hold to these values: - -1. **Discrimination limits us.** This includes discrimination on the basis of - race, gender, sexual orientation, gender identity, age, nationality, technology - and any other arbitrary exclusion of a group of people. -2. **Boundaries honor us.** Your comfort levels are not everyone’s comfort - levels. Remember that, and if brought to your attention, heed it. -3. **We are our biggest assets.** None of us were born masters of our trade. - Each of us has been helped along the way. Return that favor, when and where - you can. -4. **We are resources for the future.** As an extension of #3, share what you - know. Make yourself a resource to help those that come after you. -5. **Respect defines us.** Treat others as you wish to be treated. Make your - discussions, criticisms and debates from a position of respectfulness. Ask - yourself, is it true? Is it necessary? Is it constructive? Anything less is - unacceptable. -6. **Reactions require grace.** Angry responses are valid, but abusive language - and vindictive actions are toxic. When something happens that offends you, - handle it assertively, but be respectful. Escalate reasonably, and try to - allow the offender an opportunity to explain themselves, and possibly correct - the issue. -7. **Opinions are just that: opinions.** Each and every one of us, due to our - background and upbringing, have varying opinions. The fact of the matter, is - that is perfectly acceptable. Remember this: if you respect your own - opinions, you should respect the opinions of others. -8. **To err is human.** You might not intend it, but mistakes do happen and - contribute to build experience. Tolerate honest mistakes, and don't hesitate - to apologize if you make one yourself. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 19003077..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,233 +0,0 @@ -# CONTRIBUTING - -## RESOURCES - -If you wish to contribute to Zend Framework, please be sure to -read/subscribe to the following resources: - - - [Coding Standards](https://github.com/zendframework/zf2/wiki/Coding-Standards) - - [Contributor's Guide](http://framework.zend.com/participate/contributor-guide) - - ZF Contributor's mailing list: - Archives: http://zend-framework-community.634137.n4.nabble.com/ZF-Contributor-f680267.html - Subscribe: zf-contributors-subscribe@lists.zend.com - - ZF Contributor's IRC channel: - #zftalk.dev on Freenode.net - -If you are working on new features or refactoring [create a proposal](https://github.com/zendframework/zend-servicemanager/issues/new). - -## Reporting Potential Security Issues - -If you have encountered a potential security vulnerability, please **DO NOT** report it on the public -issue tracker: send it to us at [zf-security@zend.com](mailto:zf-security@zend.com) instead. -We will work with you to verify the vulnerability and patch it as soon as possible. - -When reporting issues, please provide the following information: - -- Component(s) affected -- A description indicating how to reproduce the issue -- A summary of the security vulnerability and impact - -We request that you contact us via the email address above and give the project -contributors a chance to resolve the vulnerability and issue a new release prior -to any public exposure; this helps protect users and provides them with a chance -to upgrade and/or update in order to protect their applications. - -For sensitive email communications, please use [our PGP key](http://framework.zend.com/zf-security-pgp-key.asc). - -## RUNNING TESTS - -> ### Note: testing versions prior to 2.4 -> -> This component originates with Zend Framework 2. During the lifetime of ZF2, -> testing infrastructure migrated from PHPUnit 3 to PHPUnit 4. In most cases, no -> changes were necessary. However, due to the migration, tests may not run on -> versions < 2.4. As such, you may need to change the PHPUnit dependency if -> attempting a fix on such a version. - -To run tests: - -- Clone the repository: - - ```console - $ git clone git@github.com:zendframework/zend-servicemanager.git - $ cd - ``` - -- Install dependencies via composer: - - ```console - $ curl -sS https://getcomposer.org/installer | php -- - $ ./composer.phar install - ``` - - If you don't have `curl` installed, you can also download `composer.phar` from https://getcomposer.org/ - -- Run the tests: - - ```console - $ composer test - ``` - -You can turn on conditional tests with the `phpunit.xml` file. -To do so: - - - Copy `phpunit.xml.dist` file to `phpunit.xml` - - Edit `phpunit.xml` to enable any specific functionality you - want to test, as well as to provide test values to utilize. - -## Running Coding Standards Checks - -This component follows [PSR-1](http://www.php-fig.org/psr/psr-1/) and -[PSR-2](http://www.php-fig.org/psr/psr-2/) guidelines, and ships with tooling -for both checking code against standards, as well as fixing most errors. - -To run checks only: - -```console -$ composer cs-check -``` - -To fix common errors: - -```console -$ composer cs-fix -``` - -If you allow tooling to fix CS issues, please re-run the tests to ensure -they pass, and make sure you add and commit the changes after verification. - -## Recommended Workflow for Contributions - -Your first step is to establish a public repository from which we can -pull your work into the master repository. We recommend using -[GitHub](https://github.com), as that is where the component is already hosted. - -1. Setup a [GitHub account](http://github.com/), if you haven't yet -2. Fork the repository (http://github.com/zendframework/zend-servicemanager) -3. Clone the canonical repository locally and enter it. - - ```console - $ git clone git://github.com:zendframework/zend-servicemanager.git - $ cd zend-servicemanager - ``` - -4. Add a remote to your fork; substitute your GitHub username in the command - below. - - ```console - $ git remote add {username} git@github.com:{username}/zend-servicemanager.git - $ git fetch {username} - ``` - -### Keeping Up-to-Date - -Periodically, you should update your fork or personal repository to -match the canonical ZF repository. Assuming you have setup your local repository -per the instructions above, you can do the following: - - -```console -$ git checkout master -$ git fetch origin -$ git rebase origin/master -# OPTIONALLY, to keep your remote up-to-date - -$ git push {username} master:master -``` - -If you're tracking other branches -- for example, the "develop" branch, where -new feature development occurs -- you'll want to do the same operations for that -branch; simply substitute "develop" for "master". - -### Working on a patch - -We recommend you do each new feature or bugfix in a new branch. This simplifies -the task of code review as well as the task of merging your changes into the -canonical repository. - -A typical workflow will then consist of the following: - -1. Create a new local branch based off either your master or develop branch. -2. Switch to your new local branch. (This step can be combined with the - previous step with the use of `git checkout -b`.) -3. Do some work, commit, repeat as necessary. -4. Push the local branch to your remote repository. -5. Send a pull request. - -The mechanics of this process are actually quite trivial. Below, we will -create a branch for fixing an issue in the tracker. - -```console -$ git checkout -b hotfix/9295 -Switched to a new branch 'hotfix/9295' -``` - -... do some work ... - - -```console -$ git commit -``` - -... write your log message ... - - -```console -$ git push {username} hotfix/9295:hotfix/9295 -Counting objects: 38, done. -Delta compression using up to 2 threads. -Compression objects: 100% (18/18), done. -Writing objects: 100% (20/20), 8.19KiB, done. -Total 20 (delta 12), reused 0 (delta 0) -To ssh://git@github.com/{username}/zend-servicemanager.git - b5583aa..4f51698 HEAD -> master -``` - -To send a pull request, you have two options. - -If using GitHub, you can do the pull request from there. Navigate to -your repository, select the branch you just created, and then select the -"Pull Request" button in the upper right. Select the user/organization -"zendframework" as the recipient. - -If using your own repository - or even if using GitHub - you can use `git -format-patch` to create a patchset for us to apply; in fact, this is -**recommended** for security-related patches. If you use `format-patch`, please -send the patches as attachments to: - -- zf-devteam@zend.com for patches without security implications -- zf-security@zend.com for security patches - -#### What branch to issue the pull request against? - -Which branch should you issue a pull request against? - -- For fixes against the stable release, issue the pull request against the - "master" branch. -- For new features, or fixes that introduce new elements to the public API (such - as new public methods or properties), issue the pull request against the - "develop" branch. - -### Branch Cleanup - -As you might imagine, if you are a frequent contributor, you'll start to -get a ton of branches both locally and on your remote. - -Once you know that your changes have been accepted to the master -repository, we suggest doing some cleanup of these branches. - -- Local branch cleanup - - ```console - $ git branch -d - ``` - -- Remote branch removal - - ```console - $ git push {username} : - ``` - - -## Conduct - -Please see our [CONDUCT.md](CONDUCT.md) to understand expected behavior when interacting with others in the project. diff --git a/COPYRIGHT.md b/COPYRIGHT.md new file mode 100644 index 00000000..c4fc4fee --- /dev/null +++ b/COPYRIGHT.md @@ -0,0 +1,2 @@ +Copyright (c) 2019, Laminas Foundation. +All rights reserved. (https://getlaminas.org/) diff --git a/LICENSE.md b/LICENSE.md index 25501b09..09f53edc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,20 +1,19 @@ -Copyright (c) 2005-2016, Zend Technologies USA, Inc. - +Copyright (c) 2019, Laminas Foundation All rights reserved. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -- Neither the name of Zend Technologies USA, Inc. nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. +- Neither the name of Laminas Foundation nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED diff --git a/README.md b/README.md index 106e74bf..066ce621 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ -# zend-servicemanager +# laminas-servicemanager Master: -[![Build Status](https://travis-ci.org/zendframework/zend-servicemanager.svg?branch=master)](https://travis-ci.org/zendframework/zend-servicemanager) -[![Coverage Status](https://coveralls.io/repos/zendframework/zend-servicemanager/badge.svg?branch=master)](https://coveralls.io/r/zendframework/zend-servicemanager?branch=master) +[![Build Status](https://travis-ci.org/laminas/laminas-servicemanager.svg?branch=master)](https://travis-ci.org/laminas/laminas-servicemanager) +[![Coverage Status](https://coveralls.io/repos/laminas/laminas-servicemanager/badge.svg?branch=master)](https://coveralls.io/r/laminas/laminas-servicemanager?branch=master) Develop: -[![Build Status](https://travis-ci.org/zendframework/zend-servicemanager.svg?branch=develop)](https://travis-ci.org/zendframework/zend-servicemanager) -[![Coverage Status](https://coveralls.io/repos/zendframework/zend-servicemanager/badge.svg?branch=develop)](https://coveralls.io/r/zendframework/zend-servicemanager?branch=develop) +[![Build Status](https://travis-ci.org/laminas/laminas-servicemanager.svg?branch=develop)](https://travis-ci.org/laminas/laminas-servicemanager) +[![Coverage Status](https://coveralls.io/repos/laminas/laminas-servicemanager/badge.svg?branch=develop)](https://coveralls.io/r/laminas/laminas-servicemanager?branch=develop) -The Service Locator design pattern is implemented by the `Zend\ServiceManager` +The Service Locator design pattern is implemented by the `Laminas\ServiceManager` component. The Service Locator is a service/object locator, tasked with retrieving other objects. -- File issues at https://github.com/zendframework/zend-servicemanager/issues -- [Online documentation](https://zendframework.github.io/zend-servicemanager) +- File issues at https://github.com/laminas/laminas-servicemanager/issues +- [Online documentation](https://docs.laminas.dev/laminas-servicemanager) - [Documentation source files](doc/book/) ## Benchmarks -We provide scripts for benchmarking zend-servicemanager using the +We provide scripts for benchmarking laminas-servicemanager using the [PHPBench](https://github.com/phpbench/phpbench) framework; these can be found in the `benchmarks/` directory. diff --git a/benchmarks/BenchAsset/AbstractFactoryFoo.php b/benchmarks/BenchAsset/AbstractFactoryFoo.php index 68879f68..d54fe3e5 100644 --- a/benchmarks/BenchAsset/AbstractFactoryFoo.php +++ b/benchmarks/BenchAsset/AbstractFactoryFoo.php @@ -1,14 +1,15 @@ [ 'abstract_factories' => [ ConfigAbstractFactory::class, ], ], - // zend-expressive or ConfigProvider consumers: + // mezzio or ConfigProvider consumers: 'dependencies' => [ 'abstract_factories' => [ ConfigAbstractFactory::class, @@ -57,7 +57,7 @@ return [ Configuration should be provided via the `config` service, which should return an array or `ArrayObject`. `ConfigAbstractFactory` looks for a top-level key in -this service named after itself (i.e., `Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory`) +this service named after itself (i.e., `Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory`) that is an array value. Each item in the array: - Should have a key representing the service name (typically the fully @@ -69,7 +69,7 @@ that is an array value. Each item in the array: As an example: ```php -use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory; +use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory; return [ ConfigAbstractFactory::class => [ diff --git a/doc/book/configuring-the-service-manager.md b/doc/book/configuring-the-service-manager.md index 1327c2f4..c7c6154d 100644 --- a/doc/book/configuring-the-service-manager.md +++ b/doc/book/configuring-the-service-manager.md @@ -23,7 +23,7 @@ constructor. The following keys are: Here is an example of how you could configure a service manager: ```php -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\ServiceManager; $serviceManager = new ServiceManager([ 'services' => [], @@ -38,14 +38,14 @@ $serviceManager = new ServiceManager([ ## Factories A factory is any callable or any class that implements the interface -`Zend\ServiceManager\Factory\FactoryInterface`. +`Laminas\ServiceManager\Factory\FactoryInterface`. Service manager components provide a default factory that can be used to create objects that do not have any dependencies: ```php -use Zend\ServiceManager\Factory\InvokableFactory; -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\ServiceManager; use stdClass; $serviceManager = new ServiceManager([ @@ -55,14 +55,14 @@ $serviceManager = new ServiceManager([ ]); ``` -> This mechanism replaces the `invokables` key that was used in Zend Framework 2. +> This mechanism replaces the `invokables` key that was used in Laminas. As said before, a factory can also be a callable, to create more complex objects: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\Factory\InvokableFactory; -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\ServiceManager; use stdClass; $serviceManager = new ServiceManager([ @@ -163,7 +163,7 @@ common creation pattern. An abstract factory must be registered inside the service manager, and is checked if no factory can create an object. Each abstract factory must -implement `Zend\ServiceManager\Factory\AbstractFactoryInterface`: +implement `Laminas\ServiceManager\Factory\AbstractFactoryInterface`: ```php // In MyAbstractFactory.php: @@ -225,8 +225,8 @@ An alias can also be mapped to another alias (it will be resolved recursively). For instance: ```php -use Zend\ServiceManager\Factory\InvokableFactory; -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\ServiceManager; use stdClass; $serviceManager = new ServiceManager([ @@ -258,7 +258,7 @@ refactoring, as most modern IDEs can refactor class names specified using the ## Initializers An initializer is any callable or any class that implements the interface -`Zend\ServiceManager\Initializer\InitializerInterface`. Initializers are +`Laminas\ServiceManager\Initializer\InitializerInterface`. Initializers are executed for each service the first time they are created, and can be used to inject additional dependencies. @@ -269,7 +269,7 @@ For instance, if we'd want to automatically inject the dependency ```php use Interop\Container\ContainerInterface; use stdClass; -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\ServiceManager; $serviceManager = new ServiceManager([ 'initializers' => [ @@ -284,7 +284,7 @@ $serviceManager = new ServiceManager([ ``` Alternately, you can create a class that implements -`Zend\ServiceManager\Initializer\InitializerInterface`, and pass it to the +`Laminas\ServiceManager\Initializer\InitializerInterface`, and pass it to the `initializers` array: ```php @@ -305,7 +305,7 @@ class MyInitializer implements InitializerInterface use Interop\Container\ContainerInterface; use stdClass; -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\ServiceManager; $serviceManager = new ServiceManager([ 'initializers' => [ @@ -498,7 +498,7 @@ following methods: `$class`; if the latter is not provided, `$name` is used for both sides of the map. - `addAbstractFactory($factory)`, where `$factory` can be either a - `Zend\ServiceManager\Factory\AbstractFactoryInterface` instance or the name + `Laminas\ServiceManager\Factory\AbstractFactoryInterface` instance or the name of a class implementing the interface. - `addDelegator($name, $factory)`, where `$factory` can be either a callable delegator factory, or the name of a delegator factory class to use. @@ -511,7 +511,7 @@ following methods: As examples: ```php -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\ServiceManager; $serviceManager = new ServiceManager([ 'factories' => [ diff --git a/doc/book/console-tools.md b/doc/book/console-tools.md index 549d1545..d54de33a 100644 --- a/doc/book/console-tools.md +++ b/doc/book/console-tools.md @@ -1,6 +1,6 @@ # Console Tools -Starting in 3.2.0, zend-servicemanager began shipping with console tools. This +Starting in 3.2.0, laminas-servicemanager began shipping with console tools. This document details each. ## generate-deps-for-config-factory @@ -70,5 +70,5 @@ $ ./vendor/bin/generate-factory-for-class \ > "Application\\Model\\AlbumModel" > ./module/Application/src/Model/AlbumModelFactory.php ``` -The class generated implements `Zend\ServiceManager\Factory\FactoryInterface`, +The class generated implements `Laminas\ServiceManager\Factory\FactoryInterface`, and is generated within the same namespace as the originating class. diff --git a/doc/book/cookbook/factories-vs-abstract-factories.md b/doc/book/cookbook/factories-vs-abstract-factories.md index 65c80191..671101fb 100644 --- a/doc/book/cookbook/factories-vs-abstract-factories.md +++ b/doc/book/cookbook/factories-vs-abstract-factories.md @@ -1,7 +1,7 @@ # When To Use Factories vs Abstract Factories -Starting with version 3, `Zend\ServiceManager\Factory\AbstractFactoryInterface` -extends `Zend\ServiceManager\Factory\FactoryInterface`, meaning they may be used +Starting with version 3, `Laminas\ServiceManager\Factory\AbstractFactoryInterface` +extends `Laminas\ServiceManager\Factory\FactoryInterface`, meaning they may be used as either an abstract factory, or mapped to a specific service name as its factory. @@ -37,7 +37,7 @@ regularly, this boiler-plate code can be a nuisance. In such situations, one or more abstract factories — such as the [ConfigAbstractFactory](../config-abstract-factory.md), the [ReflectionBasedAbstractFactory](../reflection-abstract-factory.md), or the -[zend-mvc LazyControllerAbstractFactory](https://docs.zendframework.com/zend-mvc/cookbook/automating-controller-factories/) +[laminas-mvc LazyControllerAbstractFactory](https://docs.laminas.dev/laminas-mvc/cookbook/automating-controller-factories/) — that can handle the bulk of your needs are often worthwhile, saving you time and effort as you code. diff --git a/doc/book/delegators.md b/doc/book/delegators.md index 2cb779ae..09423fb5 100644 --- a/doc/book/delegators.md +++ b/doc/book/delegators.md @@ -1,8 +1,8 @@ # Delegators -`Zend\ServiceManager` can instantiate [delegators](http://en.wikipedia.org/wiki/Delegation_pattern) +`Laminas\ServiceManager` can instantiate [delegators](http://en.wikipedia.org/wiki/Delegation_pattern) of requested services, decorating them as specified in a delegate factory -implementing the [delegator factory interface](https://github.com/zendframework/zend-servicemanager/tree/master/src/Factory/DelegatorFactoryInterface.php). +implementing the [delegator factory interface](https://github.com/laminas/laminas-servicemanager/tree/master/src/Factory/DelegatorFactoryInterface.php). The delegate pattern is useful in cases when you want to wrap a real service in a [decorator](http://en.wikipedia.org/wiki/Decorator_pattern), or generally @@ -57,7 +57,7 @@ class Buzzer The delegator class `BuzzerDelegator` has the following structure: ```php -use Zend\EventManager\EventManagerInterface; +use Laminas\EventManager\EventManagerInterface; class BuzzerDelegator extends Buzzer { @@ -83,7 +83,7 @@ To use the `BuzzerDelegator`, you can run the following code: ```php $wrappedBuzzer = new Buzzer(); -$eventManager = new Zend\EventManager\EventManager(); +$eventManager = new Laminas\EventManager\EventManager(); $eventManager->attach('buzz', function () { echo "Stare at the art!\n"; }); @@ -107,7 +107,7 @@ following: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\Factory\DelegatorFactoryInterface; +use Laminas\ServiceManager\Factory\DelegatorFactoryInterface; class BuzzerDelegatorFactory implements DelegatorFactoryInterface { @@ -127,10 +127,10 @@ You can then instruct the service manager to handle the service `buzzer` as a delegate: ```php -use Zend\ServiceManager\Factory\InvokableClass; -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\Factory\InvokableClass; +use Laminas\ServiceManager\ServiceManager; -$serviceManager = new Zend\ServiceManager\ServiceManager([ +$serviceManager = new Laminas\ServiceManager\ServiceManager([ 'factories' => [ Buzzer::class => InvokableClass::class, ], diff --git a/doc/book/index.html b/doc/book/index.html index 42efe70a..f51e7303 100644 --- a/doc/book/index.html +++ b/doc/book/index.html @@ -1,10 +1,10 @@
-

zend-servicemanager

+

laminas-servicemanager

Factory-Driven Dependency Injection Container

-
$ composer require zendframework/zend-servicemanager
+
$ composer require laminas/laminas-servicemanager
diff --git a/doc/book/lazy-services.md b/doc/book/lazy-services.md index 5cdb1676..0e4f33c9 100644 --- a/doc/book/lazy-services.md +++ b/doc/book/lazy-services.md @@ -1,6 +1,6 @@ # Lazy Services -`Zend\ServiceManager` can use [delegator factories](delegators.md) to generate +`Laminas\ServiceManager` can use [delegator factories](delegators.md) to generate "lazy" references to your services. Lazy services are [proxies](http://en.wikipedia.org/wiki/Proxy_pattern) that @@ -24,7 +24,7 @@ object is really needed. ## Setup -`Zend\ServiceManager\Proxy\LazyServiceFactory` is a [delegator factory](delegators.md) +`Laminas\ServiceManager\Proxy\LazyServiceFactory` is a [delegator factory](delegators.md) capable of generating lazy loading proxies for your services. The lazy service facilities depend on [ProxyManager](https://github.com/Ocramius/ProxyManager); @@ -63,11 +63,11 @@ instead of real services: ```php use MyApp\Buzzer; -use Zend\ServiceManager\Factory\InvokableFactory; -use Zend\ServiceManager\Proxy\LazyServiceFactory; -use Zend\ServiceManager\ServiceManager; +use Laminas\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\Proxy\LazyServiceFactory; +use Laminas\ServiceManager\ServiceManager; -$serviceManager = new \Zend\ServiceManager\ServiceManager([ +$serviceManager = new \Laminas\ServiceManager\ServiceManager([ 'factories' => [ Buzzer::class => InvokableFactory::class, ], @@ -115,7 +115,7 @@ echo $buzzer->buzz(); ## Configuration -This is the config structure expected by `Zend\ServiceManager\Proxy\LazyServiceFactory`, +This is the config structure expected by `Laminas\ServiceManager\Proxy\LazyServiceFactory`, in the `lazy_services` key passed in the service manager configuration: ```php diff --git a/doc/book/migration.md b/doc/book/migration.md index 0b95662c..37950abf 100644 --- a/doc/book/migration.md +++ b/doc/book/migration.md @@ -1,6 +1,6 @@ # Migration Guide -The Service Manager was first introduced for Zend Framework 2.0.0. Its API +The Service Manager was first introduced for Laminas.0.0. Its API remained the same throughout that version. Version 3 is the first new major release of the Service Manager, and contains a @@ -94,22 +94,22 @@ the format listed above, for passing to either the constructor or the ### Config class -`Zend\ServiceManager\Config` has been updated to follow the changes to the +`Laminas\ServiceManager\Config` has been updated to follow the changes to the `ConfigInterface` and `ServiceManager`. This essentially means that it removes the various getter methods, and adds the `toArray()` method. ## Invokables *Invokables no longer exist,* at least, not identically to how they existed in -ZF2. +Laminas. Internally, `ServiceManager` now does the following for `invokables` entries: - If the name and value match, it creates a `factories` entry mapping the - service name to `Zend\ServiceManager\Factory\InvokableFactory`. + service name to `Laminas\ServiceManager\Factory\InvokableFactory`. - If the name and value *do not* match, it creates an `aliases` entry mapping the service name to the class name, *and* a `factories` entry mapping the class - name to `Zend\ServiceManager\Factory\InvokableFactory`. + name to `Laminas\ServiceManager\Factory\InvokableFactory`. This means that you can use your existing `invokables` configuration from version 2 in version 3. However, we recommend starting to update your @@ -124,7 +124,7 @@ if needed). > `$invokableClasses` will need to become `$factories` entries, and you will > potentially need to add `$aliases` entries. > -> As an example, consider the following, from zend-math v2.x: +> As an example, consider the following, from laminas-math v2.x: > > ```php > class AdapterPluginManager extends AbstractPluginManager @@ -140,7 +140,7 @@ if needed). > now becomes: > > ```php -> use Zend\ServiceManager\Factory\InvokableFactory; +> use Laminas\ServiceManager\Factory\InvokableFactory; > > class AdapterPluginManager extends AbstractPluginManager > { @@ -170,7 +170,7 @@ steps: As an example: ```php -use Zend\ServiceManager\Proxy\LazyServiceFactoryFactory; +use Laminas\ServiceManager\Proxy\LazyServiceFactoryFactory; $config = [ 'lazy_services' => [ @@ -215,8 +215,8 @@ lazy services, the following changes were made for v3: The above example becomes the following in v3: ```php -use Zend\ServiceManager\Factory\InvokableFactory; -use Zend\ServiceManager\Proxy\LazyServiceFactory; +use Laminas\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\Proxy\LazyServiceFactory; return [ 'factories' => [ @@ -266,7 +266,7 @@ service, and to allow using the provided `$options` when creating the instance. ## ServiceManager API Changes -`Zend\ServiceManager\ServiceManager` remains the primary interface with which +`Laminas\ServiceManager\ServiceManager` remains the primary interface with which developers will interact. It has the following changes in v3: - It adds a new method, `configure()`, which allows configuring all instance @@ -275,7 +275,7 @@ developers will interact. It has the following changes in v3: - Peering capabilities were removed. - Exceptions are *always* thrown when service instance creation fails or produces an error; you can no longer disable this. -- Configuration no longer requires a `Zend\ServiceManager\Config` instance. +- Configuration no longer requires a `Laminas\ServiceManager\Config` instance. `Config` can be used, but is not needed. - It adds a new method, `build()`, for creating discrete service instances. @@ -293,7 +293,7 @@ developers will interact. It has the following changes in v3: ### Constructor The constructor now accepts an array of service configuration, not a -`Zend\ServiceManager\Config` instance. +`Laminas\ServiceManager\Config` instance. ### Use `build()` for discrete instances @@ -309,7 +309,7 @@ information on in order to create discrete plugin instances with specific state. As examples: ```php -use Zend\Validator\Between; +use Laminas\Validator\Between; $between = $container->build(Between::class, [ 'min' => 5, @@ -330,7 +330,7 @@ configuration. ## Factories Internally, the `ServiceManager` now only uses the new factory interfaces -defined in the `Zend\ServiceManager\Factory` namespace. These *replace* the +defined in the `Laminas\ServiceManager\Factory` namespace. These *replace* the interfaces defined in version 2, and define completely new signatures. For migration purposes, all original interfaces were retained, and now inherit @@ -343,9 +343,9 @@ those defined in version 3.) | Version 2 Interface | Version 3 Interface | | :-------------------------------------------------------: | :-------------------------------------------------------: | -| `Zend\ServiceManager\AbstractFactoryInterface` | `Zend\ServiceManager\Factory\AbstractFactoryInterface` | -| `Zend\ServiceManager\DelegatorFactoryInterface` | `Zend\ServiceManager\Factory\DelegatorFactoryInterface` | -| `Zend\ServiceManager\FactoryInterface` | `Zend\ServiceManager\Factory\FactoryInterface` | +| `Laminas\ServiceManager\AbstractFactoryInterface` | `Laminas\ServiceManager\Factory\AbstractFactoryInterface` | +| `Laminas\ServiceManager\DelegatorFactoryInterface` | `Laminas\ServiceManager\Factory\DelegatorFactoryInterface` | +| `Laminas\ServiceManager\FactoryInterface` | `Laminas\ServiceManager\Factory\FactoryInterface` | The version 2 interfaces now extend those in version 3, but are marked **deprecated**. You can continue to use them, but will be required to update @@ -414,8 +414,8 @@ To prepare your version 2 implementation to work upon upgrade to version 3: As an example, given the following implementation from version 2: ```php -use Zend\ServiceManager\AbstractFactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\AbstractFactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; class LenientAbstractFactory implements AbstractFactoryInterface { @@ -437,8 +437,8 @@ them, and update the existing methods to proxy to the new methods: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\AbstractFactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\AbstractFactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; class LenientAbstractFactory implements AbstractFactoryInterface { @@ -475,7 +475,7 @@ From our example above, we would update the class to read as follows: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\Factory\AbstractFactoryInterface; // <-- note the change! +use Laminas\ServiceManager\Factory\AbstractFactoryInterface; // <-- note the change! class LenientAbstractFactory implements AbstractFactoryInterface { @@ -544,8 +544,8 @@ steps: Consider the following delegator factory that works for version 2: ```php -use Zend\ServiceManager\DelegatorFactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\DelegatorFactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; class ObserverAttachmentDelegator implements DelegatorFactoryInterface { @@ -563,8 +563,8 @@ version 3, and modify `createDelegatorWithName()` to proxy to it: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\DelegatorFactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\DelegatorFactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; class ObserverAttachmentDelegator implements DelegatorFactoryInterface { @@ -592,7 +592,7 @@ From our example above, we would update the class to read as follows: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\Factory\DelegatorFactoryInterface; // <-- note the change! +use Laminas\ServiceManager\Factory\DelegatorFactoryInterface; // <-- note the change! class ObserverAttachmentDelegator implements DelegatorFactoryInterface { @@ -658,8 +658,8 @@ To prepare your existing factories for version 3, take the following steps: Consider the following factory that works for version 2: ```php -use Zend\ServiceManager\FactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; class FooFactory implements FactoryInterface { @@ -675,8 +675,8 @@ version 3, and modify `createService()` to proxy to it: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\FactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; class FooFactory implements FactoryInterface { @@ -707,7 +707,7 @@ From our example above, we would update the class to read as follows: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\Factory\FactoryInterface; // <-- note the change! +use Laminas\ServiceManager\Factory\FactoryInterface; // <-- note the change! class FooFactory implements FactoryInterface { @@ -721,7 +721,7 @@ class FooFactory implements FactoryInterface > #### Many factories already work with v3! > > Within the skeleton application, tutorial, and even in commonly shipped -> modules such as those in Apigility, we have typically suggested building your +> modules such as those in Laminas API Tools, we have typically suggested building your > factories as invokable classes. If you were doing this already, your factories > will already work with version 3! @@ -735,7 +735,7 @@ class FooFactory implements FactoryInterface ### New InvokableFactory Class -`Zend\ServiceManager\Factory\InvokableFactory` is a new `FactoryInterface` +`Laminas\ServiceManager\Factory\InvokableFactory` is a new `FactoryInterface` implementation that provides the capabilities of the "invokable classes" present in version 2. It essentially instantiates and returns the requested class name; if `$options` is non-empty, it passes them directly to the constructor. @@ -760,8 +760,8 @@ the one defined in version 3.) The following changes were made to initializers: -- `Zend\ServiceManager\InitializerInterface` was renamed to - `Zend\ServiceManager\Initializer\InitializerInterface`. +- `Laminas\ServiceManager\InitializerInterface` was renamed to + `Laminas\ServiceManager\Initializer\InitializerInterface`. - The interface itself has a new signature. The previous signature was: @@ -788,8 +788,8 @@ To prepare your existing initializers for version 3, take the following steps: As an example, consider this initializer for version 2: ```php -use Zend\ServiceManager\InitializerInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\InitializerInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; class FooInitializer implements InitializerInterface { @@ -809,8 +809,8 @@ version 3, and modify `initialize()` to proxy to it: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\InitializerInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\InitializerInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; class FooInitializer implements InitializerInterface { @@ -840,7 +840,7 @@ From our example above, we would update the class to read as follows: ```php use Interop\Container\ContainerInterface; -use Zend\ServiceManager\Initializer\InitializerInterface; // <-- note the change! +use Laminas\ServiceManager\Initializer\InitializerInterface; // <-- note the change! class FooInitializer implements InitializerInterface { @@ -912,16 +912,16 @@ manager, if composed, in order to resolve application-level dependencies. In version 3, we define the following: -- `Zend\ServiceManager\PluginManagerInterface`, which provides the public API +- `Laminas\ServiceManager\PluginManagerInterface`, which provides the public API differences from the `ServiceLocatorInterface`. -- `Zend\ServiceManager\AbstractPluginManager`, which gives the basic +- `Laminas\ServiceManager\AbstractPluginManager`, which gives the basic capabilities for plugin managers. The class now has a (semi) *required* dependency on the application-level service manager instance, which is passed to all factories, abstract factories, etc. (More on this below.) ### PluginManagerInterface -`Zend\ServiceManager\PluginInterface` is a new interface for version 3, +`Laminas\ServiceManager\PluginInterface` is a new interface for version 3, extending `ServiceLocatorInterface` and adding one method: ```php @@ -1127,7 +1127,7 @@ Let's consider the following plugin manager geared towards version 2: ```php use RuntimeException; -use Zend\ServiceManager\AbstractPluginManager; +use Laminas\ServiceManager\AbstractPluginManager; class ObserverPluginManager extends AbstractPluginManager { @@ -1165,9 +1165,9 @@ Doing so, we get the following result: namespace MyNamespace; use RuntimeException; -use Zend\ServiceManager\AbstractPluginManager; -use Zend\ServiceManager\Exception\InvalidServiceException; -use Zend\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\AbstractPluginManager; +use Laminas\ServiceManager\Exception\InvalidServiceException; +use Laminas\ServiceManager\Factory\InvokableFactory; class ObserverPluginManager extends AbstractPluginManager { @@ -1235,7 +1235,7 @@ The above will now work in both version 2 and version 3. ### Migration testing To test your changes, create a new `MigrationTest` case that uses -`Zend\ServiceManager\Test\CommonPluginManagerTrait`. Override +`Laminas\ServiceManager\Test\CommonPluginManagerTrait`. Override `getPluginManager()` to return an instance of your plugin manager, and override `getV2InvalidPluginException()` to return the classname of the exception your `validatePlugin()` method throws: @@ -1245,8 +1245,8 @@ use MyNamespace\ObserverInterface; use MyNamespace\ObserverPluginManager; use MyNamespace\Exception\RuntimeException; use PHPUnit_Framework_TestCase as TestCase; -use Zend\ServiceManager\ServiceManager; -use Zend\ServiceManager\Test\CommonPluginManagerTrait; +use Laminas\ServiceManager\ServiceManager; +use Laminas\ServiceManager\Test\CommonPluginManagerTrait; class MigrationTest extends TestCase { @@ -1291,8 +1291,8 @@ After you migrate to version 3, you can clean up your plugin manager: Performing these steps on the above, we get: ```php -use Zend\ServiceManager\AbstractPluginManager; -use Zend\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\AbstractPluginManager; +use Laminas\ServiceManager\Factory\InvokableFactory; class ObserverPluginManager extends AbstractPluginManager { @@ -1314,10 +1314,10 @@ class ObserverPluginManager extends AbstractPluginManager ## DI Namespace -**The `Zend\ServiceManager\Di` namespace has been removed.** +**The `Laminas\ServiceManager\Di` namespace has been removed.** -The `Zend\Di` component is not actively maintained, and has been largely -deprecated during the ZF2 lifecycle in favor of the Service Manager. Its usage +The `Laminas\Di` component is not actively maintained, and has been largely +deprecated during the Laminas lifecycle in favor of the Service Manager. Its usage as an abstract factory is problematic and error prone when used in conjunction with the Service Manager; as such, we've removed it for the initial v3 release. @@ -1327,16 +1327,16 @@ We may re-introduce it via a separate component in the future. The following interfaces, traits, and classes were *removed*: -- `Zend\ServiceManager\MutableCreationOptionsInterface`; this was previously +- `Laminas\ServiceManager\MutableCreationOptionsInterface`; this was previously used by the `AbstractPluginManager`, and is no longer required as we ship a separate `PluginManagerInterface`, and because the functionality is encompassed by the `build()` method. -- `Zend\ServiceManager\MutableCreationOptionsTrait` -- `Zend\ServiceManager\Proxy\LazyServiceFactoryFactory`; its capabilities were +- `Laminas\ServiceManager\MutableCreationOptionsTrait` +- `Laminas\ServiceManager\Proxy\LazyServiceFactoryFactory`; its capabilities were moved directly into the `ServiceManager`. -- `Zend\ServiceManager\ServiceLocatorAwareInterface` -- `Zend\ServiceManager\ServiceLocatorAwareTrait` -- `Zend\ServiceManager\ServiceManagerAwareInterface` +- `Laminas\ServiceManager\ServiceLocatorAwareInterface` +- `Laminas\ServiceManager\ServiceLocatorAwareTrait` +- `Laminas\ServiceManager\ServiceManagerAwareInterface` The `ServiceLocatorAware` and `ServiceManagerAware` interfaces and traits were too often abused under v2, and represent the antithesis of the purpose of the @@ -1345,11 +1345,11 @@ container should never be composed by objects. The following classes and interfaces have changes: -- `Zend\ServiceManager\Proxy\LazyServiceFactory` is now marked `final`, and - implements `Zend\ServiceManager\Proxy\DelegatorFactoryInterface`. Its +- `Laminas\ServiceManager\Proxy\LazyServiceFactory` is now marked `final`, and + implements `Laminas\ServiceManager\Proxy\DelegatorFactoryInterface`. Its dependencies and capabilities remain the same. -- `Zend\ServiceManager\ConfigInterface` now is expected to *return* the modified +- `Laminas\ServiceManager\ConfigInterface` now is expected to *return* the modified `ServiceManager` instance. -- `Zend\ServiceManager\Config` was updated to follow the changes to +- `Laminas\ServiceManager\Config` was updated to follow the changes to `ConfigInterface` and `ServiceManager`, and now returns the updated `ServiceManager` instance from `configureServiceManager()`. diff --git a/doc/book/plugin-managers.md b/doc/book/plugin-managers.md index 4ec3753d..68a80e1e 100644 --- a/doc/book/plugin-managers.md +++ b/doc/book/plugin-managers.md @@ -7,14 +7,14 @@ Because a plugin manager extends a service manager, it works the same and can be configured similarly. It provides a separation of concerns (it will be used in specific contexts), and provides additional instance validation. -Zend Framework components extensively use plugin managers to create services +Laminas components extensively use plugin managers to create services that share common functionalities. For instance, all validator services are specified inside a specialized `ValidatorPluginManager`. ## Creating a plugin manager To create a plugin manager, you first need to create a new class that extends -`Zend\ServiceManager\AbstractPluginManager`: +`Laminas\ServiceManager\AbstractPluginManager`: ```php class ValidatorPluginManager extends AbstractPluginManager @@ -25,7 +25,7 @@ class ValidatorPluginManager extends AbstractPluginManager The `$instanceOf` variable specifies a class/interface type that all instances retrieved from the plugin manager must fulfill. If an instance created by the -plugin manager does not match, a `Zend\ServiceManager\Exception\InvalidServiceException` +plugin manager does not match, a `Laminas\ServiceManager\Exception\InvalidServiceException` exception will be thrown. Most of the time, this shortcut is enough. However if you have more complex diff --git a/doc/book/quick-start.md b/doc/book/quick-start.md index 95e157c2..c9246dad 100644 --- a/doc/book/quick-start.md +++ b/doc/book/quick-start.md @@ -9,13 +9,13 @@ interfaces, providing interoperability with other implementations. The following is a "quick start" tutorial intended to get you up and running with the most common features of the Service manager. -## 1. Install Zend Service Manager +## 1. Install Laminas Service Manager If you haven't already, [install Composer](https://getcomposer.org). Once you have, you can install the service manager: ```bash -$ composer require zendframework/zend-servicemanager +$ composer require laminas/laminas-servicemanager ``` ## 2. Configuring a service manager @@ -24,8 +24,8 @@ You can now create and configure a service manager. The service manager constructor accepts a simple array: ```php -use Zend\ServiceManager\ServiceManager; -use Zend\ServiceManager\Factory\InvokableFactory; +use Laminas\ServiceManager\ServiceManager; +use Laminas\ServiceManager\Factory\InvokableFactory; use stdClass; $serviceManager = new ServiceManager([ diff --git a/doc/book/reflection-abstract-factory.md b/doc/book/reflection-abstract-factory.md index a63def4d..ffae902f 100644 --- a/doc/book/reflection-abstract-factory.md +++ b/doc/book/reflection-abstract-factory.md @@ -6,13 +6,13 @@ Writing a factory class for each and every service that has dependencies can be tedious, particularly in early development as you are still sorting out dependencies. -zend-servicemanager ships with `Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory`, +laminas-servicemanager ships with `Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory`, which provides a reflection-based approach to instantiation, resolving constructor dependencies to the relevant services. The factory may be used as either an abstract factory, or mapped to specific service names as a factory: ```php -use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory; +use Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory; return [ /* ... */ @@ -51,19 +51,19 @@ to do so. ## Handling well-known services -Some services provided by Zend Framework components do not have +Some services provided by Laminas components do not have entries based on their class name (for historical reasons). As examples: -- `Zend\Console\Adapter\AdapterInterface` maps to the service name `ConsoleAdapter`, -- `Zend\Filter\FilterPluginManager` maps to the service name `FilterManager`, -- `Zend\Hydrator\HydratorPluginManager` maps to the service name `HydratorManager`, -- `Zend\InputFilter\InputFilterPluginManager` maps to the service name `InputFilterManager`, -- `Zend\Log\FilterPluginManager` maps to the service name `LogFilterManager`, -- `Zend\Log\FormatterPluginManager` maps to the service name `LogFormatterManager`, -- `Zend\Log\ProcessorPluginManager` maps to the service name `LogProcessorManager`, -- `Zend\Log\WriterPluginManager` maps to the service name `LogWriterManager`, -- `Zend\Serializer\AdapterPluginManager` maps to the service name `SerializerAdapterManager`, -- `Zend\Validator\ValidatorPluginManager` maps to the service name `ValidatorManager`, +- `Laminas\Console\Adapter\AdapterInterface` maps to the service name `ConsoleAdapter`, +- `Laminas\Filter\FilterPluginManager` maps to the service name `FilterManager`, +- `Laminas\Hydrator\HydratorPluginManager` maps to the service name `HydratorManager`, +- `Laminas\InputFilter\InputFilterPluginManager` maps to the service name `InputFilterManager`, +- `Laminas\Log\FilterPluginManager` maps to the service name `LogFilterManager`, +- `Laminas\Log\FormatterPluginManager` maps to the service name `LogFormatterManager`, +- `Laminas\Log\ProcessorPluginManager` maps to the service name `LogProcessorManager`, +- `Laminas\Log\WriterPluginManager` maps to the service name `LogWriterManager`, +- `Laminas\Serializer\AdapterPluginManager` maps to the service name `SerializerAdapterManager`, +- `Laminas\Validator\ValidatorPluginManager` maps to the service name `ValidatorManager`, To allow the `ReflectionBasedAbstractFactory` to find these, you have two options. @@ -72,16 +72,16 @@ The first is to pass an array of mappings via the constructor: ```php $reflectionFactory = new ReflectionBasedAbstractFactory([ - \Zend\Console\Adapter\AdapterInterface::class => 'ConsoleAdapter', - \Zend\Filter\FilterPluginManager::class => 'FilterManager', - \Zend\Hydrator\HydratorPluginManager::class => 'HydratorManager', - \Zend\InputFilter\InputFilterPluginManager::class => 'InputFilterManager', - \Zend\Log\FilterPluginManager::class => 'LogFilterManager', - \Zend\Log\FormatterPluginManager::class => 'LogFormatterManager', - \Zend\Log\ProcessorPluginManager::class => 'LogProcessorManager', - \Zend\Log\WriterPluginManager::class => 'LogWriterManager', - \Zend\Serializer\AdapterPluginManager::class => 'SerializerAdapterManager', - \Zend\Validator\ValidatorPluginManager::class => 'ValidatorManager', + \Laminas\Console\Adapter\AdapterInterface::class => 'ConsoleAdapter', + \Laminas\Filter\FilterPluginManager::class => 'FilterManager', + \Laminas\Hydrator\HydratorPluginManager::class => 'HydratorManager', + \Laminas\InputFilter\InputFilterPluginManager::class => 'InputFilterManager', + \Laminas\Log\FilterPluginManager::class => 'LogFilterManager', + \Laminas\Log\FormatterPluginManager::class => 'LogFormatterManager', + \Laminas\Log\ProcessorPluginManager::class => 'LogProcessorManager', + \Laminas\Log\WriterPluginManager::class => 'LogWriterManager', + \Laminas\Serializer\AdapterPluginManager::class => 'SerializerAdapterManager', + \Laminas\Validator\ValidatorPluginManager::class => 'ValidatorManager', ]); ``` @@ -89,13 +89,13 @@ This can be done either in your configuration file (which could be problematic when considering serialization for caching), or during an early phase of application bootstrapping. -For instance, with zend-mvc, this might be in your `Application` module's +For instance, with laminas-mvc, this might be in your `Application` module's bootstrap listener: ```php namespace Application -use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory; +use Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory; class Module { @@ -111,7 +111,7 @@ class Module } ``` -For Expressive, it could be part of your `config/container.php` definition: +For Mezzio, it could be part of your `config/container.php` definition: ```php $container = new ServiceManager(); @@ -128,21 +128,21 @@ The second approach is to extend the class, and define the map in the ```php namespace Application; -use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory; +use Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory; class ReflectionAbstractFactory extends ReflectionBasedAbstractFactory { protected $aliases = [ - \Zend\Console\Adapter\AdapterInterface::class => 'ConsoleAdapter', - \Zend\Filter\FilterPluginManager::class => 'FilterManager', - \Zend\Hydrator\HydratorPluginManager::class => 'HydratorManager', - \Zend\InputFilter\InputFilterPluginManager::class => 'InputFilterManager', - \Zend\Log\FilterPluginManager::class => 'LogFilterManager', - \Zend\Log\FormatterPluginManager::class => 'LogFormatterManager', - \Zend\Log\ProcessorPluginManager::class => 'LogProcessorManager', - \Zend\Log\WriterPluginManager::class => 'LogWriterManager', - \Zend\Serializer\AdapterPluginManager::class => 'SerializerAdapterManager', - \Zend\Validator\ValidatorPluginManager::class => 'ValidatorManager', + \Laminas\Console\Adapter\AdapterInterface::class => 'ConsoleAdapter', + \Laminas\Filter\FilterPluginManager::class => 'FilterManager', + \Laminas\Hydrator\HydratorPluginManager::class => 'HydratorManager', + \Laminas\InputFilter\InputFilterPluginManager::class => 'InputFilterManager', + \Laminas\Log\FilterPluginManager::class => 'LogFilterManager', + \Laminas\Log\FormatterPluginManager::class => 'LogFormatterManager', + \Laminas\Log\ProcessorPluginManager::class => 'LogProcessorManager', + \Laminas\Log\WriterPluginManager::class => 'LogWriterManager', + \Laminas\Serializer\AdapterPluginManager::class => 'SerializerAdapterManager', + \Laminas\Validator\ValidatorPluginManager::class => 'ValidatorManager', ]; } ``` @@ -163,4 +163,4 @@ which gives slightly more flexibility in terms of mapping dependencies: ## References -This feature was inspired by [a blog post by Alexandre Lemaire](http://circlical.com/blog/2016/3/9/preparing-for-zend-f). +This feature was inspired by [a blog post by Alexandre Lemaire](http://circlical.com/blog/2016/3/9/preparing-for-laminas-f). diff --git a/mkdocs.yml b/mkdocs.yml index d9bdcecb..2ed05820 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,6 @@ docs_dir: doc/book site_dir: doc/html -pages: +nav: - index.md - 'Quick Start': quick-start.md - Reference: @@ -14,7 +14,6 @@ pages: - Cookbook: - 'Factories vs Abstract Factories': cookbook/factories-vs-abstract-factories.md - 'Migration Guide': migration.md -site_name: zend-servicemanager -site_description: 'zend-servicemanager: factory-driven dependency injection container' -repo_url: 'https://github.com/zendframework/zend-servicemanager' -copyright: 'Copyright (c) 2016 Zend Technologies USA Inc.' +site_name: laminas-servicemanager +site_description: 'laminas-servicemanager: factory-driven dependency injection container' +repo_url: 'https://github.com/laminas/laminas-servicemanager' diff --git a/phpcs.xml b/phpcs.xml index 263492ed..854e3d69 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,6 +1,6 @@ - - + + bin diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1c78e74d..e614d472 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,7 +4,7 @@ bootstrap="./vendor/autoload.php" colors="true"> - + ./test/ diff --git a/src/AbstractFactory/ConfigAbstractFactory.php b/src/AbstractFactory/ConfigAbstractFactory.php index 27882ccb..237d7365 100644 --- a/src/AbstractFactory/ConfigAbstractFactory.php +++ b/src/AbstractFactory/ConfigAbstractFactory.php @@ -1,15 +1,16 @@ * [ - * \Zend\Filter\FilterPluginManager::class => 'FilterManager', - * \Zend\Validator\ValidatorPluginManager::class => 'ValidatorManager', + * \Laminas\Filter\FilterPluginManager::class => 'FilterManager', + * \Laminas\Validator\ValidatorPluginManager::class => 'ValidatorManager', * ] * * diff --git a/src/AbstractFactoryInterface.php b/src/AbstractFactoryInterface.php index b367f72b..c378e720 100644 --- a/src/AbstractFactoryInterface.php +++ b/src/AbstractFactoryInterface.php @@ -1,16 +1,17 @@ container->has(TestAsset\SampleInterface::class)->willReturn(false); + $this->container->has(\ZendTest\ServiceManager\AbstractFactory\TestAsset\SampleInterface::class)->willReturn(false); $this->container->has('config')->willReturn(false); $factory = new ReflectionBasedAbstractFactory(); $this->expectException(ServiceNotFoundException::class); diff --git a/test/AbstractFactory/TestAsset/ClassAcceptingConfigToConstructor.php b/test/AbstractFactory/TestAsset/ClassAcceptingConfigToConstructor.php index f4b1b8cf..1830717f 100644 --- a/test/AbstractFactory/TestAsset/ClassAcceptingConfigToConstructor.php +++ b/test/AbstractFactory/TestAsset/ClassAcceptingConfigToConstructor.php @@ -1,11 +1,12 @@ proxyDir = sys_get_temp_dir() . '/zend-servicemanager-proxy'; + $this->proxyDir = sys_get_temp_dir() . '/laminas-servicemanager-proxy'; if (! is_dir($this->proxyDir)) { mkdir($this->proxyDir); } @@ -92,7 +93,7 @@ public function assertProxyFileWritten($message = '') } /** - * @covers \Zend\ServiceManager\ServiceManager::createLazyServiceDelegatorFactory + * @covers \Laminas\ServiceManager\ServiceManager::createLazyServiceDelegatorFactory */ public function testCanUseLazyServiceFactoryFactoryToCreateLazyServiceFactoryToActAsDelegatorToCreateLazyService() { @@ -146,7 +147,7 @@ public function testCanUseLazyServiceFactoryFactoryToCreateLazyServiceFactoryToA } /** - * @covers \Zend\ServiceManager\ServiceManager::createLazyServiceDelegatorFactory + * @covers \Laminas\ServiceManager\ServiceManager::createLazyServiceDelegatorFactory */ public function testMissingClassMapRaisesExceptionOnAttemptToRetrieveLazyService() { @@ -168,7 +169,7 @@ public function testMissingClassMapRaisesExceptionOnAttemptToRetrieveLazyService } /** - * @covers \Zend\ServiceManager\ServiceManager::createLazyServiceDelegatorFactory + * @covers \Laminas\ServiceManager\ServiceManager::createLazyServiceDelegatorFactory */ public function testWillNotGenerateProxyClassFilesByDefault() { diff --git a/test/Proxy/LazyServiceFactoryTest.php b/test/Proxy/LazyServiceFactoryTest.php index 7f430865..4d3d4151 100644 --- a/test/Proxy/LazyServiceFactoryTest.php +++ b/test/Proxy/LazyServiceFactoryTest.php @@ -1,24 +1,25 @@ InvokableObject::class, + + // Legacy Zend Framework aliases + \ZendTest\ServiceManager\TestAsset\InvokableObject::class => InvokableObject::class, + + // v2 normalized FQCNs + 'zendtestservicemanagertestassetinvokableobject' => InvokableObject::class, ]; protected $factories = [ InvokableObject::class => InvokableFactory::class, // Legacy (v2) due to alias resolution - 'zendtestservicemanagertestassetinvokableobject' => InvokableFactory::class, + 'laminastestservicemanagertestassetinvokableobject' => InvokableFactory::class, ]; protected $instanceOf = InvokableObject::class; diff --git a/test/TestAsset/config/invalid.config.php b/test/TestAsset/config/invalid.config.php index 4a2ff946..81121182 100644 --- a/test/TestAsset/config/invalid.config.php +++ b/test/TestAsset/config/invalid.config.php @@ -1,8 +1,9 @@ get(\ZendTest\ServiceManager\TestAsset\SimpleDependencyObject::class), - $container->get(\ZendTest\ServiceManager\TestAsset\SecondComplexDependencyObject::class) + $container->get(\LaminasTest\ServiceManager\TestAsset\SimpleDependencyObject::class), + $container->get(\LaminasTest\ServiceManager\TestAsset\SecondComplexDependencyObject::class) ); } } diff --git a/test/TestAsset/factories/InvokableObject.php b/test/TestAsset/factories/InvokableObject.php index 5e3ea439..ce2eaf66 100644 --- a/test/TestAsset/factories/InvokableObject.php +++ b/test/TestAsset/factories/InvokableObject.php @@ -1,10 +1,10 @@ get(\ZendTest\ServiceManager\TestAsset\InvokableObject::class)); + return new SimpleDependencyObject($container->get(\LaminasTest\ServiceManager\TestAsset\InvokableObject::class)); } } diff --git a/test/Tool/ConfigDumperCommandTest.php b/test/Tool/ConfigDumperCommandTest.php index 8e690de5..b263ca9a 100644 --- a/test/Tool/ConfigDumperCommandTest.php +++ b/test/Tool/ConfigDumperCommandTest.php @@ -1,23 +1,24 @@ dumper->dumpConfigFile($config); $this->assertContains( - '<' . "?php\n/**\n * This file generated by Zend\ServiceManager\Tool\ConfigDumper.\n", + '<' . "?php\n\n/**\n * This file generated by Laminas\ServiceManager\Tool\ConfigDumper.\n", $formatted ); diff --git a/test/Tool/FactoryCreatorCommandTest.php b/test/Tool/FactoryCreatorCommandTest.php index c7332462..e05c8396 100644 --- a/test/Tool/FactoryCreatorCommandTest.php +++ b/test/Tool/FactoryCreatorCommandTest.php @@ -1,19 +1,20 @@