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

Change return type of SerializerBuilder::build() to Serializer #1241

Merged
merged 2 commits into from
Aug 5, 2020
Merged

Change return type of SerializerBuilder::build() to Serializer #1241

merged 2 commits into from
Aug 5, 2020

Conversation

icanhazstring
Copy link
Contributor

@icanhazstring icanhazstring commented Jul 27, 2020

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.

Q A
Bug fix? sort of
New feature? no
Doc updated no
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

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.
@icanhazstring icanhazstring changed the title Change return type of build() to intersection Change return type of SerializerBuilder::build() to intersection Jul 27, 2020
@@ -499,7 +499,10 @@ public function setMetadataCache(CacheInterface $cache): self
return $this;
}

public function build(): SerializerInterface
/**
* @return SerializerInterface&ArrayTransformerInterface
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@goetas
Copy link
Collaborator

goetas commented Jul 31, 2020

@goetas
Copy link
Collaborator

goetas commented Aug 4, 2020

Since the serializer builder is marked as final, we can just typehint the build method with Serializer.

@icanhazstring
Copy link
Contributor Author

@goetas we could do this as well. You are right :)
I just wanted to adhere to the interface approach. Will change that.

@goetas
Copy link
Collaborator

goetas commented Aug 4, 2020

thanks!

@icanhazstring icanhazstring changed the title Change return type of SerializerBuilder::build() to intersection Change return type of SerializerBuilder::build() to Serializer Aug 4, 2020
@goetas goetas merged commit d719238 into schmittjoh:master Aug 5, 2020
@goetas
Copy link
Collaborator

goetas commented Aug 5, 2020

Thanks

@icanhazstring icanhazstring deleted the patch-1 branch August 11, 2020 15:14
@icanhazstring
Copy link
Contributor Author

Will this be tagged in a patch release soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants