Skip to content

-externalpath and phpstan #3

@sedimentation-fault

Description

@sedimentation-fault

Hello,

I feel very honored to be the first person to report something here. :-) I hope it will be of use and interest to you, as it is a tight knot I cannot untangle for me. So let's start:

I have a PHP code where I would like to do some static analysis with phpstan. For this, I did, in some working directory (it doesn't matter where):

composer create-project phpstan/phpstan phpstan

This creates a phpstan directory inside your working directory, with all you need from phpstan.
Trying it a bit, I realized that it needs to know the paths to the class files, otherwise it cannot work (of course, since it is a static analyzer, it cannot run the code to execute the include's). This is described in phpstan/phpstan#5276 - so it is a good idea to read that too, so I don't have to repeat it here. My question there was:

Is there some tool that can do this for me (read a file and all its include's recursively, then write the autoloader.php for me)?

Now you see: AutoLoadOne is this tool! :-) Thus I am trying to make it create an autoload.php for me that I can pass to phpstan with its -a option so that it can find my classes. For this I did:

cd /my/project/dir/
php /full/path/to/AutoLoadOne.php -generate -folder . -excludepath '/xxx*,/yyy*,/zzz*' -save yes -savefilename autoload -externalpath relative/path/to/phpstan/vendor

This indeed creates an autoload.php file. But there are problems - that I will discuss in my next post, so stay tuned...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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