Skip to content

DrupalPractice can use wrong autoloader #54

@danepowell

Description

@danepowell

#29 introduced the following line into the DrupalPractice ruleset:

<autoload>../Drupal/autoload.php</autoload>

This can cause phpcs to break in rather exciting and unexpected ways depending on the architecture of the host system.

In my case, I have a package (BLT) that depends on coder and uses phpcs to do internal code sniffing. I also happen to develop on Drupal core, although this shouldn't really be relevant (but you'll see why it is momentarily).

On my Mac OSX machine, I keep all packages under development in a ~/packages directory:

/Users/dane/packages/blt
/Users/dane/packages/drupal
(etc...)

When I was developing on BLT today, I ran ./vendor/bin/phpcs in the /Users/dane/packages/blt directory and was greeted with the following error:

require(/Users/dane/packages/Drupal/vendor/autoload.php): failed to open stream: No such file or directory in /Users/dane/packages/Drupal/autoload.php

This is unexpected because the drupal package should be completely isolated from BLT, as it's in a sibling directory!

I think what's happening here is that because of that definition in the ruleset, and the fact that OSX is case-insensitive, and I just happen to have Drupal cloned in a sibling directory, Composer tries to autoload from that directory and explodes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions