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

Apply language level migrations and clean-ups #33

Merged
merged 12 commits into from
Apr 1, 2022

Conversation

jeromegamez
Copy link
Contributor

@jeromegamez jeromegamez commented Jan 21, 2022

Hey there 👋,

as promised (threatened 😅), here's my follow-up PR. Since we can now expect to be on at least PHP 7.4 and PHPUnit 9.5, there are some improvements that can be applied.

I tried to be as atomic as possible, with each commit message describing what it is about, but I think some of the changes warrant a little more context:

  • Since we now have type-hints, PHPDocs are even more meant for documentation rather than support for IDEs or API Doc generation. That's the reason why I removed all property, argument and return value annotations that are already visible through the type hints.
  • There's no need for reflection or func_get_args() anymore \o/
  • According to the RFC, the "id" property of a Feature is expected to be a JSON string or a number (https://www.rfc-editor.org/rfc/rfc7946#section-3.2), so I added a check for this. This would be a breaking change, so if you're targeting a 1.1 release instead of a 2.0 release, I can remove the check again.
  • Testing the unhappy paths of the GeoJson::unserialize() method is not strictly part of the language level migration, but it was the only method that prevented a 100% code coverage and even if its importance can be disputed, I still think that it's a nice metric 😅
  • The array<...> notation in DocBlocks is used to avoid consecutive [][][]s and to make it a little bit easier to make out the supported types - especially for the nested ones. The changes should enable IDEs like PHPStorm to provide autocompletion and Static Code Analysis Tools like PHPStan to parse them.

:octocat:

Closes #21
Closes #22
Closes #30

@jeromegamez
Copy link
Contributor Author

Speaking of release 1.1 vs 2.0 - I stumbled upon this sentence in the RFC (https://www.rfc-editor.org/rfc/rfc7946#appendix-B.1):

B.1. Normative Changes

  • Specification of coordinate reference systems has been removed, i.e., the "crs" member of [GJ2008] is no longer used.

The according classes could be removed for a 2.0 release, but 1.1 would have to keep them. What are your thoughts?

@jeromegamez jeromegamez force-pushed the language-level-migration branch from 3a68197 to 15a53cc Compare January 21, 2022 23:35
@jeromegamez
Copy link
Contributor Author

Ugh, I realize that this is quite much. If you prefer another way of me submitting these changes or if you think that's all not needed, please let me know 🙈

@jeromegamez jeromegamez force-pushed the language-level-migration branch from b51ebe7 to 0e0a1ec Compare January 22, 2022 02:32
@jmikola
Copy link
Owner

jmikola commented Feb 11, 2022

@jeromegamez: Just wanted to let you know that I haven't forgotten about this PR. I just haven't had the time to take a look at it. There's definitely no need to split this up, as I realize that'd be a pretty tedious process given the commits all touching the same files.

src/GeoJson/Geometry/Polygon.php Show resolved Hide resolved
src/GeoJson/Feature/Feature.php Outdated Show resolved Hide resolved
src/GeoJson/GeoJson.php Outdated Show resolved Hide resolved
src/GeoJson/BoundingBox.php Show resolved Hide resolved
src/GeoJson/CoordinateReferenceSystem/Linked.php Outdated Show resolved Hide resolved
src/GeoJson/CoordinateReferenceSystem/Named.php Outdated Show resolved Hide resolved
src/GeoJson/Feature/Feature.php Show resolved Hide resolved
src/GeoJson/Feature/Feature.php Show resolved Hide resolved
@jmikola
Copy link
Owner

jmikola commented Mar 24, 2022

@jeromegamez: Thanks for all of the work on this PR, and apologies again for the delay in setting time aside to review this. I'll give you some time to address my feedback but if you don't get a chance (understandable) I will try to circle back next week, apply my own suggestions, and merge directly.

@jmikola
Copy link
Owner

jmikola commented Mar 24, 2022

I'll aim to take another look at this before the weekend and merge it down. Thanks very much for the quick follow-up on my late review!

@jeromegamez
Copy link
Contributor Author

jeromegamez commented Mar 25, 2022

Thank you for wading through all the changes!

When you merge the PR, will you do it as a single , squashed commit or as a rebase with all commits? If it's the latter, I would like to clean them up first by squashing some of them (if you don't mind the force push).

@jmikola
Copy link
Owner

jmikola commented Mar 25, 2022

I typically do squashing but I see that I did a rebase for your previous PR. I think that was because I manually added some of my own and ended up merging via the command line.

Anyway, I'm happy to do a rebase here. That may prove more helpful down the line if we ever need to refer back to a logical change. Feel free to squash and force push as you like.

@jeromegamez jeromegamez force-pushed the language-level-migration branch from f931387 to 8ed3b70 Compare March 26, 2022 00:20
It should be clear that composer dependencies need to be installed
in order to work on and test the library, so the `bootstrap.php` 
file can be deleted.

Since USAGE.md has been merged into README.md, the `site` 
directory is not needed anymore.
@jeromegamez jeromegamez force-pushed the language-level-migration branch from 8ed3b70 to edfa221 Compare March 26, 2022 00:35
@jeromegamez
Copy link
Contributor Author

Alright, I think I'm done with cleaning up the commits (it was mostly integrating your suggested changes in the respective commits), and this brought us from 21 commits down to 12, including the deprecation of the CoordinateReferenceSystem which I forgot earlier.

@jeromegamez jeromegamez force-pushed the language-level-migration branch from 2cc1c1f to a2915ec Compare March 26, 2022 00:52
@jeromegamez
Copy link
Contributor Author

The composer docs have more information about the allow-plugins directive at https://getcomposer.org/doc/06-config.md#allow-plugins

I think the Slevomat is considered a plugin because it's type is phpcodesniffer-standard instead of library, but I'm not 100% sure.

* Constructor.
*
* @param float[] $bounds
* @param array<float|int> $bounds
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. I see it agrees with "BoundingBox values must be integers or floats" below.

"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this. Is this actually required for anything? I haven't come across this before and we don't use in mongo-php-library.

Looking at phpcs.xml.dist, I only see references to the standard rules that ship with phpcs and Slevomat, which we explicitly require above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The composer docs have more information about the allow-plugins directive at https://getcomposer.org/doc/06-config.md#allow-plugins

I think the Slevomat is considered a plugin because it's type is phpcodesniffer-standard instead of library, but I'm not 100% sure.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll clone this later tonight and try to run phpcs without this plugin. If all goes well (and Slevomat rules are checked), I'll see if this can be removed. Otherwise, I'll keep it in.

Either way, I'll expect to have this PR merged Thursday. Thanks again!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing out the PR locally, I noticed this wasn't required to run phpcs; however, I read up further on the Composer 2.2 changes and the PHPCSStandards/composer-installer README and now understand this is a forward-thinking change to ensure Slevomat is properly installed after the new security rules take effect in July.

LGTM.

@jmikola jmikola merged commit fbe590b into jmikola:master Apr 1, 2022
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.

2 participants