BackwardCompatibilityCheck icon indicating copy to clipboard operation
BackwardCompatibilityCheck copied to clipboard

unrecognized node type `PhpParser\Node\Expr\FuncCall`

Open staabm opened this issue 1 year ago • 5 comments

using Nyholm/roave-bc-check-docker we run a github action on a codebase which contains a lib/RegexFormats.php file:

<?php

if (!defined('VALIDATOR_REGEXES_LOADED')) {
    // in case you change the EMAIL regex, make sure you also update it in rocket.js; see CLX6-272
    define('REGEX_MAIL_OLD', '^[-A-Za-z0-9~!$%^&*_=+\}\{\'?]+(\.[-A-Za-z0-9~!$%^&*_=+\}\{\'?]+)*@(?!\-)(?:[\d\-\pL]{0,62}[\pL\d]\.){1,126}(?!\d+)[a-zA-Z\d]{2,63}$');
    define('REGEX_MAIL_UTF8', "^[-A-Za-z0-9~!$%^&*_=+\}\{\'?]+(\.[-A-Za-z0-9~!$%^&*_=+\}\{\'?]+)*@(?!\-)(?:[\d\-A-Za-z\x{00C0}-\x{017F}]{0,62}[A-Za-z\x{00C0}-\x{017F}\d]\.){1,126}(?!\d+)[a-zA-Z\d]{2,63}$");
    defined('REGEX_EMAIL') ?: define('REGEX_EMAIL', defined('ENCODING_CHARSET') && (false !== stripos(ENCODING_CHARSET, StringConverter::UTF_8)) ? REGEX_MAIL_UTF8 : REGEX_MAIL_OLD);

    defined('REGEX_PLZ') ?: define('REGEX_PLZ', '^[0-9]{4,}$');
    defined('REGEX_HAUSNR') ?: define('REGEX_HAUSNR', '^[0-9a-zA-Z\.\-\s]{1,}$');
    defined('REGEX_GEBURTSORT') ?: define('REGEX_GEBURTSORT', '^[\pL\- ]+$'); // \pL means all letters, also umlauts
    defined('REGEX_NR') ?: define('REGEX_NR', '^[0-9]+$');
    defined('REGEX_BLZ') ?: define('REGEX_BLZ', '^[a-zA-Z0-9]{8}$');
    defined('REGEX_TEL') ?: define('REGEX_TEL', '^[0|+][0-9\/\-\s\+]{4,}$');
    defined('REGEX_URL') ?: define('REGEX_URL', '^[a-zA-Z0-9./?:@\-_=#%]+\.[a-zA-Z0-9./?:@\-+_=#%&]*$');
    defined('REGEX_LINK') ?: define('REGEX_LINK', '^(http:\/\/|https:\/\/|clx:\/\/|\/)[a-zA-Z0-9./?:@\-+_=#%&]+$');
    defined('REGEX_NUMBER') ?: define('REGEX_NUMBER', '^[0-9/]+$');
    defined('REGEX_UST_NUMBER') ?: define('REGEX_UST_NUMBER', '^[a-zA-Z0-9/]+$');

    define('VALIDATOR_REGEXES_LOADED', true);
}

roave/backward-compatibility-check reports

[BC] SKIPPED: Unable to compile expression in global namespace: unrecognized node type PhpParser\Node\Expr\FuncCall in file /lib/RegexFormats.php (line 7)

and I don't know what this error is trying to tell me ;)

staabm avatar Mar 29 '23 09:03 staabm

This define() call:

define('REGEX_EMAIL', defined('ENCODING_CHARSET') && (false !== stripos(ENCODING_CHARSET, StringConverter::UTF_8)) ? REGEX_MAIL_UTF8 : REGEX_MAIL_OLD);

Contains a function call, and can likely not be evaluated

Ocramius avatar Mar 29 '23 09:03 Ocramius

I see - thank you.

I tried to ignore this error via roave-bc-check.yaml

parameters:
    ignoreErrors:
        - '#\[BC\] SKIPPED: Roave\\BetterReflection\\Reflection\\ReflectionClass "SoapClient" could not be found in the located source#'
        - '#\[BC\] SKIPPED: Unable to compile expression in global namespace: unrecognized node type PhpParser\\Node\\Expr\\FuncCall in file /lib/RegexFormats.php \(line 7\)#'

but it seems I miss something. the first ignore-rule works as expected for other errors, but it seems I am not able to ignore the Unable to compile expression in global namespace one. is it somehow not ignorable , or did I miss to escape some meta character or similar?

staabm avatar Mar 29 '23 10:03 staabm

No clue: the YAML-based exclusions are not part of this package, since I wouldn't touch YAML anyway 😛

Ocramius avatar Mar 29 '23 11:03 Ocramius

Oh I see. Is there a different way of ignoring errors?

staabm avatar Mar 29 '23 11:03 staabm

#737 provides that, but we had difficulties landing it due to CI setup requiring work (for which I simply couldn't find the time ;_; )

Ocramius avatar Mar 29 '23 11:03 Ocramius