Skip to content

TypeNameMatchesFileName Namespace calculation is broken if having double source dir (src/src) #1249

@c33s

Description

@c33s

the MR #987 which would fix exactly this problem was not merged. i have exactly the problem described in this MR, if you structrue you code in an additional src dir the namespace calculation is broken

path: /projects/entity-loader-bundle

├── wiki
|  └── ...
├── doc
├── entity-read-notes.md
├── src
|  ├── codeception.yml
|  ├── composer.json
|  ├── composer.lock
|  ├── composer.yaml
|  ├── config
|  ├── docs
|  ├── LICENSE
|  ├── phpstan.neon
|  ├── README.md
|  ├── RoboFile.php
|  ├── src
|  ├── tests
|  └── vendor
├── tmp
|  ├── Content
|  └── services.yaml

where i use the additional level to have for e.g. an additional tmp dir or for cloning two branches of my bundle at the same time, or for cloning the gitlab wiki repo, the namespace detection is broken.

my path is

/projects/entity-loader-bundle/src/src/C33sEntityLoaderBundle.php

where the config files resides in

/projects/entity-loader-bundle/src/

having this config (exactly like in the composer autoload section)

    <rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
        <properties>
            <property name="rootNamespaces" type="array">
                <element key="src" value="C33s\Bundle\EntityLoaderBundle"/>
            </property>
        </properties>
        <exclude-pattern>/Robofile.php</exclude-pattern>
    </rule>

i get (\SlevomatCodingStandard\Sniffs\Files\TypeNameMatchesFileNameSniff):

$expectedTypeName "C33s\Bundle\EntityLoaderBundle\src\C33sEntityLoaderBundle"
$typeName "C33s\Bundle\EntityLoaderBundle\C33sEntityLoaderBundle"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions