addFile( 'somefile.php', 'project_checker); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); $this->assertSame('int', (string) $context->vars_in_scope['$a']); } /** * @return array */ public function providerFileCheckerValidCodeParse() { return [ 'deprecatedMethod' => [ ' [ ' */ function foo2() : array { return ["hello"]; } /** * @return array */ function foo3() : array { return ["hello"]; }', ], 'reassertWithIs' => [ ' [ ' [ '> $data */ function foo($data) : void { foreach ($data as $key => $val) { if (!\is_array($data)) { $data = [$key => null]; } else { $data[$key] = !empty($val); } } }', ], 'goodDocblock' => [ ' [ ' [ 'foo = "hello";', ], 'ignoreNullableReturn' => [ 'foo(); $a->bar = 7; takeA($a);', ], 'invalidDocblockParamSuppress' => [ ' [ ' [ ' */ $a = []; $a[0]->getMessage();', ], 'mixedDocblockParamTypeDefinedInParent' => [ ' [ ' [ ' 'InvalidDocblock', ], 'invalidReturnClass' => [ ' 'InvalidDocblock', ], 'invalidReturnClassWithComma' => [ ' 'InvalidDocblock', ], 'returnClassWithComma' => [ ' 'InvalidDocblock', ], 'deprecatedMethodWithCall' => [ ' 'DeprecatedMethod', ], 'deprecatedClassWithStaticCall' => [ ' 'DeprecatedClass', ], 'deprecatedClassWithNew' => [ ' 'DeprecatedClass', ], 'deprecatedPropertyGet' => [ 'foo;', 'error_message' => 'DeprecatedProperty', ], 'deprecatedPropertySet' => [ 'foo = 5;', 'error_message' => 'DeprecatedProperty', ], 'missingParamType' => [ ' 'TooManyArguments', ], 'missingParamVar' => [ ' 'InvalidDocblock - src/somefile.php:5 - Badly-formatted @param', ], 'invalidDocblockReturn' => [ ' 'InvalidDocblock', ], 'propertyDocblockInvalidAssignment' => [ 'foo = 5;', 'error_message' => 'InvalidPropertyAssignment', ], 'noParamType' => [ ' 'UntypedParam', ], 'intParamTypeDefinedInParent' => [ ' 'UntypedParam', 'error_levels' => ['MethodSignatureMismatch'], ], ]; } }