-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Typehint className in instantiate method #44
Conversation
@@ -16,5 +16,5 @@ | |||
* | |||
* @throws ExceptionInterface | |||
*/ | |||
public function instantiate($className); | |||
public function instantiate(string $className); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a major BC break, as it breaks implementations :-\
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hence my comment above (PR comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a major BC break, as it breaks implementations
Note: Not with PHP 7.2+.
But then it should have : object
return type, which does break implementations (but can be made forward compatible with both Instantiator 1.x and 2.x).
Why? The interface clearly defines that the |
What is the point saying "It can be a string or it can be not" ? |
The only reason why this doesn't have a type hint is that it was introduced as a PHP 5.x polyfill. If bumping a major version for this particular change made sense, I would do it. For now, the PR simply stays in a limbo 👍 |
Closing in favor of #94. |
I think this was not Typehinted for BC break reasons but since in
src/Doctrine/Instantiator/Instantiator.php
the methodinstantiate
calls thebuildAndCacheFromFactory
method where className is Typehinted asstring
, I don't see in which scenario$className
could not be astring
.Moreover, in the interface the $className parameter is already described as
string
in the annotation.If we accept classes that implement
InstantiatorInterface
but don't use astring
as parameter (unlikely) then we need to remove the annotation. Right ?