Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Warning: Use of undefined constant T_MATCH #808

Closed
aradhell opened this issue Sep 7, 2020 · 5 comments
Closed

PHP Warning: Use of undefined constant T_MATCH #808

aradhell opened this issue Sep 7, 2020 · 5 comments
Assignees

Comments

@aradhell
Copy link

aradhell commented Sep 7, 2020

Q A
php-code-coverage version 9.1.8
PHP version 7.4.3
Driver Xdebug
Xdebug version (if used) 2.9.6
Installation Method Composer
Usage Method PHPUnit
PHPUnit version (if used) 9.3.8
PHP Warning:  Use of undefined constant T_MATCH - assumed 'T_MATCH' (this will throw an Error in a future version of PHP) in /home/travis/build/user/[secure]/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/File.php on line 970
PHP Stack trace:
PHP   1. {main}() /home/travis/build/user/[secure]/vendor/brianium/paratest/bin/paratest:0
PHP   2. Symfony\Component\Console\Application->run() /home/travis/build/user/[secure]/vendor/brianium/paratest/bin/paratest:37
PHP   3. Symfony\Component\Console\Application->doRun() /home/travis/build/user/[secure]/vendor/symfony/console/Application.php:140
PHP   4. Symfony\Component\Console\Application->doRunCommand() /home/travis/build/user/[secure]/vendor/symfony/console/Application.php:264
PHP   5. ParaTest\Console\Commands\ParaTestCommand->run() /home/travis/build/user/[secure]/vendor/symfony/console/Application.php:911
PHP   6. ParaTest\Console\Commands\ParaTestCommand->execute() /home/travis/build/user/[secure]/vendor/symfony/console/Command/Command.php:258
PHP   7. ParaTest\Runners\PHPUnit\Runner->run() /home/travis/build/user/[secure]/vendor/brianium/paratest/src/Console/Commands/ParaTestCommand.php:86
PHP   8. ParaTest\Runners\PHPUnit\Runner->complete() /home/travis/build/user/[secure]/vendor/brianium/paratest/src/Runners/PHPUnit/BaseRunner.php:79
PHP   9. ParaTest\Runners\PHPUnit\Runner->logCoverage() /home/travis/build/user/[secure]/vendor/brianium/paratest/src/Runners/PHPUnit/BaseRunner.php:113
PHP  10. ParaTest\Coverage\CoverageReporter->html() /home/travis/build/user/[secure]/vendor/brianium/paratest/src/Runners/PHPUnit/BaseRunner.php:178
PHP  11. SebastianBergmann\CodeCoverage\Report\Html\Facade->process() /home/travis/build/user/[secure]/vendor/brianium/paratest/src/Coverage/CoverageReporter.php:74
PHP  12. SebastianBergmann\CodeCoverage\Report\Html\File->render() /home/travis/build/user/[secure]/vendor/phpunit/php-code-coverage/src/Report/Html/Facade.php:103
PHP  13. SebastianBergmann\CodeCoverage\Report\Html\File->renderSourceWithLineCoverage() /home/travis/build/user/[secure]/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/File.php:113
PHP  14. SebastianBergmann\CodeCoverage\Report\Html\File->loadFile() /home/travis/build/user/[secure]/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/File.php:399
@sebastianbergmann
Copy link
Owner

I know that T_MATCH is new in PHP 8. However, in my tests on PHP 7 I did not run into this issue. Will safeguard against this.

@sebastianbergmann
Copy link
Owner

Just out of curiosity: how do you trigger this warning? When I run the tests for this library the line of code in question is executed. My PHP is configured with error_reporting=-1 so that I get all errors. Yet I do not see the warning.

@aradhell
Copy link
Author

aradhell commented Sep 8, 2020

Hi @sebastianbergmann ,

Actually it was my bad, we recently upgraded PhpUnit to 9.36 from 8.5 and didn't change the configuration :/ After updating phpunit.xml works fine 👍

@SiebeVE
Copy link

SiebeVE commented Sep 11, 2020

Hi,

I'm also receiving this warnings.
@aradhell what configuration did you change?

Thanks!

@aradhell
Copy link
Author

aradhell commented Sep 11, 2020

@SiebeVE

Hi,

I'm also receiving this warnings.
@aradhell what configuration did you change?

Thanks!

adding phpunit.xmls. before and after, https://phpunit.readthedocs.io/en/9.3/configuration.html?highlight=%3Cfilter%3E#the-coverage-element

        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
            <exclude>
                <directory>app/Console</directory>
                <directory>app/Creditsafe/Models</directory>
                <directory>app/Events</directory>
                <directory>app/Exceptions</directory>
                <directory>app/Http/Controllers/Auth</directory>
                <directory>app/Interfaces</directory>
                <directory>app/Jobs</directory>
                <directory>app/Listeners</directory>
                <directory>app/Models</directory>
                <directory>app/Providers</directory>

                <file>app/Http/Middleware/Authenticate.php</file>
            </exclude>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-clover" target="clover.xml"/>
        <log type="coverage-html" target="report/codeCoverage/" />
<!--        <log type="junit" target="report/tests.xml"/>-->
    </logging>```


```<?xml version="1.0" encoding="UTF-8"?>
    <testsuites>
        ...
    </testsuites>
    <coverage cacheDirectory="/tmp"
              includeUncoveredFiles="true"
              processUncoveredFiles="true"
              pathCoverage="false"
              ignoreDeprecatedCodeUnits="true"
              disableCodeCoverageIgnore="true">
        <include>
            <directory suffix=".php">./app</directory>
        </include>
        <exclude>
            <directory>app/Console</directory>
            <directory>app/Creditsafe/Models</directory>
            <directory>app/Events</directory>
            <directory>app/Exceptions</directory>
            <directory>app/Http/Controllers/Auth</directory>
            <directory>app/Interfaces</directory>
            <directory>app/Jobs</directory>
            <directory>app/Listeners</directory>
            <directory>app/Models</directory>
            <directory>app/Providers</directory>

            <file>app/Http/Middleware/Authenticate.php</file>
        </exclude>
        <report>
            <clover outputFile="clover.xml"/>
        </report>
    </coverage>
</phpunit>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants