[NFLRUSBridge] Remove byte-order-mark (#2777)

With UTF-8 byte-order mark in the file, the `ListActionTest::testOutput`
would fail after converting tests to PSR-4 namespaces:

    invalid JSON output: Syntax error
    Failed asserting that null is not null.

This is because ListAction::execute tries to create the bridge objects
and, when the files containing the bridge classes are not loaded yet,
the autoloader starts including them. Since this happens after output
buffering has begun, any text in the PHP file before the `<?php` tag
such as the BOM will end up in the buffer to be parsed by `json_decode`.

Previously, it worked by chance thanks to some other test including the file
before `ListActionTest`. With the restructuring, `Actions\ListActionTest`
will run sooner and become responsible for triggering the autoloader.

To prevent this in the future, I also disallowed BOM in the coding style.
This commit is contained in:
Jan Tojnar 2022-06-07 04:59:22 +02:00 committed by GitHub
parent 190c95fa62
commit 19ad2584da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,4 @@
<?php <?php
class NFLRUSBridge extends BridgeAbstract { class NFLRUSBridge extends BridgeAbstract {

View File

@ -15,6 +15,8 @@
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/> <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Do not override methods to call their parent --> <!-- Do not override methods to call their parent -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/> <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Do not allow UTF-8 byte-order mark -->
<rule ref="Generic.Files.ByteOrderMark"/>
<!-- Make sure the concatenation operator has spaces around it --> <!-- Make sure the concatenation operator has spaces around it -->
<rule ref="Squiz.Strings.ConcatenationSpacing"> <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties> <properties>