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

Changed migration template to adopt strict types #1819

Merged
merged 2 commits into from
Jun 24, 2020

Conversation

Bilge
Copy link
Contributor

@Bilge Bilge commented Jun 22, 2020

Since Phinx targets PHP >= 7.2, it is safe and probably a good idea to include the strict_types declaration. How good of an idea? Well, not very good, because Phinx's API appears to be entirely devoid of scalar type hints and also misses array type hints in places where only arrays are valid. However, once these areas are updated, templates from now on will be configured correctly to take advantage of type hints and the errors generated by mismatching types. Without these type hints, PHP just emits warnings such as Invalid argument supplied for foreach() , but continues regardless until something worse blows up later on.

You will also notice I added a few other bonuses which can be reverted if it's too many changes for this PR. First is a final type declaration to signal that migrations are not intended to be inherited (there should be no use case for this). The second is the void return type hint just to keep static analysers happy. Again, either of these can be reverted but it is not expected to be particularly contentious.

@dereuromark
Copy link
Member

I don't think adding the strict types now provides any real measurable effect at this point for the library or the project use of it.

More importantly, we probably want to get phpstan to level 6, and make sure we start to add more typehints in general in the next majors probably.

@Bilge
Copy link
Contributor Author

Bilge commented Jun 23, 2020

It doesn't hurt to add the strict types requirement for migration files now.

@dereuromark
Copy link
Member

Fair enough.
If everyone else is fine with this.

@dereuromark dereuromark merged commit 1b88860 into cakephp:master Jun 24, 2020
@Bilge
Copy link
Contributor Author

Bilge commented Jun 26, 2020

Can we get a tag for this?

@dereuromark
Copy link
Member

https://github.com/cakephp/phinx/releases/tag/0.12.3

@Bilge Bilge deleted the strict_types branch June 26, 2020 23:26
Bilge referenced this pull request Dec 30, 2022
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants