1. Go to this page and download the library: Download simtel/phpstan-rules library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener]
class UserRegisteredEventListener
{
// Event listener implementation
}
public function getUser(): User
{
return $this->user;
}
/**
* @return User
*/
public function getUser(): User // Redundant @return annotation
{
return $this->user;
}
namespace Simtel\PHPStanRules\Rule;
use PHPStan\Rules\Rule;
/**
* @implements Rule<NodeType>
*/
final class YourNewRule implements Rule
{
public function getNodeType(): string
{
return NodeType::class;
}
public function processNode(Node $node, Scope $scope): array
{
// Rule implementation
}
}
namespace Simtel\PHPStanRules\Tests\Rules;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
class YourNewRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new YourNewRule();
}
public function testValidCase(): void
{
$this->analyse([__DIR__ . '/../Fixture/Valid.php'], []);
}
}