-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
171917c
commit ec415a7
Showing
11 changed files
with
252 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\EventFacadeIsSealedException; | ||
use PHPUnit\Event\Facade; | ||
use PHPUnit\Event\Test\DeprecationTriggered; | ||
use PHPUnit\Event\Test\PhpunitDeprecationTriggered; | ||
use PHPUnit\Event\UnknownSubscriberTypeException; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class Collector | ||
{ | ||
/** | ||
* @psalm-var list<non-empty-string> | ||
*/ | ||
private array $deprecations = []; | ||
|
||
/** | ||
* @psalm-var list<non-empty-string> | ||
*/ | ||
private array $phpunitDeprecations = []; | ||
|
||
/** | ||
* @throws EventFacadeIsSealedException | ||
* @throws UnknownSubscriberTypeException | ||
*/ | ||
public function __construct(Facade $facade) | ||
{ | ||
$facade->registerSubscribers( | ||
new TestPreparedSubscriber($this), | ||
new TestTriggeredDeprecationSubscriber($this), | ||
new TestTriggeredPhpunitDeprecationSubscriber($this), | ||
); | ||
} | ||
|
||
/** | ||
* @psalm-return list<non-empty-string> | ||
*/ | ||
public function deprecations(): array | ||
{ | ||
return $this->deprecations; | ||
} | ||
|
||
/** | ||
* @psalm-return list<non-empty-string> | ||
*/ | ||
public function phpunitDeprecations(): array | ||
{ | ||
return $this->phpunitDeprecations; | ||
} | ||
|
||
public function testPrepared(): void | ||
{ | ||
$this->deprecations = []; | ||
$this->phpunitDeprecations = []; | ||
} | ||
|
||
public function testTriggeredDeprecation(DeprecationTriggered $event): void | ||
{ | ||
$this->deprecations[] = $event->message(); | ||
} | ||
|
||
public function testTriggeredPhpunitDeprecation(PhpunitDeprecationTriggered $event): void | ||
{ | ||
$this->phpunitDeprecations[] = $event->message(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\EventFacadeIsSealedException; | ||
use PHPUnit\Event\Facade as EventFacade; | ||
use PHPUnit\Event\UnknownSubscriberTypeException; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class Facade | ||
{ | ||
private static ?Collector $collector = null; | ||
|
||
/** | ||
* @throws EventFacadeIsSealedException | ||
* @throws UnknownSubscriberTypeException | ||
*/ | ||
public static function init(): void | ||
{ | ||
self::collector(); | ||
} | ||
|
||
/** | ||
* @psalm-return list<non-empty-string> | ||
*/ | ||
public static function deprecations(): array | ||
{ | ||
return self::collector()->deprecations(); | ||
} | ||
|
||
/** | ||
* @psalm-return list<non-empty-string> | ||
*/ | ||
public static function phpunitDeprecations(): array | ||
{ | ||
return self::collector()->phpunitDeprecations(); | ||
} | ||
|
||
/** | ||
* @throws EventFacadeIsSealedException | ||
* @throws UnknownSubscriberTypeException | ||
*/ | ||
private static function collector(): Collector | ||
{ | ||
if (self::$collector === null) { | ||
self::$collector = new Collector(EventFacade::instance()); | ||
} | ||
|
||
return self::$collector; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
abstract class Subscriber | ||
{ | ||
private readonly Collector $collector; | ||
|
||
public function __construct(Collector $collector) | ||
{ | ||
$this->collector = $collector; | ||
} | ||
|
||
protected function collector(): Collector | ||
{ | ||
return $this->collector; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Runner/DeprecationCollector/Subscriber/TestPreparedSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\Test\Prepared; | ||
use PHPUnit\Event\Test\PreparedSubscriber; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class TestPreparedSubscriber extends Subscriber implements PreparedSubscriber | ||
{ | ||
public function notify(Prepared $event): void | ||
{ | ||
$this->collector()->testPrepared(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Runner/DeprecationCollector/Subscriber/TestTriggeredDeprecationSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\Test\DeprecationTriggered; | ||
use PHPUnit\Event\Test\DeprecationTriggeredSubscriber; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class TestTriggeredDeprecationSubscriber extends Subscriber implements DeprecationTriggeredSubscriber | ||
{ | ||
public function notify(DeprecationTriggered $event): void | ||
{ | ||
$this->collector()->testTriggeredDeprecation($event); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Runner/DeprecationCollector/Subscriber/TestTriggeredPhpunitDeprecationSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\Test\PhpunitDeprecationTriggered; | ||
use PHPUnit\Event\Test\PhpunitDeprecationTriggeredSubscriber; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class TestTriggeredPhpunitDeprecationSubscriber extends Subscriber implements PhpunitDeprecationTriggeredSubscriber | ||
{ | ||
public function notify(PhpunitDeprecationTriggered $event): void | ||
{ | ||
$this->collector()->testTriggeredPhpunitDeprecation($event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters