zendframework / zend-servicemanager

ServiceManager component from Zend Framework
BSD 3-Clause "New" or "Revised" License
188 stars 89 forks source link

phpstan fixes #272

Open thomasvargiu opened 5 years ago

thomasvargiu commented 5 years ago

This PR fixes some issues with phpdoc and types. Used phpstan to static analyse the code.

Added phpstan in CI build.

thomasvargiu commented 5 years ago

I've added phpstan in CI build and fixed some wrong uses of array_key_exists with ArrayObject.

Ocramius commented 5 years ago

@thomasvargiu I've just noticed that this targets master: can you change it to develop? Since it's an improvement, it needs to target the next minor or major.

Ocramius commented 5 years ago

Please rebase, don't merge :)

thomasvargiu commented 5 years ago

My fault, I'm still working on it

thomasvargiu commented 5 years ago

@Ocramius I have just one issue that I want to fix:

------ ----------------------------------------------------------------------------------------------------------------------------
  Line   src/AbstractPluginManager.php
 ------ ----------------------------------------------------------------------------------------------------------------------------
  130    Parameter #1 $instance of method Zend\ServiceManager\AbstractPluginManager::validate() expects object, array|object given.
 ------ ----------------------------------------------------------------------------------------------------------------------------

I think we should change PHPDoc of $instance parameter in Zend\ServiceManager\PluginManagerInterface::validate() from object to mixed because we know that services config key can contain anything.

But I'm not sure about this change. We can also ignore the error at the moment.

What do you think about it?

thomasvargiu commented 5 years ago

I've noted that phpstan should only be added for Travis jobs that require it, not as a general dev dependency.

Done.

Additionally, I'll note that a large number of the changes presented here are present in other pull requests; you'll likely need to rebase and run again once those are in place.

It's not a problem, when I open it I though that it could be useful before to introduce strict type hints. We can merge other PRs and then rebase it.

Xerkus commented 5 years ago

Rescheduling to 4.0.0 since it targets develop in turn targeting 4.0

thomasvargiu commented 5 years ago

@weierophinney I rebased it, updated phpstan, done some other fixes.

I also allowed array in the PluginManager validate() method.

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-servicemanager; a new issue has been opened at https://github.com/laminas/laminas-servicemanager/issues/7.

weierophinney commented 4 years ago

This repository has been moved to laminas/laminas-servicemanager. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow: