-
Notifications
You must be signed in to change notification settings - Fork 33
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
Alexkalanis/refactoring for php7 oop #8
base: master
Are you sure you want to change the base?
Alexkalanis/refactoring for php7 oop #8
Conversation
- services into subdir, use factory for getting them - client also into subdir, allow to change to another one - add static analysis tools, allow add tests
- nearly all available code goes through tests
…hp7_oop Alexkalanis/refactoring for php7 oop
Wow, this looks super useful Would you be interested in re-added this to the maintained fork @ https://github.com/php-collective/google-maps-services ?
Note:
|
There are two issues I'd like to discuss:
Thanks! |
7.4 is definitly the best min version possible at this point (2024). I agree that the namespace change looks like a BC break and as such should not be done without majoring, so probably not in this PR. |
# Conflicts: # README.md
7.1 is minimum due type control over null. "?string" etc... Even PSR already have problems with php7 (here http message). |
Also I do not expect that this pull request will rot here for 2 years. I set major version in mine repo as 2 - breaking change is then expected. |
The idea is to take care of users of the ancient system who want to use new services as possible. How about to keep the mininal PHP version at 7.1 so far with the same namespace. |
There should be no one anymore: https://stitcher.io/blog/php-version-stats-january-2024 |
I also referred to that article which revealed the number of 7.1 releases until January 2024. from my perspective, the priority we can work on right now is to check which code changes are using the 7.4 version restrictions. |
Namespaces rewritten. |
composer.json
Outdated
@@ -10,9 +10,19 @@ | |||
"source": "https://github.com/yidas/google-maps-services-php" | |||
}, | |||
"require": { | |||
"php": ">=5.4", | |||
"ext-json": "*", | |||
"php": ">=7.4", |
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.
7.1 right?
@@ -16,231 +15,68 @@ | |||
* @method array elevation(string $locations, array $params=[]) | |||
* @method array geocode(string $address, array $params=[]) | |||
* @method array reverseGeocode(string $latlng, array $params=[]) | |||
* @method array computeRoutes(array $origin, array $destination, array $body=[], array $fieldMask=[]) | |||
* @method array computeRoutes(array $origin, array $destination, array $body=[], array $headers=[], array $params=[]) |
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.
That looks wrong
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.
\yidas\googleMaps\Services\Routes::computeRoutes - src/Services/Routes.php:59
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.
google-maps-services-php/src/Routes.php
Line 31 in a6300c7
public static function computeRoutes(Client $client, $origin, $destination, $body=[], $fieldMask=[]) |
My point is that there have been changes in upstream to provide fieldmask directly which seems reverted now in your PR.
.github/workflows/code_checks.yml
Outdated
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php: [ '7.4', '8.0', '8.1' ] |
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.
Usually min max suffices
7.1, 8.3 then
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.
Adding.
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.
My point is that only 7.1 and 8.3 needs testing
tests/ServiceTests/RoutesTest.php
Outdated
$lib = new Services\Routes(new ApiAuth('test')); | ||
$this->assertEquals('https://routes.googleapis.com/directions/v2:computeRoutes', $lib->getPath()); | ||
$this->assertEquals('POST', $lib->getMethod()); | ||
$this->assertEquals(null, $lib->getBody()); |
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.
assertNull() usully
Small nitpick: also assertSame() with scalar values to make sure the type also mappes IMO
* @throws ServiceException | ||
* @return array<string, string|int|float> | ||
*/ | ||
public function computeRoutes($origin, $destination, $body=[], array $headers=[], array $params=[]): array |
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 looks different than upstream. I think headers are not used anymore afaik, instead fieldmask
See https://github.com/yidas/google-maps-services-php/pull/15/files
@yidas I recommend changing the github setting so only "new github contributors" require a manual workflow run init. |
We should probably wrap this up :) |
…s-php into alexkalanis/refactoring_for_php7_oop
@yidas you still would want to change the github action run setting as per my suggestion |
Update nearly the complete code, possible to use as v2, minimal php7