-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Declare some types #7092
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,13 +38,7 @@ class SequenceGenerator implements Generator, Serializable | |
*/ | ||
private $maxValue; | ||
|
||
/** | ||
* Initializes a new sequence generator. | ||
* | ||
* @param string $sequenceName The name of the sequence. | ||
* @param int $allocationSize The allocation size of the sequence. | ||
*/ | ||
public function __construct($sequenceName, $allocationSize) | ||
public function __construct(string $sequenceName, int $allocationSize) | ||
{ | ||
$this->sequenceName = $sequenceName; | ||
$this->allocationSize = $allocationSize; | ||
|
@@ -53,7 +47,7 @@ public function __construct($sequenceName, $allocationSize) | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function generate(EntityManagerInterface $em, $entity) | ||
public function generate(EntityManagerInterface $em, ?object $entity) | ||
{ | ||
if ($this->maxValue === null || $this->nextValue === $this->maxValue) { | ||
// Allocate new values | ||
|
@@ -70,41 +64,34 @@ public function generate(EntityManagerInterface $em, $entity) | |
|
||
/** | ||
* Gets the maximum value of the currently allocated bag of values. | ||
* | ||
* @return int|null | ||
*/ | ||
public function getCurrentMaxValue() | ||
public function getCurrentMaxValue() : ?int | ||
{ | ||
return $this->maxValue; | ||
} | ||
|
||
/** | ||
* Gets the next value that will be returned by generate(). | ||
* | ||
* @return int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this previously wrong? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeap... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, it's not needed with the type hint =) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hint added nullability There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, no, I think my comment was misplaced |
||
*/ | ||
public function getNextValue() | ||
public function getNextValue() : int | ||
{ | ||
return $this->nextValue; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function serialize() | ||
public function serialize() : string | ||
{ | ||
return serialize( | ||
[ | ||
'allocationSize' => $this->allocationSize, | ||
'sequenceName' => $this->sequenceName, | ||
'allocationSize' => $this->allocationSize, | ||
'sequenceName' => $this->sequenceName, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @param string $serialized | ||
*/ | ||
public function unserialize($serialized) | ||
public function unserialize($serialized) : void | ||
{ | ||
$array = unserialize($serialized); | ||
|
||
|
@@ -115,7 +102,7 @@ public function unserialize($serialized) | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isPostInsertGenerator() | ||
public function isPostInsertGenerator() : bool | ||
{ | ||
return false; | ||
} | ||
|
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.
What happened here? :|
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.
It was just wrong before, you can see based on the implementation...