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 #7530 from ohader/issue-7528
- Loading branch information
Showing
6 changed files
with
138 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Psalm\Plugin\EventHandler; | ||
|
||
use Psalm\Plugin\EventHandler\Event\BeforeAddIssueEvent; | ||
|
||
interface BeforeAddIssueInterface | ||
{ | ||
/** | ||
* Called before adding a code issue. | ||
* | ||
* Note that event handlers are called in the order they were registered, and thus | ||
* the handler registered earlier may prevent subsequent handlers from running by | ||
* returning a boolean value. | ||
* | ||
* @param BeforeAddIssueEvent $event | ||
* @return null|bool $event How and whether to continue: | ||
* + `null` continues with next event handler | ||
* + `true` stops event handling & keeps issue | ||
* + `false` stops event handling & ignores issue | ||
*/ | ||
public static function beforeAddIssue(BeforeAddIssueEvent $event): ?bool; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Psalm/Plugin/EventHandler/Event/BeforeAddIssueEvent.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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Psalm\Plugin\EventHandler\Event; | ||
|
||
use Psalm\Issue\CodeIssue; | ||
|
||
final class BeforeAddIssueEvent | ||
{ | ||
/** | ||
* @var CodeIssue | ||
*/ | ||
private CodeIssue $issue; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private bool $fixable; | ||
|
||
/** @internal */ | ||
public function __construct(CodeIssue $issue, bool $fixable) | ||
{ | ||
$this->issue = $issue; | ||
$this->fixable = $fixable; | ||
} | ||
|
||
public function getIssue(): CodeIssue | ||
{ | ||
return $this->issue; | ||
} | ||
|
||
public function isFixable(): bool | ||
{ | ||
return $this->fixable; | ||
} | ||
} |
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