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

Alexkalanis/refactoring for php7 oop #8

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

alex-kalanis
Copy link

Update nearly the complete code, possible to use as v2, minimal php7

  • added service to access Nearby endpoint (my inital reason)
  • enabled extending of some parts (extended service factory, other query libraries)
  • added tests (phpunit, phpstan, codestyle)
  • added comments and property descriptions

@dereuromark
Copy link
Contributor

dereuromark commented Feb 20, 2024

Wow, this looks super useful
I love that you also added tests

Would you be interested in re-added this to the maintained fork @ https://github.com/php-collective/google-maps-services ?

  • CI
  • tests
  • new functionality

Note:

  • CS is already added, so this can be skipped.
  • We can rename the namespace from yidas\googleMaps to PhpCollective\GoogleMaps

@yidas
Copy link
Owner

yidas commented Feb 21, 2024

There are two issues I'd like to discuss:

  1. Modifying the mininal PHP version to 7.4 is embarrassing, I suggest to keep supporting 7.0 as the current one.
  2. Modifying the namespace from lower to upper camel case is the same as above.

Thanks!

@dereuromark
Copy link
Contributor

7.4 is definitly the best min version possible at this point (2024).
Even 8.0 is already EOL - https://www.php.net/supported-versions.php
Whats the reason to support versions from like 4 years ago?

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
@alex-kalanis
Copy link
Author

7.1 is minimum due type control over null. "?string" etc... Even PSR already have problems with php7 (here http message).
API in src\Client stays the same.

@alex-kalanis
Copy link
Author

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.

@yidas
Copy link
Owner

yidas commented Feb 21, 2024

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.

@dereuromark
Copy link
Contributor

There should be no one anymore: https://stitcher.io/blog/php-version-stats-january-2024
Ancient is basically 7.4 (LTS for 7.x)

@yidas
Copy link
Owner

yidas commented Feb 21, 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.

@alex-kalanis
Copy link
Author

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",
Copy link
Contributor

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=[])
Copy link
Contributor

Choose a reason for hiding this comment

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

That looks wrong

Copy link
Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.4', '8.0', '8.1' ]
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

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

Adding.

Copy link
Contributor

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

$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());
Copy link
Contributor

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
Copy link
Contributor

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

@dereuromark
Copy link
Contributor

@yidas I recommend changing the github setting so only "new github contributors" require a manual workflow run init.
This way, the tests will run right away for PRs.

@dereuromark
Copy link
Contributor

We should probably wrap this up :)

@dereuromark
Copy link
Contributor

@yidas you still would want to change the github action run setting as per my suggestion

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.

None yet

3 participants