Skip to content

Allow installation of psalm 6, Drop PHP 8.0 support #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
- uses: ramsey/composer-install@v1
- run: composer check
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
"type": "psalm-plugin",
"license": "MIT",
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-simplexml": "*",
"vimeo/psalm": "5.*"
"vimeo/psalm": "^5.0.0|^6.0.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5.5",
"squizlabs/php_codesniffer": "^3.3",
"psalm/plugin-phpunit": "^0.18",
"weirdan/prophecy-shim": "^2.0",
"weirdan/codeception-psalm-module": "^0.13.1",
"codeception/codeception": "^4.1",
"behat/behat": "^3.11"
"phpunit/phpunit": "^10.5.40",
"squizlabs/php_codesniffer": "^3.11.3",
"psalm/plugin-phpunit": "^0.19.2",
"weirdan/prophecy-shim": "^2.0.2",
"weirdan/codeception-psalm-module": "^0.14.0",
"codeception/codeception": "^5.1.2",
"behat/behat": "^3.18.1"
},
"extra": {
"psalm": {
Expand Down
1 change: 1 addition & 0 deletions src/AllowInheritance.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Attribute;

/** @api */
#[Attribute(Attribute::TARGET_CLASS)]
final class AllowInheritance
{
Expand Down
22 changes: 1 addition & 21 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,20 @@
namespace Cspray\Phinal;

use PhpParser\Node;
use Psalm\Codebase;
use Psalm\CodeLocation;
use Psalm\IssueBuffer;
use Psalm\Plugin\EventHandler\AfterClassLikeAnalysisInterface;
use Psalm\Plugin\EventHandler\Event\AfterClassLikeAnalysisEvent;
use Psalm\StatementsSource;
use Psalm\Storage\ClassLikeStorage;
use SimpleXMLElement;
use Psalm\Plugin\PluginEntryPointInterface;
use Psalm\Plugin\RegistrationInterface;

/** @psalm-suppress UnusedClass */
class Plugin implements PluginEntryPointInterface, AfterClassLikeAnalysisInterface
{
/** @return void */
public function __invoke(RegistrationInterface $psalm, ?SimpleXMLElement $config = null): void
{
// This is plugin entry point. You can initialize things you need here,
// and hook them into psalm using RegistrationInterface
//
// Here's some examples:
// 1. Add a stub file
// ```php
// $psalm->addStubFile(__DIR__ . '/stubs/YourStub.php');
// ```
foreach ($this->getStubFiles() as $file) {
$psalm->addStubFile($file);
}

// Psalm allows arbitrary content to be stored under you plugin entry in
// its config file, psalm.xml, so your plugin users can put some configuration
// values there. They will be provided to your plugin entry point in $config
Expand All @@ -39,12 +25,6 @@ public function __invoke(RegistrationInterface $psalm, ?SimpleXMLElement $config
$psalm->registerHooksFromClass($this::class);
}

/** @return list<string> */
private function getStubFiles(): array
{
return glob(__DIR__ . '/stubs/*.phpstub') ?: [];
}

public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event)
{
$stmt = $event->getStmt();
Expand Down
Empty file removed stubs/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
* @SuppressWarnings(PHPMD)
* @psalm-suppress UndefinedTrait
* @psalm-suppress UnusedClass
*/
class AcceptanceTester extends \Codeception\Actor
{
Expand Down
1 change: 1 addition & 0 deletions tests/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// here you can define custom actions
// all public methods declared in helper class will be available in $I

/** @psalm-suppress UnusedClass */
class Acceptance extends \Codeception\Module
{
}
6 changes: 5 additions & 1 deletion tests/acceptance/MyTest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Feature: basics
"""
<?php

/** @psalm-suppress UnusedClass */
abstract class AbstractClass {}
"""
When I run Psalm
Expand All @@ -43,6 +44,7 @@ Feature: basics
"""
<?php

/** @psalm-suppress UnusedClass */
interface SomeInterface {}
"""
When I run Psalm
Expand All @@ -53,6 +55,7 @@ Feature: basics
"""
<?php

/** @psalm-suppress UnusedClass */
final class SomeFinalClass {}
"""
When I run Psalm
Expand All @@ -65,7 +68,7 @@ Feature: basics

interface SomeInterface {}

$class = new class implements SomeInterface {};
$_class = new class implements SomeInterface {};
"""
When I run Psalm
Then I see no errors
Expand All @@ -77,6 +80,7 @@ Feature: basics

use Cspray\Phinal\AllowInheritance;

/** @psalm-suppress UnusedClass */
#[AllowInheritance('We are allowing inheritance because we could not figure out how to use composition')]
class SomeClassThatGetsInherited {}
"""
Expand Down
Loading