Skip to content

Commit

Permalink
Complete README about autoloading improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tyx committed Dec 27, 2016
1 parent 407caae commit 96e1779
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,31 @@ All the following options are part of the `parameters` section.
PHPStan uses Composer autoloader so the easiest way how to autoload classes
is through the `autoload`/`autoload-dev` sections in composer.json.

#### Specify autoloading path

If you install PHPStan with composer global or if you change the `vendor-dir` of your `composer.json`, you should help it to find your composer autoloader.

**Two solutions** :

You could specify `--autoload-file|-a` option during execution :

```
vendor/bin/phpstan analyse --autoload-file=/path/to/autoload.php src tests
```

Or you could add a `vendor/autoload.php` file next to the folder where you run PHPStan.

```shell
# /home/www/myapp
pwd
echo '<?php require_once("the/path/to/my/app/autoload.php")' > 'vendor/autoload.php'

# Now this call will require the above autoload.php
/home/www/myapp/phpstan analyse
```

#### Your own autoloading

If PHPStan complains about some nonexistent classes and you're sure the classes
exist in the codebase AND you don't want to use Composer autoloader for some reason,
you can specify directories to scan and concrete files to include using
Expand Down Expand Up @@ -315,7 +340,7 @@ interface PropertyReflection
{

public function getType(): Type;

public function getDeclaringClass(): ClassReflection;

public function isStatic(): bool;
Expand Down Expand Up @@ -369,7 +394,7 @@ interface MethodReflection
public function isPrivate(): bool;

public function isPublic(): bool;

public function getName(): string;

/**
Expand Down

0 comments on commit 96e1779

Please sign in to comment.