2 Commits
Author SHA1 Message Date
Jérôme Gamez 98d1e6f1d8 Release 2.0.0 2022-04-20 16:28:31 +02:00
Andreas Heigl 731f4c9651 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.
2022-04-20 16:21:40 +02:00
9 changed files with 14 additions and 30 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
# CHANGELOG # CHANGELOG
## [Unreleased] ## 2.0.0 - 2022-04-20
This release introduces a compatibility layer with the PSR-20 draft, allowing us to already
get some interoperability by depending on a shared interface.
## 1.0.0 - 2021-12-10 ## 1.0.0 - 2021-12-10
Initial Release Initial Release
[Unreleased]: https://github.com/beste/clock/compare/1.0.0...main
+6 -3
View File
@@ -11,7 +11,8 @@
} }
], ],
"require": { "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": { "require-dev": {
"phpstan/extension-installer": "^1.1", "phpstan/extension-installer": "^1.1",
@@ -27,7 +28,6 @@
"Beste\\Clock\\": "src/Clock" "Beste\\Clock\\": "src/Clock"
}, },
"files": [ "files": [
"src/psr-polyfill.php",
"src/Clock.php" "src/Clock.php"
] ]
}, },
@@ -40,7 +40,10 @@
"psr/clock-implementation": "1.0" "psr/clock-implementation": "1.0"
}, },
"config": { "config": {
"sort-packages": true "sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
}, },
"scripts": { "scripts": {
"test": [ "test": [
-2
View File
@@ -7,5 +7,3 @@ parameters:
tmpDir: .build/phpstan/ tmpDir: .build/phpstan/
bootstrapFiles:
- ./src/psr-polyfill.php
+1 -1
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Beste; namespace Beste;
use Psr\Clock\ClockInterface; use StellaMaris\Clock\ClockInterface;
interface Clock extends ClockInterface interface Clock extends ClockInterface
{ {
+1 -1
View File
@@ -7,7 +7,7 @@ namespace Beste\Clock;
use Beste\Clock; use Beste\Clock;
use DateTimeImmutable; use DateTimeImmutable;
use DateTimeZone; use DateTimeZone;
use Psr\Clock\ClockInterface; use StellaMaris\Clock\ClockInterface;
final class FrozenClock implements Clock final class FrozenClock implements Clock
{ {
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Beste\Clock;
use Beste\Clock; use Beste\Clock;
use DateTimeImmutable; use DateTimeImmutable;
use Psr\Clock\ClockInterface; use StellaMaris\Clock\ClockInterface;
final class MinuteClock implements Clock final class MinuteClock implements Clock
{ {
-17
View File
@@ -1,17 +0,0 @@
<?php
namespace Psr\Clock;
if (class_exists('\Psr\Clock\ClockInterface')) {
return;
}
use DateTimeImmutable;
interface ClockInterface
{
/**
* Returns the current time as a DateTimeImmutable Object
*/
public function now(): DateTimeImmutable;
}
+1 -1
View File
@@ -7,7 +7,7 @@ namespace Beste\Clock\Tests;
use Beste\Clock\FrozenClock; use Beste\Clock\FrozenClock;
use DateTimeImmutable; use DateTimeImmutable;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface; use StellaMaris\Clock\ClockInterface;
/** /**
* @internal * @internal
+1 -1
View File
@@ -7,7 +7,7 @@ namespace Beste\Clock\Tests;
use Beste\Clock\MinuteClock; use Beste\Clock\MinuteClock;
use DateTimeImmutable; use DateTimeImmutable;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface; use StellaMaris\Clock\ClockInterface;
/** /**
* @internal * @internal