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

Declare some types #7092

Merged
merged 3 commits into from
Feb 25, 2018
Merged

Declare some types #7092

merged 3 commits into from
Feb 25, 2018

Conversation

lcobucci
Copy link
Member

Since now we're require PHP 7.2 we can start to add object

@lcobucci lcobucci added this to the 3.0 milestone Feb 25, 2018
@lcobucci lcobucci self-assigned this Feb 25, 2018
@lcobucci
Copy link
Member Author

I've tried to minimise the impact so I could already use this in #7054

* @param object $entity
*
* @return \Generator
* @return string|int
Copy link
Member

Choose a reason for hiding this comment

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

What happened here? :|

Copy link
Member Author

Choose a reason for hiding this comment

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

It was just wrong before, you can see based on the implementation...

{
return $this->maxValue;
}

/**
* Gets the next value that will be returned by generate().
*
* @return int
Copy link
Member

Choose a reason for hiding this comment

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

Was this previously wrong?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeap...

Copy link
Member Author

@lcobucci lcobucci Feb 25, 2018

Choose a reason for hiding this comment

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

I mean, it's not needed with the type hint =)

Copy link
Member

Choose a reason for hiding this comment

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

The hint added nullability

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, no, I think my comment was misplaced

* @param string $serialized
*/
public function unserialize($serialized)
public function unserialize($serialized) : void
Copy link
Member

Choose a reason for hiding this comment

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

Can a string type be added here? Or does it collide with Serializable?

Copy link
Member Author

Choose a reason for hiding this comment

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

It collides with Serializable

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll put the docblock back, my intention was to add the type declaration

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@Ocramius
Copy link
Member

🚢

@Ocramius Ocramius merged commit 3e1d124 into doctrine:master Feb 25, 2018
@lcobucci lcobucci deleted the declare-some-types branch February 25, 2018 18:18
@Majkl578
Copy link
Contributor

@Ocramius Hmm so now documentation of type changes is not required anymore? I am confused.

@Ocramius
Copy link
Member

@Majkl578 these types are compatible with existing ones, and as we now support PHP 7.2, then subclasses and implementors do not break if we add a type in a superclass or abstract type.

@Majkl578
Copy link
Contributor

subclasses and implementors do not break if we add a type in a superclass or abstract type

That is only true for parameter types, but return types were also added here.

@Ocramius
Copy link
Member

Ocramius commented Feb 25, 2018

@lcobucci worth adding UPGRADE.md docs then

@lcobucci
Copy link
Member Author

@Ocramius @Majkl578 yeap, I completely forgot to do it... sending a PR in a bit

@greg0ire greg0ire removed this from the 3.0.0 milestone Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants