-
Notifications
You must be signed in to change notification settings - Fork 83
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
Improve code by using current standards on strict types #122
Conversation
…PStan at level 8 and report no errors
For those who want to run PHPStan, here is the configuration file I use: parameters:
level: 8
tipsOfTheDay: false
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: true
polluteScopeWithLoopInitialAssignments: false
polluteScopeWithAlwaysIterableForeach: false
checkExplicitMixedMissingReturn: true
checkFunctionNameCase: true
checkInternalClassCaseSensitivity: true
reportMaybesInMethodSignatures: true
reportMaybesInPropertyPhpDocTypes: true
reportStaticMethodSignatures: true
checkUninitializedProperties: true
rememberPossiblyImpureFunctionValues: true
treatPhpDocTypesAsCertain: false
#phpVersion: 70200
#phpVersion: 70300
#phpVersion: 70400
#phpVersion: 80000
#phpVersion: 80100
phpVersion: 80200
paths:
- ./MatomoTracker.php Save it as Run with:
|
PSR formatting. I did not follow all the rules, because that would require to remove the extra commands at the bottom of the file, PSR requires that a loadable class does NOT contain extra code outside the class. |
…s unclear why this was placed here since it causes problems.
Removed undocumented RuntimeException that causes problems, fixes bug #88. |
…able by multiple instances. Fix bug #14
Remove static stuff, make the class more compatible with object oriented designs, fixes bug #14. |
Very good work! But I have one little question:
A succession maybe for a discussion:
|
Thank you for your kind words. About the public attributes. It is a great question and I'd appreciate your suggestions, my thinking is this: keep everything backward compatible (as much as possible), since the attributes did not appear as protected in the first place I let them be public. So we have both worlds: About PHP version support. Currently (matomo 4.x) requires PHP v7.2.5 or greater, maybe we need to keep that as a minimum? or is this project independent? Of course my personal preference is PHP v8.0 as a minimum because that is supported by Enterprise Linux distros (RHEL 8.x, Alma 8.x, Rocky 8.x, Oracle 8.x). Is there a review procedure for my changes? 🥲 |
I think, the Matomo-Project is not the Tracker. The code would be much better and easier with PHP 8+. The most of the popular PHP-projects need 8.x+ now cause its not safe to use older versions. |
Description:
I took the time to upgrade the code to current PHP 8.x coding standards but without causing any issues with older PHP versions.
The old code had a lot of issues with mixed types, like testing for empty on boolean values and expecting a string concatenation. I avoided doing changes to the code that did not directly relate to strict types, my main objective is to have a good starting point for the next generation of code. My next objective is to format the code to PSR standards, so the code is more readable.
Please let me know what you think about these changes.
Thank you.
Review