Search code examples
phpphpcs

PHP Code Sniffer explanation of rule PEAR.Files.IncludingFile.UseRequireOnce


i'm trying to improve my coding style, so i'm starting to use PHP Code Sniffer to follow standards. Im confused by this rule "PEAR.Files.IncludingFile.UseRequireOnce" what's wrong on include_once? Is it serious violation of standard to suppres this sniff?

Thaks for your answers and advices.


Solution

  • There's no "right" answer, it's whatever you want your coding standards to be.

    Personally, I would use a rule that marked "require_once" as incorrect since it's the exact same as include_once with no chance to check the result for errors. A fatal error because of class not found or a fatal error because require_once failed both have no chance for graceful recovery in PHP.