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

Use readonly properties for model classes #217

Merged
merged 10 commits into from
Nov 6, 2023
Merged

Conversation

oschwald
Copy link
Member

  • Drop 8.0 support. Test on 8.2.
  • Use readonly properties
  • Only include set fields in jsonSerlialize output
  • Upgrade to phpunit 10
  • Use vendor/autoload.php to bootstrap directly
  • Do not include name in JSON output
  • Make ipAddress and network nullable

This is more similar to the previous version and the output is much
more usable, particularly for things like Country.
@oschwald oschwald force-pushed the greg/readonly-properties branch 2 times, most recently from a3c8dbf to ee920df Compare October 31, 2023 22:06
This makes is more similar to the web-service response.
This is needed for minFraud.
Previously this was not possible as we were using magic methods.
@oschwald oschwald force-pushed the greg/readonly-properties branch from ee920df to 59aab5d Compare October 31, 2023 22:08
Copy link
Contributor

@faktas2 faktas2 left a comment

Choose a reason for hiding this comment

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

Just had a few comments.

phpunit.xml.dist Outdated
</testsuite>
</testsuites>
<logging/>
<source>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there is a <source> tag. Did you mean <coverage> ? https://docs.phpunit.de/en/10.0/configuration.html#the-include-element

Copy link
Member Author

Choose a reason for hiding this comment

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

Given that phpunit generated it, I assume it is valid, but I'll see if I can clean it up.

Copy link
Member Author

@oschwald oschwald Nov 6, 2023

Choose a reason for hiding this comment

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

There is an example of its usage in their repo.

See this issue.

phpunit.xml.dist Outdated
<logging/>
<source>
<include>
<directory suffix=".php">./src/GeoIp2/</directory>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the ..../GeoIp2 extra in here ? I can't see the directory within src.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that predates our switch to PSR-4. I'll clean it up.

new \GeoIp2\Record\Subdivision($sub, $locales)
;
}

// Not using end as we don't want to modify internal pointer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would array_key_last help with this ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but that would just turn it to $subdivisions[\array_key_last($subdivisions)]. I am not sure that is a big improvement. I am guessing it would be slower and might make people think it is an associative array as opposed to an indexed one.

phpunit.xml.dist Outdated
<directory suffix="Test.php">./tests/GeoIp2/Test/</directory>
</testsuite>
</testsuites>
<logging/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this tag if it doesn't configure anything ?

Copy link
Member Author

Choose a reason for hiding this comment

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

These changes are the result of phpunit --migrate-configuration. I didn't modify the file by hand.

@faktas2 faktas2 merged commit 441034b into main Nov 6, 2023
7 checks passed
@faktas2 faktas2 deleted the greg/readonly-properties branch November 6, 2023 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants