Skip to content

Commit

Permalink
Lock event classes
Browse files Browse the repository at this point in the history
This makes all event (`Psalm\Plugin\EventHandler\Event\*`) classes
`final`, allowing us to add methods to them without breaking BC.

Additionally all constructors of those classes are made `@internal` as
plugins are not supposed to emit events.
  • Loading branch information
weirdan committed Jan 26, 2022
1 parent 1cc9d1c commit 7503f23
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/Psalm/Plugin/EventHandler/Event/AddRemoveTaintsEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Psalm\Context;
use Psalm\StatementsSource;

class AddRemoveTaintsEvent
final class AddRemoveTaintsEvent
{
/**
* @var Expr
Expand All @@ -28,6 +28,7 @@ class AddRemoveTaintsEvent

/**
* Called after an expression has been checked
* @internal
*/
public function __construct(
Expr $expr,
Expand Down
3 changes: 2 additions & 1 deletion src/Psalm/Plugin/EventHandler/Event/AfterAnalysisEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Psalm\Internal\Analyzer\IssueData;
use Psalm\SourceControl\SourceControlInfo;

class AfterAnalysisEvent
final class AfterAnalysisEvent
{
/**
* @var Codebase
Expand All @@ -29,6 +29,7 @@ class AfterAnalysisEvent
* Called after analysis is complete
*
* @param array<string, list<IssueData>> $issues
* @internal
*/
public function __construct(
Codebase $codebase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psalm\StatementsSource;
use Psalm\Storage\ClassLikeStorage;

class AfterClassLikeAnalysisEvent
final class AfterClassLikeAnalysisEvent
{
/**
* @var Node\Stmt\ClassLike
Expand All @@ -35,6 +35,7 @@ class AfterClassLikeAnalysisEvent
* Called after a statement has been checked
*
* @param FileManipulation[] $file_replacements
* @internal
*/
public function __construct(
Node\Stmt\ClassLike $stmt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Psalm\FileManipulation;
use Psalm\StatementsSource;

class AfterClassLikeExistenceCheckEvent
final class AfterClassLikeExistenceCheckEvent
{
/**
* @var string
Expand All @@ -32,6 +32,7 @@ class AfterClassLikeExistenceCheckEvent

/**
* @param FileManipulation[] $file_replacements
* @internal
*/
public function __construct(
string $fq_class_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psalm\FileSource;
use Psalm\Storage\ClassLikeStorage;

class AfterClassLikeVisitEvent
final class AfterClassLikeVisitEvent
{
/**
* @var ClassLike
Expand All @@ -33,6 +33,7 @@ class AfterClassLikeVisitEvent

/**
* @param FileManipulation[] $file_replacements
* @internal
*/
public function __construct(
ClassLike $stmt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Psalm\Codebase;

class AfterCodebasePopulatedEvent
final class AfterCodebasePopulatedEvent
{
/**
* @var Codebase
Expand All @@ -13,6 +13,7 @@ class AfterCodebasePopulatedEvent

/**
* Called after codebase has been populated
* @internal
*/
public function __construct(Codebase $codebase)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Psalm\Context;
use Psalm\StatementsSource;

class AfterEveryFunctionCallAnalysisEvent
final class AfterEveryFunctionCallAnalysisEvent
{
/**
* @var FuncCall
Expand All @@ -30,6 +30,7 @@ class AfterEveryFunctionCallAnalysisEvent
*/
private $codebase;

/** @internal */
public function __construct(
FuncCall $expr,
string $function_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psalm\FileManipulation;
use Psalm\StatementsSource;

class AfterExpressionAnalysisEvent
final class AfterExpressionAnalysisEvent
{
/**
* @var Expr
Expand All @@ -35,6 +35,7 @@ class AfterExpressionAnalysisEvent
* Called after an expression has been checked
*
* @param FileManipulation[] $file_replacements
* @internal
*/
public function __construct(
Expr $expr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psalm\StatementsSource;
use Psalm\Storage\FileStorage;

class AfterFileAnalysisEvent
final class AfterFileAnalysisEvent
{
/**
* @var StatementsSource
Expand All @@ -35,6 +35,7 @@ class AfterFileAnalysisEvent
* Called after a file has been checked
*
* @param array<Stmt> $stmts
* @internal
*/
public function __construct(
StatementsSource $statements_source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Psalm\StatementsSource;
use Psalm\Type\Union;

class AfterFunctionCallAnalysisEvent
final class AfterFunctionCallAnalysisEvent
{
/**
* @var FuncCall
Expand Down Expand Up @@ -43,6 +43,7 @@ class AfterFunctionCallAnalysisEvent
/**
* @param non-empty-string $function_id
* @param FileManipulation[] $file_replacements
* @internal
*/
public function __construct(
FuncCall $expr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Psalm\StatementsSource;
use Psalm\Storage\FunctionLikeStorage;

class AfterFunctionLikeAnalysisEvent
final class AfterFunctionLikeAnalysisEvent
{
/**
* @var Node\FunctionLike
Expand Down Expand Up @@ -45,6 +45,7 @@ class AfterFunctionLikeAnalysisEvent
* Called after a statement has been checked
*
* @param FileManipulation[] $file_replacements
* @internal
*/
public function __construct(
Node\FunctionLike $stmt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Psalm\StatementsSource;
use Psalm\Type\Union;

class AfterMethodCallAnalysisEvent
final class AfterMethodCallAnalysisEvent
{
/**
* @var MethodCall|StaticCall
Expand Down Expand Up @@ -53,6 +53,7 @@ class AfterMethodCallAnalysisEvent
/**
* @param MethodCall|StaticCall $expr
* @param FileManipulation[] $file_replacements
* @internal
*/
public function __construct(
Expr $expr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psalm\FileManipulation;
use Psalm\StatementsSource;

class AfterStatementAnalysisEvent
final class AfterStatementAnalysisEvent
{
/**
* @var Stmt
Expand All @@ -35,6 +35,7 @@ class AfterStatementAnalysisEvent
* Called after a statement has been checked
*
* @param FileManipulation[] $file_replacements
* @internal
*/
public function __construct(
Stmt $stmt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Psalm\StatementsSource;
use Psalm\Storage\FileStorage;

class BeforeFileAnalysisEvent
final class BeforeFileAnalysisEvent
{
/**
* @var StatementsSource
Expand All @@ -28,6 +28,7 @@ class BeforeFileAnalysisEvent

/**
* Called before a file has been checked
* @internal
*/
public function __construct(
StatementsSource $statements_source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Psalm\StatementsSource;

class FunctionExistenceProviderEvent
final class FunctionExistenceProviderEvent
{
/**
* @var StatementsSource
Expand All @@ -19,6 +19,8 @@ class FunctionExistenceProviderEvent
* Use this hook for informing whether or not a global function exists. If you know the function does
* not exist, return false. If you aren't sure if it exists or not, return null and the default analysis
* will continue to determine if the function actually exists.
*
* @internal
*/
public function __construct(
StatementsSource $statements_source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Psalm\Context;
use Psalm\StatementsSource;

class FunctionParamsProviderEvent
final class FunctionParamsProviderEvent
{
/**
* @var StatementsSource
Expand All @@ -32,6 +32,7 @@ class FunctionParamsProviderEvent

/**
* @param list<PhpParser\Node\Arg> $call_args
* @internal
*/
public function __construct(
StatementsSource $statements_source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Psalm\Context;
use Psalm\StatementsSource;

class FunctionReturnTypeProviderEvent
final class FunctionReturnTypeProviderEvent
{
/**
* @var StatementsSource
Expand Down Expand Up @@ -36,6 +36,7 @@ class FunctionReturnTypeProviderEvent
* if something should be returned, but can't be more specific.
*
* @param non-empty-string $function_id
* @internal
*/
public function __construct(
StatementsSource $statements_source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Psalm\CodeLocation;
use Psalm\StatementsSource;

class MethodExistenceProviderEvent
final class MethodExistenceProviderEvent
{
/**
* @var string
Expand All @@ -28,6 +28,8 @@ class MethodExistenceProviderEvent
* Use this hook for informing whether or not a method exists on a given object. If you know the method does
* not exist, return false. If you aren't sure if it exists or not, return null and the default analysis will
* continue to determine if the method actually exists.
*
* @internal
*/
public function __construct(
string $fq_classlike_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Psalm\Context;
use Psalm\StatementsSource;

class MethodParamsProviderEvent
final class MethodParamsProviderEvent
{
/**
* @var string
Expand Down Expand Up @@ -36,6 +36,7 @@ class MethodParamsProviderEvent

/**
* @param list<PhpParser\Node\Arg> $call_args
* @internal
*/
public function __construct(
string $fq_classlike_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psalm\StatementsSource;
use Psalm\Type\Union;

class MethodReturnTypeProviderEvent
final class MethodReturnTypeProviderEvent
{
/**
* @var StatementsSource
Expand Down Expand Up @@ -56,6 +56,8 @@ class MethodReturnTypeProviderEvent
* @param ?array<Union> $template_type_parameters
* @param lowercase-string $method_name_lowercase
* @param lowercase-string $called_method_name_lowercase
*
* @internal
*/
public function __construct(
StatementsSource $source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Psalm\Context;
use Psalm\StatementsSource;

class MethodVisibilityProviderEvent
final class MethodVisibilityProviderEvent
{
/**
* @var StatementsSource
Expand All @@ -29,6 +29,7 @@ class MethodVisibilityProviderEvent
*/
private $code_location;

/** @internal */
public function __construct(
StatementsSource $source,
string $fq_classlike_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Psalm\Context;
use Psalm\StatementsSource;

class PropertyExistenceProviderEvent
final class PropertyExistenceProviderEvent
{
/**
* @var string
Expand Down Expand Up @@ -38,6 +38,7 @@ class PropertyExistenceProviderEvent
* not exist, return false. If you aren't sure if it exists or not, return null and the default analysis will
* continue to determine if the property actually exists.
*
* @internal
*/
public function __construct(
string $fq_classlike_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Psalm\Context;
use Psalm\StatementsSource;

class PropertyTypeProviderEvent
final class PropertyTypeProviderEvent
{
/**
* @var string
Expand All @@ -28,6 +28,7 @@ class PropertyTypeProviderEvent
*/
private $context;

/** @internal */
public function __construct(
string $fq_classlike_name,
string $property_name,
Expand Down

0 comments on commit 7503f23

Please sign in to comment.