[ ' [ ' 5) { $str = null; } }', ], 'trackFunctionReturnRefs' => [ 'foo; } } function useString(string &$s) : void {} $a = new A(); useString($a->getString());', ], 'makeByRefUseMixed' => [ ' [], 'error_levels' => ['MixedArgument'], ], 'assignByRefToMixed' => [ ' [], 'error_levels' => [ 'MixedAssignment', 'MixedArrayAccess', 'MixedReturnStatement', 'MixedInferredReturnType', 'MixedOperand', ], ], ]; } /** * @return array */ public function providerFileCheckerInvalidCodeParse() { return [ 'functionParameterViolation' => [ ' 'ReferenceConstraintViolation', ], 'classMethodParameterViolation' => [ 'foo = &$foo; $foo = "hello"; } } $bar = 5; $a = new A($bar); // $bar is constrained to an int $bar = null; // ReferenceConstraintViolation issue emitted', 'error_message' => 'ReferenceConstraintViolation', ], 'classMethodParameterViolationInPostAssignment' => [ 'foo = &$foo; } } $bar = 5; $a = new A($bar); $bar = null;', 'error_message' => 'ReferenceConstraintViolation', ], 'contradictoryReferenceConstraints' => [ 'foo = &$foo; } } class B { /** @var string */ private $bar; public function __construct(string &$bar) { $this->bar = &$bar; } } if (rand(0, 1)) { $v = 5; $c = (new A($v)); // $v is constrained to an int } else { $v = "hello"; $c = (new B($v)); // $v is constrained to a string } $v = 8;', 'error_message' => 'ConflictingReferenceConstraint', ], ]; } }