Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Update to use PSR-11 for plugin managers #36

Merged
merged 17 commits into from
Feb 16, 2017

Conversation

weierophinney
Copy link
Member

This patch updates zend-config to typehint on PSR-11 for each of its plugin managers, and provides standalone versions that have no dependencies other than the PSR-11 interfaces; this allows usage of the Factory without having zend-servicemanager installed.

Additionally, this patch does the following:

  • Updates the minimum supported versions of dependencies to the latest releases of each. If both v2 and v3 versions exist, it allows either.
  • Updates the JSON reader and writer to allow usage with ext/json, falling back to zend-json if present. This allows usage without zend-json being present.
  • Adds malukehno/docheader as a development requirement, in order to enforce license headers in all class files.

- and conflict with container-interop < 1.2.0.
… plugin managers

Allows usage with any PSR-11 implementation, not just the
zend-servicemanager-based ones present.
Instead of zend-servicemanager variants. Ensures no requirement for
zend-servicemanager for standalone usage of the `Factory`.
Set minimum supported versions to most recent releases of dependencies.
In cases where 2.X and 3.X versions exist, and they are compatible, the
most recent versons of each are `||`'d.
Will now default to ext/json when present.
- Now require `malukehno/docheader` in development.
- Added configuration via `.docheader`.
- `license-check` will check all `src/` files.
- `license-check-all` will check all `src/` and `test/` files; there are
  test assets that are _expected_ to fail.
- Travis runs `license-check` for targets doing CS checks.
*/
private function decode($data)
{
if (function_exists('json_decode')) {
Copy link
Member

Choose a reason for hiding this comment

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

From PHP docs:

As of PHP 5.2.0, the JSON extension is bundled and compiled into PHP by default.
http://php.net/manual/en/json.installation.php

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but many distributions still ship it as an optional package. As such, we still need to verify, and have zend-json as a polyfill.

Copy link
Member

Choose a reason for hiding this comment

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

"require":{"ext-json":"*"} ;-)

Copy link
Member Author

Choose a reason for hiding this comment

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

That's even easier... 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to remove zend-json entirely and require ext-json via Composer.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I like it, but now we lost zend-json fallback IF somebody doesn't have this extension and can't add it (IF it is even possible to not have it now on PHP 5.6+)

Copy link
Member

Choose a reason for hiding this comment

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

@webimpress seriously: their loss. A system without json support in 2017? :|

'php' => Writer\PhpArray::class,
'phparray' => Writer\PhpArray::class,
'xml' => Writer\Xml::class,
'yaml' => Writer\Yaml::class,
Copy link
Member

Choose a reason for hiding this comment

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

Can we have here less spaces before =>, please?

*/
public function processConfig(array $config)
{
return JsonFormat::encode($config);
if (function_exists('json_encode')) {
Copy link
Member

Choose a reason for hiding this comment

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

As noted above, probably we don't need it.

}

/**
* @dataProvider supportedConfigExtensions
Copy link
Member

Choose a reason for hiding this comment

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

Can we add here also @param TYPE NAME for method parameters, please?

* @param string $extension
* @param string $expectedType

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}

/**
* @dataProvider supportedConfigClassNames
Copy link
Member

Choose a reason for hiding this comment

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

Can we add here:

* @param string $class

please?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}

/**
* @dataProvider supportedConfigTypes
Copy link
Member

Choose a reason for hiding this comment

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

As above, can we update PHPDocs here, please?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}

/**
* @dataProvider supportedConfigClassNames
Copy link
Member

Choose a reason for hiding this comment

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

Update PHPDocs please.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

src/Factory.php Outdated
{
static::$readers = $readers;
}

/**
* Get the reader plugin manager
*
* @return ReaderPluginManager
* @return ContainerInterface
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should have here also StandaloneReaderPluginManager, so generic one and specific/default?

Yes, I know that StandaloneReaderPluginManager implements ContainerInterface.

Copy link
Member Author

Choose a reason for hiding this comment

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

The whole point with this change was to signal that you can provide generic implementations based on ContainerInterface.

I'll update the method description to indicate the default implementation, however.

src/Factory.php Outdated
{
static::$writers = $writers;
}

/**
* Get the writer plugin manager
*
* @return WriterPluginManager
* @return ContainerInterface
Copy link
Member

Choose a reason for hiding this comment

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

As above, maybe we need to have here ContainerInterface|StandaloneWriterPluginManager?

Instead of optionally requiring ext/json and/or zend-json, just require
ext/json. This simplifies internal logic tremendously, and allows
removal of a custom exception.
- Always install from lock file
- If on 5.6, update the PHPUnit dependency to ensure we get a version
  that works with that PHP version.
- If on the "latest" strategy, do a full update.
- If on the "lowest" strategy, do a full update, with `--prefer-lowest`.
- If test coverage is requested, install coverage utilities.
- Use variables to detail both legacy and coverage dependencies.
@weierophinney weierophinney merged commit 9199d71 into zendframework:develop Feb 16, 2017
weierophinney added a commit that referenced this pull request Feb 16, 2017
@weierophinney weierophinney deleted the feature/psr-11 branch February 16, 2017 22:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants