From 731f4c9651a00e0d93fee0b2f02855413879d802 Mon Sep 17 00:00:00 2001 From: Andreas Heigl Date: Sun, 17 Apr 2022 12:13:00 +0200 Subject: [PATCH] Implement forward compatible Clock-Interface The stella-maris/clock package provides an interface based on the currently proposed status of PSR20. Due to the inactivity of the PSR20 working group this is a way to already provide interoperability while still maintaining forward compatibility. When the current status of PSR20 will be released at one point in time the stella-maris/clock package will extend the PSR20 interface so that this package becomes immeadiately PSR20 compatible without any further work necessary. In the long run the stella-maris/clock package will then be marked deprecated so that people can then use the PSR20 provided implementation. Should the implementation of PSR20 change between now and a possible release then this interface will still exist and a possible implementation will need more code-changes anyhow so this interface will still provide some way of interoperability. The implementation of the PSR20 polyfill has been moved to the stella-maris/clock interface which can be implemented independentyl from PSR20 and might allow some interoperability before the working group of the FIG manages to decide upon something. --- composer.json | 9 ++++++--- phpstan.neon.dist | 2 -- src/Clock.php | 2 +- src/Clock/FrozenClock.php | 2 +- src/Clock/MinuteClock.php | 2 +- src/psr-polyfill.php | 17 ----------------- tests/Clock/FrozenClockTest.php | 2 +- tests/Clock/MinuteClockTest.php | 2 +- 8 files changed, 11 insertions(+), 27 deletions(-) delete mode 100644 src/psr-polyfill.php diff --git a/composer.json b/composer.json index 8f5429b..f8b7edf 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ } ], "require": { - "php": "~7.4.0 || ~8.0.0 || ~8.1.0" + "php": "~7.4.0 || ~8.0.0 || ~8.1.0", + "stella-maris/clock": "^0.1.4" }, "require-dev": { "phpstan/extension-installer": "^1.1", @@ -27,7 +28,6 @@ "Beste\\Clock\\": "src/Clock" }, "files": [ - "src/psr-polyfill.php", "src/Clock.php" ] }, @@ -40,7 +40,10 @@ "psr/clock-implementation": "1.0" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true + } }, "scripts": { "test": [ diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 2712cf2..58f5ef4 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,5 +7,3 @@ parameters: tmpDir: .build/phpstan/ - bootstrapFiles: - - ./src/psr-polyfill.php diff --git a/src/Clock.php b/src/Clock.php index 5693d1d..02d9f71 100644 --- a/src/Clock.php +++ b/src/Clock.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Beste; -use Psr\Clock\ClockInterface; +use StellaMaris\Clock\ClockInterface; interface Clock extends ClockInterface { diff --git a/src/Clock/FrozenClock.php b/src/Clock/FrozenClock.php index 40f2895..f2bf651 100644 --- a/src/Clock/FrozenClock.php +++ b/src/Clock/FrozenClock.php @@ -7,7 +7,7 @@ namespace Beste\Clock; use Beste\Clock; use DateTimeImmutable; use DateTimeZone; -use Psr\Clock\ClockInterface; +use StellaMaris\Clock\ClockInterface; final class FrozenClock implements Clock { diff --git a/src/Clock/MinuteClock.php b/src/Clock/MinuteClock.php index 309545f..a7b5a31 100644 --- a/src/Clock/MinuteClock.php +++ b/src/Clock/MinuteClock.php @@ -6,7 +6,7 @@ namespace Beste\Clock; use Beste\Clock; use DateTimeImmutable; -use Psr\Clock\ClockInterface; +use StellaMaris\Clock\ClockInterface; final class MinuteClock implements Clock { diff --git a/src/psr-polyfill.php b/src/psr-polyfill.php deleted file mode 100644 index 1a96e74..0000000 --- a/src/psr-polyfill.php +++ /dev/null @@ -1,17 +0,0 @@ -