Skip to content

Commit baa5339

Browse files
AdrienClairembaultcedric-anne
authored andcommitted
Review the empty plugin
- Fix spelling mistakes and punctuation inconsistencies - Fix incorrect license - Add global modified to sed commands to fix missed replacements - Rename master to main - Fix headers - Update glpi-project/tools to ^0.7 - Add empty src folder - Add makefile - Add phpunit - Add PHPStan - Add PHP-CS-Fixer - Add CI workflow
1 parent 289432b commit baa5339

15 files changed

Lines changed: 301 additions & 55 deletions
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Continuous integration"
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
tags:
8+
- "*"
9+
pull_request:
10+
schedule:
11+
- cron: "0 0 * * *"
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: "${{ github.workflow }}-${{ github.ref }}"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
generate-ci-matrix:
20+
name: "Generate CI matrix"
21+
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
22+
with:
23+
glpi-version: "10.0.x"
24+
ci:
25+
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
26+
needs: "generate-ci-matrix"
27+
strategy:
28+
fail-fast: false
29+
matrix: ${{ fromJson(needs.generate-ci-matrix.outputs.matrix) }}
30+
uses: "glpi-project/plugin-ci-workflows/.github/workflows/continuous-integration.yml@v1"
31+
with:
32+
plugin-key: "empty"
33+
glpi-version: "${{ matrix.glpi-version }}"
34+
php-version: "${{ matrix.php-version }}"
35+
db-image: "${{ matrix.db-image }}"
36+
init-script: "./.github/workflows/create-plugin.sh"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Continuous integration"
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
tags:
8+
- "*"
9+
pull_request:
10+
schedule:
11+
- cron: "0 0 * * *"
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: "${{ github.workflow }}-${{ github.ref }}"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
generate-ci-matrix:
20+
name: "Generate CI matrix"
21+
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
22+
with:
23+
glpi-version: "10.0.x"
24+
ci:
25+
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
26+
needs: "generate-ci-matrix"
27+
strategy:
28+
fail-fast: false
29+
matrix: ${{ fromJson(needs.generate-ci-matrix.outputs.matrix) }}
30+
uses: "glpi-project/plugin-ci-workflows/.github/workflows/continuous-integration.yml@v1"
31+
with:
32+
plugin-key: "{LNAME}"
33+
glpi-version: "${{ matrix.glpi-version }}"
34+
php-version: "${{ matrix.php-version }}"
35+
db-image: "${{ matrix.db-image }}"

.github/workflows/create-plugin.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
#
3+
# -------------------------------------------------------------------------
4+
# {NAME} plugin for GLPI
5+
# Copyright (C) {YEAR} by the {NAME} Development Team.
6+
# -------------------------------------------------------------------------
7+
#
8+
# MIT License
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a copy
11+
# of this software and associated documentation files (the "Software"), to deal
12+
# in the Software without restriction, including without limitation the rights
13+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
# copies of the Software, and to permit persons to whom the Software is
15+
# furnished to do so, subject to the following conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included in all
18+
# copies or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
# SOFTWARE.
27+
#
28+
# --------------------------------------------------------------------------
29+
#
30+
31+
set -e -u -o pipefail
32+
33+
# `rsync` is required by the `plugin.sh` script
34+
sudo apt update
35+
sudo apt install --assume-yes --no-install-recommends --quiet rsync
36+
37+
# move self to `template` then create an `empty` plugin`
38+
(cd .. && mv empty template && cd template && ./plugin.sh empty "1.0.0")

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ vendor/
44
.gh_token
55
composer.lock
66
*.min.*
7-
7+
var

.php-cs-fixer.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
/**
4+
* -------------------------------------------------------------------------
5+
* {NAME} plugin for GLPI
6+
* -------------------------------------------------------------------------
7+
*
8+
* MIT License
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a copy
11+
* of this software and associated documentation files (the "Software"), to deal
12+
* in the Software without restriction, including without limitation the rights
13+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
* copies of the Software, and to permit persons to whom the Software is
15+
* furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in all
18+
* copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
* SOFTWARE.
27+
* -------------------------------------------------------------------------
28+
* @copyright Copyright (C) {YEAR} by the {NAME} plugin team.
29+
* @license MIT https://opensource.org/licenses/mit-license.php
30+
* @link https://github.com/pluginsGLPI/{LNAME}
31+
* -------------------------------------------------------------------------
32+
*/
33+
34+
use PhpCsFixer\Config;
35+
use PhpCsFixer\Finder;
36+
37+
$finder = Finder::create()
38+
->in(__DIR__)
39+
->ignoreVCSIgnored(true)
40+
->name('*.php');
41+
42+
$config = new Config();
43+
44+
$rules = [
45+
'@PER-CS' => true, // Latest PER rules.
46+
];
47+
48+
return $config
49+
->setRules($rules)
50+
->setFinder($finder)
51+
->setCacheFile(__DIR__ . '/var/php-cs-fixer/.php-cs-fixer.cache')
52+
;

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../PluginsMakefile.mk

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"php": ">=7.4"
44
},
55
"require-dev": {
6-
"glpi-project/tools": "^0.4"
6+
"glpi-project/tools": "^0.7"
77
},
88
"config": {
99
"optimize-autoloader": true,

hook.php.tpl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
/**
44
* -------------------------------------------------------------------------
55
* {NAME} plugin for GLPI
6-
* Copyright (C) {YEAR} by the {NAME} Development Team.
76
* -------------------------------------------------------------------------
87
*
98
* MIT License
@@ -25,26 +24,25 @@
2524
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2625
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2726
* SOFTWARE.
28-
*
29-
* --------------------------------------------------------------------------
27+
* -------------------------------------------------------------------------
28+
* @copyright Copyright (C) {YEAR} by the {NAME} plugin team.
29+
* @license MIT https://opensource.org/licenses/mit-license.php
30+
* @link https://github.com/pluginsGLPI/{LNAME}
31+
* -------------------------------------------------------------------------
3032
*/
3133

3234
/**
3335
* Plugin install process
34-
*
35-
* @return boolean
3636
*/
37-
function plugin_{LNAME}_install()
37+
function plugin_{LNAME}_install(): bool
3838
{
3939
return true;
4040
}
4141

4242
/**
4343
* Plugin uninstall process
44-
*
45-
* @return boolean
4644
*/
47-
function plugin_{LNAME}_uninstall()
45+
function plugin_{LNAME}_uninstall(): bool
4846
{
4947
return true;
5048
}

phpstan.neon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
includes:
2+
- ../../vendor/phpstan/phpstan-deprecation-rules/rules.neon
3+
4+
parameters:
5+
level: max
6+
paths:
7+
- src
8+
- hook.php
9+
- setup.php
10+
scanDirectories:
11+
- ../../src
12+
bootstrapFiles:
13+
- ../../inc/based_config.php
14+
stubFiles:
15+
- ../../stubs/glpi_constants.php
16+
treatPhpDocTypesAsCertain: false

phpunit.xml

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

0 commit comments

Comments
 (0)