parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); $this->assertEquals('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";' ], ]; } /** * @return array */ public function providerFileCheckerInvalidCodeParse() { return [ 'deprecatedMethodWithCall' => [ ' 'DeprecatedMethod' ], 'invalidDocblockParam' => [ ' 'InvalidDocblock' ], 'extraneousDocblockParam' => [ ' 'InvalidDocblock - somefile.php:3 - Parameter $bar does not appear in the ' . 'argument list for fooBar' ], 'missingParamType' => [ ' 'InvalidDocblock - somefile.php:3 - Parameter $bar does not appear in the ' . 'argument list for fooBar' ], 'missingParamVar' => [ ' 'InvalidDocblock - somefile.php:5 - Badly-formatted @param in docblock for fooBar' ], 'invalidDocblockReturn' => [ ' 'InvalidDocblock' ], 'propertyDocblockInvalidAssignment' => [ 'foo = 5;', 'error_message' => 'InvalidPropertyAssignment', ], ]; } }