Skip to content

MissingThrowsDocblock

A function throws an exception that is not declared in its @throws docblock.

<?php
function open(string $path): resource {
if (!file_exists($path)) {
throw new \RuntimeException("Not found: $path"); // not declared in @throws
}
return fopen($path, 'r');
}

Add a @throws \RuntimeException annotation to the docblock.