1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Analyser;
4:
5: use PhpParser\Node;
6: use PHPStan\Node\VirtualNode;
7: use PHPStan\Reflection\SideEffects;
8: use PHPStan\Turbo\ShadowedByTurboExtension;
9:
10: /**
11: * @phpstan-type ImpurePointIdentifier = 'echo'|'die'|'exit'|'propertyAssign'|'propertyAssignByRef'|'propertyUnset'|'propertyHookCall'|'methodCall'|'new'|'functionCall'|'include'|'require'|'print'|'eval'|'superglobal'|'yield'|'yieldFrom'|'static'|'global'|'betweenPhpTags'|'shellExec'|'staticPropertyAccess'
12: * @api
13: */
14: #[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ImpurePoint.cpp')]
15: final class ImpurePoint
16: {
17:
18: /**
19: * @param Node\Expr|Node\Stmt|VirtualNode $node
20: * @param ImpurePointIdentifier $identifier
21: * @param SideEffects|null $sideEffects the side effects of the called function, null when unknown
22: */
23: public function __construct(
24: private Scope $scope,
25: private Node $node,
26: private string $identifier,
27: private string $description,
28: private bool $certain,
29: private ?SideEffects $sideEffects = null,
30: )
31: {
32: }
33:
34: public function getScope(): Scope
35: {
36: return $this->scope;
37: }
38:
39: /**
40: * @return Node\Expr|Node\Stmt|VirtualNode
41: */
42: public function getNode()
43: {
44: return $this->node;
45: }
46:
47: /**
48: * @return ImpurePointIdentifier
49: */
50: public function getIdentifier(): string
51: {
52: return $this->identifier;
53: }
54:
55: public function getDescription(): string
56: {
57: return $this->description;
58: }
59:
60: public function isCertain(): bool
61: {
62: return $this->certain;
63: }
64:
65: public function getSideEffects(): ?SideEffects
66: {
67: return $this->sideEffects;
68: }
69:
70: }
71: