-
-
Notifications
You must be signed in to change notification settings - Fork 586
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
Change return type of SerializerBuilder::build() to Serializer #1241
Conversation
Using the `SerializerBuilder` build will return an instance of `Serializer` which implements `SerializerInterface` and `ArrayTransformerInterface`. So the return type of `SerializerInterface` is wrong in this case.
src/SerializerBuilder.php
Outdated
@@ -499,7 +499,10 @@ public function setMetadataCache(CacheInterface $cache): self | |||
return $this; | |||
} | |||
|
|||
public function build(): SerializerInterface | |||
/** | |||
* @return SerializerInterface&ArrayTransformerInterface |
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.
is this syntax supported? as I know php does not have yet intersection types
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.
the ci job https://travis-ci.org/github/schmittjoh/serializer/jobs/712201589 is failing |
Since the serializer builder is marked as final, we can just typehint the build method with |
@goetas we could do this as well. You are right :) |
thanks! |
Thanks |
Will this be tagged in a patch release soon? |
Using the
SerializerBuilder
build will return an instance ofSerializer
which implementsSerializerInterface
andArrayTransformerInterface
.So the return type of
SerializerInterface
is wrong in this case.