Skip to content

Always exclude the prefix namespace #1098

@hirasso

Description

@hirasso

Feature Request

The Problem

php-scoper currently scopes already-scoped packages again. Example:

// scoper.inc.php
return [
    'prefix' => 'RH\AdminUtils\Scoped',
];

The result in psr/log after the first run:

namespace RH\AdminUtils\Scoped\Psr\Log;

...after the second run:

namespace RH\AdminUtils\Scoped\RH\AdminUtils\Scoped\Psr\Log;

...after the third run:

namespace RH\AdminUtils\Scoped\RH\AdminUtils\Scoped\RH\AdminUtils\Scoped\Psr\Log;

...and so on. Currently one must add the prefix to exclude-namespaces as well to prevent this behavior:

return [
    'prefix' => 'RH\AdminUtils\Scoped',
    /** prevent double scoping */
    'exclude-namespaces' => ['RH\AdminUtils\Scoped'],
];

The solution

When a prefix is provided, php-scoper should automatically add that namespace to exclude-namespaces.

Considerations

This would of course not work when no custom prefix was provided and php-scoper chooses a random string. But it would be a nice quality-of-live improvement for the case where there is a prefix provided that doesn't change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions