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

unrecognized node type PhpParser\Node\Expr\FuncCall #743

Open
staabm opened this issue Mar 29, 2023 · 5 comments
Open

unrecognized node type PhpParser\Node\Expr\FuncCall #743

staabm opened this issue Mar 29, 2023 · 5 comments

Comments

@staabm
Copy link
Contributor

staabm commented Mar 29, 2023

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 ;)

@Ocramius
Copy link
Member

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

@staabm
Copy link
Contributor Author

staabm commented Mar 29, 2023

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?

@Ocramius
Copy link
Member

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

@staabm
Copy link
Contributor Author

staabm commented Mar 29, 2023

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

@Ocramius
Copy link
Member

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

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

2 participants