Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @implements Rule<ClassPropertiesNode>
- */
- class ClassPropertiesNullabilityRule implements Rule
- {
- private Standard $printer;
- public function __construct(\PhpParser\PrettyPrinter\Standard $printer)
- {
- $this->printer = $printer;
- }
- public function getNodeType(): string
- {
- return ClassPropertiesNode::class;
- }
- /**
- * @param ClassPropertiesNode $node
- * @return RuleError[]
- */
- public function processNode(Node $node, Scope $scope): array
- {
- foreach ($node->getPropertyUsages() as $propertyUsage) {
- if (!$propertyUsage instanceof PropertyWrite) {
- continue;
- }
- $parentNode = $propertyUsage->getFetch()->getAttribute('parent');
- echo $this->printer->prettyPrint([$parentNode]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment