What is the correct placement of the file-level DocBlock when using declare(strict_types=1) and namespace?
For example is the following correct or does the DocBlock go under the opening PHP tag?
<?php
declare(strict_types=1)
/**
* DocBlock
*/
namespace Xxx\Xxx;
use Xxx\Xxx;
if (!defined('ABSPATH')) {
exit;
}
/**
*
*/
class Xxx {
// ...
}
Coding style rules are declared in some PSR (PHP Standard Recommendation) standards from PHP-FIG. They are not officially related to the language but are followed by many PHP programmers and can be considered industry standards.
The question you ask is detailed in the PSR-12 - 3rd part:
The example that follows shows the file-level docblock before the
declarestatement: