u01jmg3 / ics-parser

Parser for iCalendar Events • PHP 8+, 7 (≥ 7.4), 5 (≥ 5.6)
MIT License
439 stars 144 forks source link

Bump minimum version to PHP 7.4 #308

Closed tacman closed 2 years ago

tacman commented 2 years ago

Description of the Issue:

We can't update to the latest version of phpunit and support PHP 5.

Steps to Reproduce:

tac@pop-os:~/survos/bundles/ics-parser$ composer test
> phpunit --colors=always
PHP Warning:  Private methods cannot be final as they are never overridden by other classes in /home/tac/survos/bundles/ics-parser/vendor/phpunit/phpunit/src/Util/Configuration.php on line 162
PHP Fatal error:  Cannot acquire reference to $GLOBALS in /home/tac/survos/bundles/ics-parser/vendor/phpunit/phpunit/src/Util/Configuration.php on line 504
Script phpunit --colors=always handling the test event returned with error code 255
tacman commented 2 years ago

On a related note, I used rector to update the code to PHP 7.4, and it went smoothly. Although it's not necessary, PHP 7.4 allows for typed properties, which makes static analysis using tool like phpstan easier. Indeed, running phpstan on level 2 showed some issues. For example

    /**
     * Parses a duration and applies it to a date
     *
     * @param  string $date
     * @param  string $duration
     * @param  string $format
     * @return integer|\DateTime
     */
    protected function parseDuration($date, $duration, $format = self::UNIX_FORMAT)
    {
        $dateTime = date_create($date);
        $dateTime->modify(sprintf('%s year', $duration->y));

$duration is marked as a string, but it's obviously an object, and typing it in PHP would ultimately be a better practice. Not sure if it's worth the effort to make these changes, though.

u01jmg3 commented 2 years ago

See PR #309, 2c8cf55