Repository navigation
PHP 7.4 types - #586
PHP 7.4 types#586
Conversation
* Require PHP 7.4 * Add typing everywhere possible * Small internal improvements Signed-off-by: Thomas Citharel <[email protected]>
Signed-off-by: Thomas Citharel <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #586 +/- ##
============================================
+ Coverage 98.35% 98.53% +0.18%
+ Complexity 1897 1865 -32
============================================
Files 71 71
Lines 4550 4159 -391
============================================
- Hits 4475 4098 -377
+ Misses 75 61 -14
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Most of this code is a rebase of code that @tcitworld has handed over to me. I am looking through to see what else can/needs to be done. That will take "some time" because there is a lot to look at... |
| public static function parseDuration($duration, $asString = false) | ||
| public static function parseDuration(string $duration): DateInterval |
There was a problem hiding this comment.
ToDo: understand why we can remove the $asString parameter here. This parameter is never used internally, but people using sabre/vobject could call this Sabre\VObject\DateTimeParser::parseDuration static function and use the $asString parameter.
@tcitworld do you remember why you removed the parameter? (and added parseDurationAsString below)
There was a problem hiding this comment.
I probably thought it would be nicer to have consistent parameters types and return types. Sounds a sane BC.
There was a problem hiding this comment.
I will start making notes for the release notes - need to mention this sort of stuff.
There was a problem hiding this comment.
we can do such changes more easily/with confidence when we declare the classes which are not designed to be subclassed as final.
2b2f11a to
45f6740
Compare
|
@staabm @tcitworld IMO this is all good, and as close as I can see to implementing all the PHP 7.4 features throughout the code. Please let me know what you think (I know that you will not likely to be able to look at every line of the diffs!). If you are OK with this, then I could make a major version 5.0.0-RC1 which would not be an official release, but I (and anyone else) could try it in their projects and give feedback about anything that explodes unexpectedly. |
staabm
left a comment
There was a problem hiding this comment.
I think we should level up phpstan in a future PR.
| @@ -15,23 +17,19 @@ class BirthdayCalendarGenerator | |||
| { | |||
| /** | |||
| * Input objects. | |||
There was a problem hiding this comment.
defining array key/value brings a lot of benefits. in the next PR we maybe should increase the phpstan level, so these types are required
| * Input objects. | |
| * Input objects. | |
| * | |
| * @var list<Component\VCard> |
but feel free to do these in a followup as this PR already is pretty big
There was a problem hiding this comment.
yes, I will followup with a next PR...
| public static function parseDuration($duration, $asString = false) | ||
| public static function parseDuration(string $duration): DateInterval |
There was a problem hiding this comment.
we can do such changes more easily/with confidence when we declare the classes which are not designed to be subclassed as final.
|
Merged - I will followup an increased |
Add parameter and return types etc. that are available in PHP 7,4 and upwards.
Drop support for PHP older than 7.4
code from @tcitworld plus cs-fixer changes.
I went through the code and added whatever else that I could see for declaring types in PHP 7.4
And went through the test code (see last commit) to add type declarations, and make use of newer assert methods that my IDE suggested now exist.