Skip to content

Commit d6c3451

Browse files
authored
Adapt template to GLPI 11.0 (#44)
1 parent 853c2f7 commit d6c3451

9 files changed

Lines changed: 31 additions & 29 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: "Generate CI matrix"
2121
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
2222
with:
23-
glpi-version: "10.0.x"
23+
glpi-version: "11.0.x"
2424
ci:
2525
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
2626
needs: "generate-ci-matrix"

.github/workflows/continuous-integration.yml.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: "Generate CI matrix"
2121
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
2222
with:
23-
glpi-version: "10.0.x"
23+
glpi-version: "11.0.x"
2424
ci:
2525
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
2626
needs: "generate-ci-matrix"

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"require": {
3-
"php": ">=7.4"
3+
"php": ">=8.2"
44
},
55
"require-dev": {
66
"glpi-project/tools": "^0.8"
77
},
88
"config": {
99
"optimize-autoloader": true,
1010
"platform": {
11-
"php": "7.4.0"
11+
"php": "8.2.99"
1212
},
1313
"sort-packages": true
1414
}

phpstan.neon

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
includes:
2+
- ../../vendor/glpi-project/phpstan-glpi/extension.neon
23
- ../../vendor/phpstan/phpstan-deprecation-rules/rules.neon
4+
- ../../vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
35

46
parameters:
57
level: max
@@ -10,7 +12,6 @@ parameters:
1012
scanDirectories:
1113
- ../../src
1214
bootstrapFiles:
13-
- ../../inc/based_config.php
14-
stubFiles:
1515
- ../../stubs/glpi_constants.php
16+
- ../../vendor/autoload.php
1617
treatPhpDocTypesAsCertain: false

phpunit.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<phpunit bootstrap="tests/bootstrap.php" colors="true" testdox="true">
1+
<phpunit
2+
bootstrap="tests/bootstrap.php"
3+
colors="true"
4+
testdox="true"
5+
cacheDirectory="var/phpunit"
6+
>
27
<testsuites>
38
<testsuite name="Tests">
49
<directory suffix="Test.php">tests</directory>

plugin.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
<version>
3030
<num>{VERSION}</num>
3131
<!-- Add as many compatibility tag you want -->
32-
<compatibility>9.4</compatibility>
33-
<compatibility>9.3</compatibility>
34-
<compatibility>9.2</compatibility>
32+
<compatibility>~11.0.0</compatibility>
3533
</version>
3634
</versions>
3735
<langs>

psalm.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
runTaintAnalysis="true"
4+
>
5+
<projectFiles>
6+
<directory name="src"/>
7+
<file name="hook.php"/>
8+
<file name="setup.php"/>
9+
</projectFiles>
10+
</psalm>

setup.php.tpl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,22 @@
3131
* -------------------------------------------------------------------------
3232
*/
3333

34+
/** @phpstan-ignore theCodingMachineSafe.function (safe to assume this isn't already defined) */
3435
define('PLUGIN_{UNAME}_VERSION', '{VERSION}');
3536

3637
// Minimal GLPI version, inclusive
37-
define("PLUGIN_{UNAME}_MIN_GLPI_VERSION", "10.0.0");
38+
/** @phpstan-ignore theCodingMachineSafe.function (safe to assume this isn't already defined) */
39+
define("PLUGIN_{UNAME}_MIN_GLPI_VERSION", "11.0.0");
3840

3941
// Maximum GLPI version, exclusive
40-
define("PLUGIN_{UNAME}_MAX_GLPI_VERSION", "10.0.99");
42+
/** @phpstan-ignore theCodingMachineSafe.function (safe to assume this isn't already defined) */
43+
define("PLUGIN_{UNAME}_MAX_GLPI_VERSION", "11.0.99");
4144

4245
/**
4346
* Init hooks of the plugin.
4447
* REQUIRED
4548
*/
46-
function plugin_init_{LNAME}(): void
47-
{
48-
/** @var array<string, array<string, mixed>> $PLUGIN_HOOKS */
49-
global $PLUGIN_HOOKS;
50-
51-
$PLUGIN_HOOKS['csrf_compliant']['{LNAME}'] = true;
52-
}
49+
function plugin_init_{LNAME}(): void {}
5350

5451
/**
5552
* Get the name and the version of the plugin

tests/bootstrap.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,7 @@
3131
* -------------------------------------------------------------------------
3232
*/
3333

34-
global $CFG_GLPI, $PLUGIN_HOOKS;
35-
36-
define('GLPI_ROOT', __DIR__ . '/../../../');
37-
define('GLPI_LOG_DIR', __DIR__ . '/files/_logs');
38-
39-
define('TU_USER', 'glpi');
40-
define('TU_PASS', 'glpi');
41-
define('GLPI_LOG_LVL', 'DEBUG');
42-
43-
require GLPI_ROOT . '/inc/includes.php';
34+
require __DIR__ . '/../../../phpunit/bootstrap.php';
4435

4536
if (!Plugin::isPluginActive("{LNAME}")) {
4637
throw new RuntimeException("Plugin {LNAME} is not active in the test database");

0 commit comments

Comments
 (0)