Skip to content

Commit

Permalink
phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B committed Apr 26, 2024
1 parent 226bc48 commit da6151e
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 3 deletions.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"php": ">=7.4"
},
"require-dev": {
"glpi-project/tools": "^0.7",
"glpi-project/tools": "^0.7.2",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
"squizlabs/php_codesniffer": "^3.9"
},
"config": {
Expand Down
213 changes: 212 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
parameters:
parallel:
maximumNumberOfProcesses: 2
level: 0
bootstrapFiles:
- ../../inc/based_config.php
paths:
- ajax
- front
- src
- hook.php
- setup.php
scanDirectories:
- ../../inc
- ../../src
stubFiles:
- ../../stubs/glpi_constants.php
rules:
- GlpiProject\Tools\PHPStan\Rules\GlobalVarTypeRule

1 change: 1 addition & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
*/
function plugin_init_gantt()
{
/** @var array $PLUGIN_HOOKS */
global $PLUGIN_HOOKS;

$PLUGIN_HOOKS['csrf_compliant']['gantt'] = true;
Expand Down
4 changes: 3 additions & 1 deletion src/DataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/**
* Class used to prepare data for Gantt
*/
class Datafactory
class DataFactory
{
/**
* Recursive function used to get all subitems of a project, when $id > 0.
Expand All @@ -46,6 +46,7 @@ class Datafactory
*/
public function getItemsForProject(&$itemArray, $id)
{
/** @var DBmysql $DB */
global $DB;
$project = new \Project();
if ($id == -1) {
Expand Down Expand Up @@ -106,6 +107,7 @@ public function getProjectTaskLinks($itemArray)
*/
public function getSubprojects(&$itemArray, $projectId)
{
/** @var DBmysql $DB */
global $DB;
$iterator = $DB->request('glpi_projects', ['projects_id' => $projectId, 'is_template' => 0, 'is_deleted' => 0]);

Expand Down
2 changes: 2 additions & 0 deletions src/ProjectTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ public static function getTypeName($nb = 0)

public function getTabNameForItem(\CommonGLPI $item, $withtemplate = 0)
{
// @phpstan-ignore-next-line
if ($item instanceof \Project) {
return self::createTabEntry(self::getTypeName());
}
}

public static function displayTabContentForItem(\CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
{
// @phpstan-ignore-next-line
if ($item instanceof \Project) {
self::showForProject($item->getId());
}
Expand Down

0 comments on commit da6151e

Please sign in to comment.