expectException(\Psalm\Exception\CodeException::class); $this->expectExceptionMessage('UnusedPsalmSuppress'); $this->addFile( 'somefile.php', 'barBar()->bat()->baz()->bam()->bas()->bee()->bet()->bes()->bis(); } }' ); $this->analyzeFile('somefile.php', new \Psalm\Context()); } /** * @return void */ public function testIssueSuppressedOnStatement() { $this->expectException(\Psalm\Exception\CodeException::class); $this->expectExceptionMessage('UnusedPsalmSuppress'); $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', new \Psalm\Context()); } /** * @return void */ public function testMissingThrowsDocblockSuppressed() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testMissingThrowsDocblockSuppressedWithoutThrow() { $this->expectException(\Psalm\Exception\CodeException::class); $this->expectExceptionMessage('UnusedPsalmSuppress'); Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testMissingThrowsDocblockSuppressedDuplicate() { $this->expectException(\Psalm\Exception\CodeException::class); $this->expectExceptionMessage('UnusedPsalmSuppress'); Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testUncaughtThrowInGlobalScopeSuppressed() { Config::getInstance()->check_for_throws_in_global_scope = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testUncaughtThrowInGlobalScopeSuppressedWithoutThrow() { $this->expectException(\Psalm\Exception\CodeException::class); $this->expectExceptionMessage('UnusedPsalmSuppress'); Config::getInstance()->check_for_throws_in_global_scope = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return iterable,error_levels?:string[]}> */ public function providerValidCodeParse() { return [ 'undefinedClassSimple' => [ 'barBar()->bat()->baz()->bam()->bas()->bee()->bet()->bes()->bis(); } }', ], 'undefinedClassOneLine' => [ ' [ ' [ ' [], 'error_levels' => ['UndefinedFunction'], ], 'suppressWithNewlineAfterComment' => [ ' [ ' */ public function providerInvalidCodeParse() { return [ 'undefinedClassOneLineWithLineAfter' => [ ' 'UndefinedClass - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:33 - Class or interface C', ], 'undefinedClassOneLineInFileAfter' => [ ' 'UndefinedClass - src' . DIRECTORY_SEPARATOR . 'somefile.php:6:25 - Class or interface C', ], 'missingParamTypeShouldntPreventUndefinedClassError' => [ ' 'UndefinedClass', ], ]; } }