Skip to content

Commit

Permalink
Merge pull request #111 from weirdan/upgrade-psalm-interfaces
Browse files Browse the repository at this point in the history
Upgrade Psalm interfaces
  • Loading branch information
weirdan authored Jun 6, 2021
2 parents 31d15bb + 8d7446e commit 1ce1ef2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"ext-simplexml": "*",
"composer/semver": "^1.4 || ^2.0 || ^3.0",
"composer/package-versions-deprecated": "^1.10",
"vimeo/psalm": "dev-master || dev-4.x || ^4.0"
"vimeo/psalm": "dev-master || dev-4.x || ^4.5"
},
"conflict": {
"phpunit/phpunit": "<7.5"
Expand Down
47 changes: 23 additions & 24 deletions src/Hooks/TestCaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
use Psalm\Codebase;
use Psalm\DocComment;
use Psalm\Exception\DocblockParseException;
use Psalm\FileSource;
use Psalm\IssueBuffer;
use Psalm\Issue;
use Psalm\PhpUnitPlugin\VersionUtils;
use Psalm\Plugin\Hook\AfterClassLikeAnalysisInterface;
use Psalm\Plugin\Hook\AfterClassLikeVisitInterface;
use Psalm\Plugin\Hook\AfterCodebasePopulatedInterface;
use Psalm\StatementsSource;
use Psalm\Plugin\EventHandler\AfterClassLikeAnalysisInterface;
use Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface;
use Psalm\Plugin\EventHandler\AfterCodebasePopulatedInterface;
use Psalm\Plugin\EventHandler\Event\AfterClassLikeAnalysisEvent;
use Psalm\Plugin\EventHandler\Event\AfterClassLikeVisitEvent;
use Psalm\Plugin\EventHandler\Event\AfterCodebasePopulatedEvent;
use Psalm\Storage\ClassLikeStorage;
use Psalm\Type;
use Psalm\Type\Atomic\TNull;
Expand All @@ -31,8 +32,10 @@ class TestCaseHandler implements
/**
* {@inheritDoc}
*/
public static function afterCodebasePopulated(Codebase $codebase)
public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event)
{
$codebase = $event->getCodebase();

foreach ($codebase->classlike_storage_provider->getAll() as $name => $storage) {
$meta = (array) ($storage->custom_metadata[__NAMESPACE__] ?? []);
if ($codebase->classExtends($name, 'PHPUnit\Framework\TestCase') && ($meta['hasInitializers'] ?? false)) {
Expand Down Expand Up @@ -68,15 +71,13 @@ private static function getDescendants(Codebase $codebase, string $name): array
/**
* {@inheritDoc}
*/
public static function afterClassLikeVisit(
ClassLike $stmt,
ClassLikeStorage $storage,
FileSource $statements_source,
Codebase $codebase,
array &$file_replacements = []
) {
$class_node = $stmt;
$class_storage = $storage;
public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event)
{
$class_node = $event->getStmt();
$class_storage = $event->getStorage();
$statements_source = $event->getStatementsSource();
$codebase = $event->getCodebase();

if (self::hasInitializers($class_storage, $class_node)) {
$class_storage->custom_metadata[__NAMESPACE__] = ['hasInitializers' => true];
}
Expand All @@ -103,15 +104,13 @@ public static function afterClassLikeVisit(
/**
* {@inheritDoc}
*/
public static function afterStatementAnalysis(
ClassLike $stmt,
ClassLikeStorage $classlike_storage,
StatementsSource $statements_source,
Codebase $codebase,
array &$file_replacements = []
) {
$class_node = $stmt;
$class_storage = $classlike_storage;
public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event)
{
$class_node = $event->getStmt();
$class_storage = $event->getClasslikeStorage();
$codebase = $event->getCodebase();
$statements_source = $event->getStatementsSource();

if (!$codebase->classExtends($class_storage->name, 'PHPUnit\Framework\TestCase')) {
return null;
}
Expand Down

0 comments on commit 1ce1ef2

Please sign in to comment.