SlevomatCodingStandard.TypeHints.DeclareStrictTypes
declareOnFirstLine requires declare on the first line right after
I want to be able to require declare on the next line of the PHP opening tag, this seems not require-able in version 7.0.0?
When the opening <?php tag is on the first line of the file, it MUST be on its own line with no other statements unless it is a file containing markup outside of PHP opening and closing tags.
See: https://www.php-fig.org/psr/psr-12/
Thanks for your reply; I read the README and already tried the configuration options, but without result.
When I put the option linesCountBeforeDeclare on 1, it will be enforced like this:
<?php
declare(strict_types=1);
However I try to enforce this:
<?php
declare(strict_types=1);
Set linesCountBeforeDeclare to 0.
When I set linesCountBeforeDeclare to 0, you're still able to put the declare on the same line as the opening PHP tag.
@tlsvda I'm sorry, I don't understand you.
Let me try to clarify it again, this is what I try to enforce:
<?php
declare(strict_types=1);
I can't achieve this with the current configuration options.
This is my configuration:
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="declareOnFirstLine" value="0"/>
<property name="linesCountBeforeDeclare" value="0"/>
<property name="linesCountAfterDeclare" value="1"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
</properties>
</rule>
But with these settings I'm also able to put it like this:
<?php declare(strict_types=1);
When changing this
<property name="linesCountBeforeDeclare" value="0"/>
to
<property name="linesCountBeforeDeclare" value="1"/>
I'm forced to put an extra line between opening tag and declare line, like this:
<?php
declare(strict_types=1);
declareOnFirstLine is boolean so it should be false. Or you can just remove the line because false is default.
Okay I removed declareOnFirstLine now, but it's still possible to put the declare(strict_types=1) on the same line as the PHP opening tag.
Ok, I've finally understood you.
Fixed in https://github.com/slevomat/coding-standard/commit/08580348e8bb68a36c8753d3db6ba816089129e6
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Ok, I've finally understood you.
Fixed in https://github.com/slevomat/coding-standard/commit/08580348e8bb68a36c8753d3db6ba816089129e6