Skip to content

Commit

Permalink
Autoloading footnote
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Apr 11, 2020
1 parent a3d25de commit 0eda87b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 3 additions & 1 deletion website/src/user-guide/autoloading.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ title: Autoloading

PHPStan needs a working autoloader to access reflection of the analysed classes. It uses Composer autoloader in the project by looking at `vendor/autoload.php` from the current working directory. Use the `autoload`/`autoload-dev` sections in `composer.json` to configure the autoloader.

If PHPStan complains about some non-existent classes and you're sure the classes exist in the codebase and you don't want to use Composer autoloader, you can specify directories to scan and concrete files to include using `autoload_directories` and `autoload_files` parameters in the [configuration file](/config-reference).
If PHPStan complains about some non-existent classes [^class-not-found] and you're sure the classes exist in the codebase and you don't want to use Composer autoloader, you can specify directories to scan and concrete files to include using `autoload_directories` and `autoload_files` parameters in the [configuration file](/config-reference).

[^class-not-found]: This manifests are "Class not found" message in the PHPStan's output, even when analysing the file the class is in.

`autoload_directories` is for discovering classes, interfaces, and traits, `autoload_files` is used for loading function definitions.

Expand Down
2 changes: 1 addition & 1 deletion website/src/user-guide/command-line-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Outputs a summary of available CLI options, but not as in much detail as this pa
Clearing the result cache
--------------

To clear the current state of the result cache, for example if you're developing [custom extensions](/developing-extensions/extension-types) and the result cache is getting stale too often.
To clear the current state of the [result cache](/user-guide/result-cache), for example if you're developing [custom extensions](/developing-extensions/extension-types) and the result cache is getting stale too often.

```bash
vendor/bin/phpstan clear-result-cache [options]
Expand Down
28 changes: 28 additions & 0 deletions website/src/user-guide/result-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Result Cache
---

PHPStan caches the result of the analysis so the subsequent runs are much faster. You should always analyse the whole project - the list of paths passed to the [`analyse` command](/user-guide/command-line-usage) should be the same to take advantage of the result cache. If the list of paths differs from run to run, the cache is rebuilt from the ground up each time.

The result cache is saved at `%tmpDir%/result-cache.php`. [Learn more about `tmpDir` configuration »](/config-reference#caching)

Result cache contents
--------------

* The last time a full analysis of the project was performed. The full analysis is performed at least every 24 hours.
* Analysis variables used to invalidate a stale cache. If any of these values change, full analysis is performed again.
* PHPStan version
* PHP version
* Loaded PHP extensions
* [Rule level](/user-guide/rule-levels)
* [Configuration files](/config-reference) hashes
* Analysed paths
* `composer.lock` files hashes
* [Stub files](/user-guide/stub-files) hashes
* Errors in the last run
* Dependency tree of project files. If file `A.php` was modified since the last run, `A.php` and all the files calling or otherwise referencing all the symbols in `A.php` are analysed again.

Clearing the result cache
---------------

To clear the current state of the result cache, for example if you're developing [custom extensions](/developing-extensions/extension-types) and the result cache is getting stale too often, you can run the `clear-result-cache` command. [Learn more »](/user-guide/command-line-usage#clearing-the-result-cache)
4 changes: 4 additions & 0 deletions website/src/user-guide/user-guide.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
"title": "Stub Files",
"link": "/user-guide/stub-files"
},
{
"title": "Result Cache",
"link": "/user-guide/result-cache"
},
{
"title": "Extension Library",
"link": "/user-guide/extension-library"
Expand Down

0 comments on commit 0eda87b

Please sign in to comment.