check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testDocumentedThrow() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testDocumentedParentThrow() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testNoThrowWhenSuppressing() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage MissingThrowsDocblock * * @return void */ public function testUndocumentedThrowInFunctionCall() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testDocumentedThrowInFunctionCallWithThrow() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testDocumentedThrowInFunctionCallWithoutThrow() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', ' 0) { return ""; } return (string) $a; } public function test(): string { try { return self::notReallyThrowing(2); } catch (\Throwable $E) { return ""; } } }' ); $context = new Context(); $this->analyzeFile('somefile.php', $context); } /** * @return void */ public function testCaughtThrowInFunctionCall() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage MissingThrowsDocblock * * @return void */ public function testUncaughtThrowInFunctionCall() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage MissingDocblockType * * @return void */ public function testEmptyThrows() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } /** * @return void */ public function testCaughtAllThrowInFunctionCall() { Config::getInstance()->check_for_throws_docblock = true; $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', $context); } }