-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
PhpStan fixes #364
base: master
Are you sure you want to change the base?
PhpStan fixes #364
Conversation
if ($this->errors) { | ||
throw new Exception('SQL translate error: ' . trim(reset($this->errors), '*'), 0, $sql); | ||
if ($this->errors !== []) { | ||
throw new Exception('SQL translate error: ' . trim((string) reset($this->errors), '*'), 0, $sql); |
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 changes behavior, can be null or empty array. And original code is correct.
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.
I reverted original condition but kept (string)
for PhpStan because function reset()
can return mixed
value.
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.
For nonempty string[]
? I think it must be always string.
if (in_array($code, [1216, 1217, 1451, 1452, 1701], true)) { | ||
return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql); | ||
if (is_int($code) === true) { | ||
if (in_array($code, [1216, 1217, 1451, 1452, 1701], true)) { |
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.
there is no reason for this change, in_array checks type
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.
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.
I think in mysql driver it is always int.
@@ -41,7 +41,8 @@ public function __construct(\mysqli_result $resultSet, bool $buffered) | |||
*/ | |||
public function __destruct() | |||
{ | |||
if ($this->autoFree && $this->getResultResource()) { | |||
if ($this->autoFree) { | |||
$this->getResultResource(); |
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.
changes behavior
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.
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 is right.
138139d
to
81a66da
Compare
8db0534
to
cc3b09e
Compare
17866e0
to
82c45c3
Compare
dd46ea7
to
9e71132
Compare
f739394
to
86a71dd
Compare
ebee17f
to
9908f6f
Compare
b6a770f
to
ab68077
Compare
4947fa5
to
04f006a
Compare
I fixed some PhpStan errors.
Resend #363.