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

How exactly whitelist works for subnamespaces? #366

Closed
TomasVotruba opened this issue Jan 9, 2020 · 5 comments · Fixed by #370
Closed

How exactly whitelist works for subnamespaces? #366

TomasVotruba opened this issue Jan 9, 2020 · 5 comments · Fixed by #370

Comments

@TomasVotruba
Copy link
Contributor

I'm trying to create prefixed ecs.phar:

<?php declare(strict_types=1);

// scoper.inc.php
return [
    'whitelist' => [
        'Symplify\EasyCodingStandard\*',
        #  this might work, but it's too broad
        # 'Symplify\*',
    ],
];

But it prefixed the namespace in the file :/

 services:
-    Symplify\EasyCodingStandard\:
+    _HumbugBox1de09932b74e\Symplify\EasyCodingStandard\:

What can I do to remove it?

@TomasVotruba TomasVotruba changed the title How exacctly whitelist works for subnamespaces? How exactly whitelist works for subnamespaces? Jan 10, 2020
@TomasVotruba
Copy link
Contributor Author

I tried this with same effect:

    'whitelist' => [
        'Symplify\EasyCodingStandard\*',
        'Symplify\EasyCodingStandard*',
        'Symplify\EasyCodingStandard',
        'Symplify\CodingStandard\*',
        'Symplify\CodingStandard',
        'PHP_CodeSniffer\*',
        'PhpCsFixer\*',
    ],

Here is the full PR with box and scoper: deprecated-packages/symplify#1734

@theofidry
Copy link
Member

But it prefixed the namespace in the file :/

Is it in the PHP file or just the service declaration? I would be surprised if the namespace whitelisting doesn't work properly, so I have higher suspicious of it not being done correctly for the Symfony service declaration files

@theofidry theofidry added the bug label Jan 10, 2020
@TomasVotruba
Copy link
Contributor Author

TomasVotruba commented Jan 10, 2020

It's only prefixed in the config, that's why the class cannot be found.

This is the workaround, but it hijacks 7 extra Symplify packages we don't need.

-'Symplify\CodingStandard\*',
+'Symplify\*',

@theofidry
Copy link
Member

Arg indeed https://github.com/humbug/php-scoper/blob/master/src/Scoper/Symfony/YamlScoper.php doesn't make use of the whitelist at all to check that... Probably the same for the XML one

@theofidry
Copy link
Member

Correction: the YamlScoper does take that into account, the issue is with the logic itself. This scoper tries to go by regexes which I guess has its limitations... Maybe it's still possible to do so with it but I'm struggling a bit to do so

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

Successfully merging a pull request may close this issue.

2 participants