-
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
Make implicit type casts explicit #8836
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 |
---|---|---|
|
@@ -610,13 +610,13 @@ class ClassMetadataInfo implements ClassMetadata | |
* <code> | ||
* array( | ||
* 'sequenceName' => 'name', | ||
* 'allocationSize' => 20, | ||
* 'initialValue' => 1 | ||
* 'allocationSize' => '20', | ||
* 'initialValue' => '1' | ||
* ) | ||
* </code> | ||
* | ||
* @var mixed[] | ||
* @psalm-var array{sequenceName: string, allocationSize: int, initialValue: int} | ||
* @psalm-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed} | ||
* @todo Merge with tableGeneratorDefinition into generic generatorDefinition | ||
*/ | ||
public $sequenceGeneratorDefinition; | ||
|
@@ -3289,7 +3289,7 @@ public function setCustomGeneratorDefinition(array $definition) | |
* ) | ||
* </code> | ||
* | ||
* @psalm-param array<string, string> $definition | ||
* @psalm-param array{sequenceName?: string, allocationSize?: int|string, initialValue?: int|string, quoted?: mixed} $definition | ||
* | ||
* @return void | ||
* | ||
|
@@ -3306,14 +3306,17 @@ public function setSequenceGeneratorDefinition(array $definition) | |
$definition['quoted'] = true; | ||
} | ||
|
||
if (! isset($definition['allocationSize']) || trim($definition['allocationSize']) === '') { | ||
if (! isset($definition['allocationSize']) || trim((string) $definition['allocationSize']) === '') { | ||
$definition['allocationSize'] = '1'; | ||
} | ||
|
||
if (! isset($definition['initialValue']) || trim($definition['initialValue']) === '') { | ||
if (! isset($definition['initialValue']) || trim((string) $definition['initialValue']) === '') { | ||
$definition['initialValue'] = '1'; | ||
} | ||
|
||
$definition['allocationSize'] = (string) $definition['allocationSize']; | ||
$definition['initialValue'] = (string) $definition['initialValue']; | ||
|
||
Comment on lines
+3309
to
+3319
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. It would make sense to use a variable here now so you need to cast only one time. It increases readability after the type casts were introduced or when changes are going to be introduced where the type casts are forgotten. 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. Can you please show me how you would do it? It tried, and it's a bit too tricky IMO, since 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. My bad, I confused keys during my review. 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. No worries :) |
||
$this->sequenceGeneratorDefinition = $definition; | ||
} | ||
|
||
|
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.
Since the
+
operator is used here, this must be fine:orm/lib/Doctrine/ORM/Id/SequenceGenerator.php
Line 78 in 95408cd