I'm introducing some more coding quality standards and checks via a new project - in particular, the PHP-FIG recommendations.
This project using Zend Framework 2, and I have a fairly simple entry script which passes on to the MVC application:
define("BASE_PATH", (dirname(__DIR__))); // Decline static file requests back to the PHP built-in webserver if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) { return false; } // Setup autoloading // Get the autoloader from composer $loader = include BASE_PATH . '/vendor/autoload.php'; $zf2Path = BASE_PATH . '/vendor/ZF2/library'; // Add the Zend namespaces/paths to the autoloader $loader->add('Zend', $zf2Path); $loader->add('ZendXml', $zf2Path); if (!class_exists('Zend\Loader\AutoloaderFactory')) { throw new RuntimeException('Unable to load ZF2.'); } // Run the application! Zend\Mvc\Application::init(require BASE_PATH . '/config/application.config.php')->run();
When I run this through PHP-CodeSniffer, I get a warning that:
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 11 and the first side effect is on line 17.
Essentially, PSR-1 does not like that I have a constant definition and then a return statement later on.
Is this an instance where it doesn't matter - as long as the rest of the MVC framework and application is okay, then there's no problem?