Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INJECTOR: Add type declarations to properties #45

Closed
wants to merge 1 commit into from

Conversation

sjokkateer
Copy link
Contributor

And also missing method return types

Signed-off-by: Remy Bos [email protected]

Q A
Documentation no
Bugfix no
BC Break no
New Feature no
RFC no
QA no

Description

This PR adds type declarations to the Injector::class properties as well as update some of the missing method return types.

src/Injector.php Outdated

/** @var ConfigInterface */
protected $config;
protected DefinitionInterface $definition;
Copy link
Member

Choose a reason for hiding this comment

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

This type addition is a BC break for inheritance scenarios 🤔

Copy link
Contributor Author

@sjokkateer sjokkateer May 9, 2022

Choose a reason for hiding this comment

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

Would you like me to add back the docblock or is there a better way to account for the BC break?

Copy link
Member

Choose a reason for hiding this comment

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

Back to comment is okay

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On a side note, is there a way for me to detect BC breaks like those up front?

Copy link
Member

Choose a reason for hiding this comment

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

I wrote https://github.com/Roave/BackwardCompatibilityCheck, which is somewhat able to detect some of these :-)

I'd really like to integrate it with our CI: laminas/laminas-ci-matrix-action#60

And also missing method return types

Signed-off-by: Remy Bos <[email protected]>
@sjokkateer sjokkateer force-pushed the improvement/injector branch from 039efd5 to 2b357c0 Compare May 9, 2022 18:13

/** @var string[] */
protected $instantiationStack = [];
protected array $instantiationStack = [];
Copy link
Member

Choose a reason for hiding this comment

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

this is BC break, only private property that allowed the type to be changed when class is not final

Copy link
Contributor Author

@sjokkateer sjokkateer May 9, 2022

Choose a reason for hiding this comment

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

I see, thanks for the insight. Does that mean the other protected properties I modified should be reverted back to using docblocks as well?

Copy link
Member

Choose a reason for hiding this comment

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

yes

* @throws ClassNotFoundException
* @throws RuntimeException
*/
public function create(string $name, array $parameters = [])
public function create(string $name, array $parameters = []): ?object
Copy link
Member

Choose a reason for hiding this comment

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

this is also BC break when extended class override it, ref https://3v4l.org/QTiTt

* @throws InvalidCallbackException
* @throws ClassNotFoundException
*/
protected function createInstance(string $name, array $params)
protected function createInstance(string $name, array $params): object
Copy link
Member

@samsonasik samsonasik May 9, 2022

Choose a reason for hiding this comment

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

this is also BC break when extended class override it, ref https://3v4l.org/OgOHS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see now, thanks again for the insight.
Sorry for my lack of knowledge and wasting your and @Ocramius time but I think this pull request can be closed/ignored then.

@samsonasik samsonasik closed this May 9, 2022
@sjokkateer sjokkateer deleted the improvement/injector branch May 9, 2022 18:48
@Ocramius Ocramius added BC Break Enhancement Won't Fix This will not be worked on labels May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Break Enhancement Won't Fix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants