*/ final class DisallowDynamicNewRule implements Rule{ public function getNodeType() : string{ return New_::class; } public function processNode(Node $node, Scope $scope) : array{ /** @var New_ $node */ if($node->class instanceof Expr){ return [ RuleErrorBuilder::message("Dynamic new is not allowed.") ->tip("For factories, use closures instead. Closures can implement custom logic, are statically analyzable, and don't restrict the constructor signature.") ->identifier("pocketmine.new.dynamic") ->build() ]; } return []; } }