Skip to content

Commit

Permalink
Implement forward compatible Clock-Interface
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
heiglandreas authored and jeromegamez committed Apr 20, 2022
1 parent 10c02d2 commit 731f4c9
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 27 deletions.
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -27,7 +28,6 @@
"Beste\\Clock\\": "src/Clock"
},
"files": [
"src/psr-polyfill.php",
"src/Clock.php"
]
},
Expand All @@ -40,7 +40,10 @@
"psr/clock-implementation": "1.0"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"scripts": {
"test": [
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ parameters:

tmpDir: .build/phpstan/

bootstrapFiles:
- ./src/psr-polyfill.php
2 changes: 1 addition & 1 deletion src/Clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Beste;

use Psr\Clock\ClockInterface;
use StellaMaris\Clock\ClockInterface;

interface Clock extends ClockInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clock/FrozenClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Beste\Clock;
use DateTimeImmutable;
use DateTimeZone;
use Psr\Clock\ClockInterface;
use StellaMaris\Clock\ClockInterface;

final class FrozenClock implements Clock
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clock/MinuteClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Beste\Clock;
use DateTimeImmutable;
use Psr\Clock\ClockInterface;
use StellaMaris\Clock\ClockInterface;

final class MinuteClock implements Clock
{
Expand Down
17 changes: 0 additions & 17 deletions src/psr-polyfill.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Clock/FrozenClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Beste\Clock\FrozenClock;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use StellaMaris\Clock\ClockInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Clock/MinuteClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Beste\Clock\MinuteClock;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use StellaMaris\Clock\ClockInterface;

/**
* @internal
Expand Down

0 comments on commit 731f4c9

Please sign in to comment.