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
Add type hints to codebase #1995
Conversation
I would hold off on the strict_types part, as this can create some more pitfalls where currently auto-casting works (to not break more than necessary). |
{ | ||
$this->columns = $columns; | ||
$this->columns = is_string($columns) ? [$columns] : $columns; |
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.
This change makes this method equivalent to how setColumns
works in the ForeignKey
class.
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.
Though the handling of the $columns
value is very inconsistent across the codebase. A number of the AlterInstruction
functions within the database adapters accepts a string $column
property while some accept a Column $column
, and then elsewhere we have string|string[] $columns
or just string[] $columns
. A follow-up PR would perhaps be good to work on making this more consistent throughout.
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
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.
Reviewed conventions. Left a couple open questions about valid types but just from a logic point of view.
I skipped several adapters that were likely exact copies of the base adapter.
Shall we continue/finish this for the next branch? |
Co-authored-by: othercorey <corey.taylor.fl@gmail.com>
Co-authored-by: othercorey <corey.taylor.fl@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
@othercorey requested changes have been made. @dereuromark the failing phpstan test is due to a bug in phpstan: phpstan/phpstan#5369. Could maybe pin the used version to an older one that doesn't have this bug? |
@othercorey What do you think about the float thingie? Should we keep as is, or do we want to internally work with integers here (as one intuitively would)? |
Looks like Is it possible to cast the limit when reflecting? |
For the MySQL adapter, the following values are problematic if declaring a
phinx/src/Phinx/Db/Adapter/MysqlAdapter.php Lines 73 to 74 in 26adc41
These values all exceed the value of This would be BC breaking, but in a way that I'm not sure anyone would notice. The specifics here are that:
However, again, given that these are supposed to be "magic constants" as it were and not to directly depend on the underlying value, should be fine to change? |
Looks like this is implemented differently than I leave it up to you. I was just reviewing the type conventions and noticed the type changed in an odd way there. |
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
@othercorey @dereuromark I followed through with what I talked about above, giving the
That's the expected usage of |
This PR will add type hints to all possible places in the codebase. I debated on adding
declare(strict_types=1);
at the same time, but not sure if should be done at the same time, or separately. Putting this up in draft form to keep track of progress, and hopefully help ensure no one else spends time on doing this concurrently.