Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/vendor/
.composer.lock
.php-cs-fixer.cache
.phpunit.result.cache
composer.lock
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,22 @@ parameters:
- ../../stubs/glpi_constants.php
```

The GLPI version should be detected automatically, but you can specify it in the `parameters` section of your PHPStan configuration:
The GLPI path and version should be detected automatically, but you can specify them in the `parameters` section of your PHPStan configuration:
```neon
parameters:
glpi:
glpiVersion: "11.0"
glpiPath: "/path/to/glpi"
glpiVersion: "11.0.0"
```

See https://phpstan.org/config-reference fore more information about the PHPStan configuration options.

## Analyser improvements

This extension will help PHPStan to resolve the GLPI global variables types.
For instance, it will indicate that the `global $DB;` variable is an instance of the `DBmysql` class,
so PHPStan will be able to detected bad method calls, deprecated methods usages, ...

## Rules

### `ForbidDynamicInstantiationRule`
Expand Down Expand Up @@ -111,9 +118,10 @@ Therefore, its usage is discouraged.
> Since GLPI 10.0.

By default, PHPStan is not able to detect the global variables types, and is therefore not able to detect any issue
related to their usage. To get around this limitation, we recommend that you declare each global variable type with
a PHPDoc tag.
related to their usage. This extension will resolve the type of GLPI global variables, but cannot resolve your plugin
specific global variables.
To get around this limitation, we recommend that you declare each global variable type with a PHPDoc tag.
```php
/** @var \DBmysql $DB */
global $DB;
/** @var \Migration $migration */
global migration;
```
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
],
"require": {
"php": ">=7.4",
"phpstan/phpstan": "^2.1"
"phpstan/phpstan": "^2.1",
"symfony/polyfill-php80": "^1.32"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.76",
Expand Down
Loading