-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to implement custom taint type classes
Instead of just having a generic `TaintedCustom` for custom taint - this change allows plugins/extensions to register their own custom taint type classes. Examples ``` TaintTypeRegistry::getType('html'); // returns \Psalm\Issue\TaintedHtml TaintTypeRegistry::addType( 'my-type', \Example\TaintedMyType::class, TaintKindGroup::GROUP_INPUT, ); ```
- Loading branch information
Showing
29 changed files
with
326 additions
and
173 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
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,35 @@ | ||
<?php | ||
|
||
namespace Psalm\Issue; | ||
|
||
use Psalm\CodeLocation; | ||
|
||
final class TaintTypeFactory | ||
{ | ||
/** | ||
* @readonly | ||
*/ | ||
private TaintTypeRegistry $registry; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public function __construct(TaintTypeRegistry $registry) | ||
{ | ||
$this->registry = $registry; | ||
} | ||
|
||
/** | ||
* @param non-empty-string $type | ||
*/ | ||
public function create( | ||
string $type, | ||
CodeLocation $code_location, | ||
array $journey, | ||
string $journey_text | ||
): CodeIssue { | ||
/** @var TaintedInput $class_name */ | ||
$class_name = $this->registry->getType($type) ?? $this->registry->getDefaultType(); | ||
return new $class_name($class_name::MESSAGE, $code_location, $journey, $journey_text); | ||
} | ||
} |
Oops, something went wrong.