-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9725 from tuqqu/before-expr-analysis
Introduce BeforeExpressionAnalysisEvent
- Loading branch information
Showing
4 changed files
with
180 additions
and
15 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
15 changes: 15 additions & 0 deletions
15
src/Psalm/Plugin/EventHandler/BeforeExpressionAnalysisInterface.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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Psalm\Plugin\EventHandler; | ||
|
||
use Psalm\Plugin\EventHandler\Event\BeforeExpressionAnalysisEvent; | ||
|
||
interface BeforeExpressionAnalysisInterface | ||
{ | ||
/** | ||
* Called before an expression is checked | ||
*/ | ||
public static function beforeExpressionAnalysis(BeforeExpressionAnalysisEvent $event): ?bool; | ||
} |
79 changes: 79 additions & 0 deletions
79
src/Psalm/Plugin/EventHandler/Event/BeforeExpressionAnalysisEvent.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,79 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Psalm\Plugin\EventHandler\Event; | ||
|
||
use PhpParser\Node\Expr; | ||
use Psalm\Codebase; | ||
use Psalm\Context; | ||
use Psalm\FileManipulation; | ||
use Psalm\StatementsSource; | ||
|
||
final class BeforeExpressionAnalysisEvent | ||
{ | ||
private Expr $expr; | ||
private Context $context; | ||
private StatementsSource $statements_source; | ||
private Codebase $codebase; | ||
/** | ||
* @var list<FileManipulation> | ||
*/ | ||
private array $file_replacements; | ||
|
||
/** | ||
* Called before an expression is checked | ||
* | ||
* @param list<FileManipulation> $file_replacements | ||
* @internal | ||
*/ | ||
public function __construct( | ||
Expr $expr, | ||
Context $context, | ||
StatementsSource $statements_source, | ||
Codebase $codebase, | ||
array $file_replacements = [] | ||
) { | ||
$this->expr = $expr; | ||
$this->context = $context; | ||
$this->statements_source = $statements_source; | ||
$this->codebase = $codebase; | ||
$this->file_replacements = $file_replacements; | ||
} | ||
|
||
public function getExpr(): Expr | ||
{ | ||
return $this->expr; | ||
} | ||
|
||
public function getContext(): Context | ||
{ | ||
return $this->context; | ||
} | ||
|
||
public function getStatementsSource(): StatementsSource | ||
{ | ||
return $this->statements_source; | ||
} | ||
|
||
public function getCodebase(): Codebase | ||
{ | ||
return $this->codebase; | ||
} | ||
|
||
/** | ||
* @return list<FileManipulation> | ||
*/ | ||
public function getFileReplacements(): array | ||
{ | ||
return $this->file_replacements; | ||
} | ||
|
||
/** | ||
* @param list<FileManipulation> $file_replacements | ||
*/ | ||
public function setFileReplacements(array $file_replacements): void | ||
{ | ||
$this->file_replacements = $file_replacements; | ||
} | ||
} |