From 15748a7c3d3a13433be45f8d144e95269190da97 Mon Sep 17 00:00:00 2001 From: Stanislas Date: Tue, 30 Sep 2025 16:14:41 +0200 Subject: [PATCH] Feature GLP11 (#88) * Feature GLP11 * phpstan * enable CI and fix phstanneon * Update .github/workflows/continuous-integration.yml Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> * Update phpstan.neon Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> * Pass all paramters to parent call * move query -> doQuery * fix direct query * release GLPI 11.0 * Clean composer.json * psalm + rector * fix --------- Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> Co-authored-by: Johan Cwiklinski Co-authored-by: Rom1-B --- .github/workflows/continuous-integration.yml | 35 + CHANGELOG.md | 12 + composer.json | 12 +- composer.lock | 2113 +----------------- example.xml | 4 + front/config.php | 4 +- front/devicecamera.form.php | 2 +- front/devicecamera.php | 2 +- front/dropdown.form.php | 2 +- front/dropdown.php | 2 +- front/example.form.php | 2 +- front/example.php | 2 +- front/popup.php | 17 +- front/ruletest.form.php | 2 +- front/ruletest.php | 2 +- hook.php | 100 +- phpstan.neon | 19 + psalm.xml | 24 + rector.php | 97 + setup.php | 44 +- src/Child.php | 8 +- src/Computer.php | 12 +- src/Config.php | 13 +- src/DeviceCamera.php | 8 +- src/Document.php | 81 +- src/Dropdown.php | 4 +- src/Example.php | 188 +- src/Filters/ComputerModelFilter.php | 3 +- src/ItemForm.php | 24 +- src/Item_DeviceCamera.php | 4 - src/NotificationTargetExample.php | 8 +- src/Profile.php | 18 +- src/RuleTest.php | 9 +- src/RuleTestCollection.php | 5 - src/Showtabitem.php | 17 +- 35 files changed, 554 insertions(+), 2345 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 CHANGELOG.md create mode 100644 phpstan.neon create mode 100644 psalm.xml create mode 100644 rector.php diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..0d446fc --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,35 @@ +name: "Continuous integration" + +on: + push: + branches: + - "main" + tags: + - "*" + pull_request: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + generate-ci-matrix: + name: "Generate CI matrix" + uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1" + with: + glpi-version: "11.0.x" + ci: + name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}" + needs: "generate-ci-matrix" + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.generate-ci-matrix.outputs.matrix) }} + uses: "glpi-project/plugin-ci-workflows/.github/workflows/continuous-integration.yml@v1" + with: + plugin-key: "example" + glpi-version: "${{ matrix.glpi-version }}" + php-version: "${{ matrix.php-version }}" + db-image: "${{ matrix.db-image }}" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4079509 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Change Log + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [0.1.0] - 2025-09-30 + +### Added + +- GLPI 11 compatibility diff --git a/composer.json b/composer.json index 6d78c2d..8b1e015 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,20 @@ { "require": { - "php": ">=7.4" + "php": ">=8.2" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.86", - "glpi-project/tools": "^0.8.0" + "glpi-project/tools": "^0.8" }, "config": { "optimize-autoloader": true, "platform": { - "php": "7.4.0" + "php": "8.2.99" }, "sort-packages": true + }, + "autoload-dev": { + "psr-4": { + "Glpi\\Tools\\": "../../tools/src/" + } } } diff --git a/composer.lock b/composer.lock index 2bbb589..07dddba 100644 --- a/composer.lock +++ b/composer.lock @@ -4,520 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "168843fcb11ffc870261e03c3ec79771", + "content-hash": "0bb7734a8837cdd118f20d259d3613e7", "packages": [], "packages-dev": [ - { - "name": "clue/ndjson-react", - "version": "v1.3.0", - "source": { - "type": "git", - "url": "https://github.com/clue/reactphp-ndjson.git", - "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", - "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "react/stream": "^1.2" - }, - "require-dev": { - "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", - "react/event-loop": "^1.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "Clue\\React\\NDJson\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering" - } - ], - "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", - "homepage": "https://github.com/clue/reactphp-ndjson", - "keywords": [ - "NDJSON", - "json", - "jsonlines", - "newline", - "reactphp", - "streaming" - ], - "support": { - "issues": "https://github.com/clue/reactphp-ndjson/issues", - "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" - }, - "funding": [ - { - "url": "https://clue.engineering/support", - "type": "custom" - }, - { - "url": "https://github.com/clue", - "type": "github" - } - ], - "time": "2022-12-23T10:58:28+00:00" - }, - { - "name": "composer/pcre", - "version": "3.3.2", - "source": { - "type": "git", - "url": "https://github.com/composer/pcre.git", - "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", - "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0" - }, - "conflict": { - "phpstan/phpstan": "<1.11.10" - }, - "require-dev": { - "phpstan/phpstan": "^1.12 || ^2", - "phpstan/phpstan-strict-rules": "^1 || ^2", - "phpunit/phpunit": "^8 || ^9" - }, - "type": "library", - "extra": { - "phpstan": { - "includes": [ - "extension.neon" - ] - }, - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Pcre\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "PCRE wrapping library that offers type-safe preg_* replacements.", - "keywords": [ - "PCRE", - "preg", - "regex", - "regular expression" - ], - "support": { - "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.3.2" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2024-11-12T16:29:46+00:00" - }, - { - "name": "composer/semver", - "version": "3.4.4", - "source": { - "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", - "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.11", - "symfony/phpunit-bridge": "^3 || ^7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Semver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" - } - ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", - "keywords": [ - "semantic", - "semver", - "validation", - "versioning" - ], - "support": { - "irc": "ircs://irc.libera.chat:6697/composer", - "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.4.4" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - } - ], - "time": "2025-08-20T19:15:30+00:00" - }, - { - "name": "composer/xdebug-handler", - "version": "3.0.5", - "source": { - "type": "git", - "url": "https://github.com/composer/xdebug-handler.git", - "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", - "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", - "shasum": "" - }, - "require": { - "composer/pcre": "^1 || ^2 || ^3", - "php": "^7.2.5 || ^8.0", - "psr/log": "^1 || ^2 || ^3" - }, - "require-dev": { - "phpstan/phpstan": "^1.0", - "phpstan/phpstan-strict-rules": "^1.1", - "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Composer\\XdebugHandler\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" - } - ], - "description": "Restarts a process without Xdebug.", - "keywords": [ - "Xdebug", - "performance" - ], - "support": { - "irc": "ircs://irc.libera.chat:6697/composer", - "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2024-05-06T16:37:16+00:00" - }, - { - "name": "evenement/evenement", - "version": "v3.0.2", - "source": { - "type": "git", - "url": "https://github.com/igorw/evenement.git", - "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", - "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "require-dev": { - "phpunit/phpunit": "^9 || ^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Evenement\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "Événement is a very simple event dispatching library for PHP", - "keywords": [ - "event-dispatcher", - "event-emitter" - ], - "support": { - "issues": "https://github.com/igorw/evenement/issues", - "source": "https://github.com/igorw/evenement/tree/v3.0.2" - }, - "time": "2023-08-08T05:53:35+00:00" - }, - { - "name": "fidry/cpu-core-counter", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "db9508f7b1474469d9d3c53b86f817e344732678" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678", - "reference": "db9508f7b1474469d9d3c53b86f817e344732678", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "fidry/makefile": "^0.2.0", - "fidry/php-cs-fixer-config": "^1.1.2", - "phpstan/extension-installer": "^1.2.0", - "phpstan/phpstan": "^2.0", - "phpstan/phpstan-deprecation-rules": "^2.0.0", - "phpstan/phpstan-phpunit": "^2.0", - "phpstan/phpstan-strict-rules": "^2.0", - "phpunit/phpunit": "^8.5.31 || ^9.5.26", - "webmozarts/strict-phpunit": "^7.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Fidry\\CpuCoreCounter\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Théo FIDRY", - "email": "theo.fidry@gmail.com" - } - ], - "description": "Tiny utility to get the number of CPU cores.", - "keywords": [ - "CPU", - "core" - ], - "support": { - "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/1.3.0" - }, - "funding": [ - { - "url": "https://github.com/theofidry", - "type": "github" - } - ], - "time": "2025-08-14T07:29:31+00:00" - }, - { - "name": "friendsofphp/php-cs-fixer", - "version": "v3.86.0", - "source": { - "type": "git", - "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "4a952bd19dc97879b0620f495552ef09b55f7d36" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/4a952bd19dc97879b0620f495552ef09b55f7d36", - "reference": "4a952bd19dc97879b0620f495552ef09b55f7d36", - "shasum": "" - }, - "require": { - "clue/ndjson-react": "^1.3", - "composer/semver": "^3.4", - "composer/xdebug-handler": "^3.0.5", - "ext-filter": "*", - "ext-hash": "*", - "ext-json": "*", - "ext-tokenizer": "*", - "fidry/cpu-core-counter": "^1.2", - "php": "^7.4 || ^8.0", - "react/child-process": "^0.6.6", - "react/event-loop": "^1.5", - "react/promise": "^3.2", - "react/socket": "^1.16", - "react/stream": "^1.4", - "sebastian/diff": "^4.0.6 || ^5.1.1 || ^6.0.2 || ^7.0", - "symfony/console": "^5.4.47 || ^6.4.13 || ^7.0", - "symfony/event-dispatcher": "^5.4.45 || ^6.4.13 || ^7.0", - "symfony/filesystem": "^5.4.45 || ^6.4.13 || ^7.0", - "symfony/finder": "^5.4.45 || ^6.4.17 || ^7.0", - "symfony/options-resolver": "^5.4.45 || ^6.4.16 || ^7.0", - "symfony/polyfill-mbstring": "^1.32", - "symfony/polyfill-php80": "^1.32", - "symfony/polyfill-php81": "^1.32", - "symfony/process": "^5.4.47 || ^6.4.20 || ^7.2", - "symfony/stopwatch": "^5.4.45 || ^6.4.19 || ^7.0" - }, - "require-dev": { - "facile-it/paraunit": "^1.3.1 || ^2.6", - "infection/infection": "^0.29.14", - "justinrainbow/json-schema": "^5.3 || ^6.4", - "keradus/cli-executor": "^2.2", - "mikey179/vfsstream": "^1.6.12", - "php-coveralls/php-coveralls": "^2.8", - "php-cs-fixer/accessible-object": "^1.1", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.6", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.6", - "phpunit/phpunit": "^9.6.23 || ^10.5.47 || ^11.5.25", - "symfony/polyfill-php84": "^1.32", - "symfony/var-dumper": "^5.4.48 || ^6.4.23 || ^7.3.1", - "symfony/yaml": "^5.4.45 || ^6.4.23 || ^7.3.1" - }, - "suggest": { - "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters." - }, - "bin": [ - "php-cs-fixer" - ], - "type": "application", - "autoload": { - "psr-4": { - "PhpCsFixer\\": "src/" - }, - "exclude-from-classmap": [ - "src/Fixer/Internal/*" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" - } - ], - "description": "A tool to automatically fix PHP code style", - "keywords": [ - "Static code analysis", - "fixer", - "standards", - "static analysis" - ], - "support": { - "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.86.0" - }, - "funding": [ - { - "url": "https://github.com/keradus", - "type": "github" - } - ], - "time": "2025-08-13T22:36:21+00:00" - }, { "name": "glpi-project/tools", - "version": "0.8.0", + "version": "0.8.1", "source": { "type": "git", "url": "https://github.com/glpi-project/tools.git", - "reference": "7c2dcec105ed3427183bdfd382d785363aade436" + "reference": "cf182b1a6bd1a73c5c6469dbbd0edabf7cb5857e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/7c2dcec105ed3427183bdfd382d785363aade436", - "reference": "7c2dcec105ed3427183bdfd382d785363aade436", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/cf182b1a6bd1a73c5c6469dbbd0edabf7cb5857e", + "reference": "cf182b1a6bd1a73c5c6469dbbd0edabf7cb5857e", "shasum": "" }, "require": { @@ -560,26 +61,31 @@ "issues": "https://github.com/glpi-project/tools/issues", "source": "https://github.com/glpi-project/tools" }, - "time": "2025-08-26T10:18:38+00:00" + "time": "2025-09-08T09:45:41+00:00" }, { "name": "psr/container", - "version": "1.1.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -606,750 +112,53 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-11-05T16:50:12+00:00" - }, - { - "name": "psr/event-dispatcher", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/event-dispatcher.git", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\EventDispatcher\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Standard interfaces for event handling.", - "keywords": [ - "events", - "psr", - "psr-14" - ], - "support": { - "issues": "https://github.com/php-fig/event-dispatcher/issues", - "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" - }, - "time": "2019-01-08T18:20:26+00:00" - }, - { - "name": "psr/log", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" - }, - "time": "2021-05-03T11:20:27+00:00" - }, - { - "name": "react/cache", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/cache.git", - "reference": "d47c472b64aa5608225f47965a484b75c7817d5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b", - "reference": "d47c472b64aa5608225f47965a484b75c7817d5b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "react/promise": "^3.0 || ^2.0 || ^1.1" - }, - "require-dev": { - "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Async, Promise-based cache interface for ReactPHP", - "keywords": [ - "cache", - "caching", - "promise", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/cache/issues", - "source": "https://github.com/reactphp/cache/tree/v1.2.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2022-11-30T15:59:55+00:00" - }, - { - "name": "react/child-process", - "version": "v0.6.6", - "source": { - "type": "git", - "url": "https://github.com/reactphp/child-process.git", - "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/child-process/zipball/1721e2b93d89b745664353b9cfc8f155ba8a6159", - "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.0", - "react/event-loop": "^1.2", - "react/stream": "^1.4" - }, - "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/socket": "^1.16", - "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\ChildProcess\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Event-driven library for executing child processes with ReactPHP.", - "keywords": [ - "event-driven", - "process", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/child-process/issues", - "source": "https://github.com/reactphp/child-process/tree/v0.6.6" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2025-01-01T16:37:48+00:00" - }, - { - "name": "react/dns", - "version": "v1.13.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/dns.git", - "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/dns/zipball/eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", - "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "react/cache": "^1.0 || ^0.6 || ^0.5", - "react/event-loop": "^1.2", - "react/promise": "^3.2 || ^2.7 || ^1.2.1" - }, - "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/async": "^4.3 || ^3 || ^2", - "react/promise-timer": "^1.11" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Dns\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Async DNS resolver for ReactPHP", - "keywords": [ - "async", - "dns", - "dns-resolver", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/dns/issues", - "source": "https://github.com/reactphp/dns/tree/v1.13.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2024-06-13T14:18:03+00:00" - }, - { - "name": "react/event-loop", - "version": "v1.5.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/event-loop.git", - "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", - "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" - }, - "suggest": { - "ext-pcntl": "For signal handling support when using the StreamSelectLoop" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\EventLoop\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", - "keywords": [ - "asynchronous", - "event-loop" - ], - "support": { - "issues": "https://github.com/reactphp/event-loop/issues", - "source": "https://github.com/reactphp/event-loop/tree/v1.5.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2023-11-13T13:48:05+00:00" - }, - { - "name": "react/promise", - "version": "v3.3.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise.git", - "reference": "23444f53a813a3296c1368bb104793ce8d88f04a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/23444f53a813a3296c1368bb104793ce8d88f04a", - "reference": "23444f53a813a3296c1368bb104793ce8d88f04a", - "shasum": "" - }, - "require": { - "php": ">=7.1.0" - }, - "require-dev": { - "phpstan/phpstan": "1.12.28 || 1.4.10", - "phpunit/phpunit": "^9.6 || ^7.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "React\\Promise\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "keywords": [ - "promise", - "promises" - ], - "support": { - "issues": "https://github.com/reactphp/promise/issues", - "source": "https://github.com/reactphp/promise/tree/v3.3.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2025-08-19T18:57:03+00:00" - }, - { - "name": "react/socket", - "version": "v1.16.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/socket.git", - "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/socket/zipball/23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1", - "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.0", - "react/dns": "^1.13", - "react/event-loop": "^1.2", - "react/promise": "^3.2 || ^2.6 || ^1.2.1", - "react/stream": "^1.4" - }, - "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/async": "^4.3 || ^3.3 || ^2", - "react/promise-stream": "^1.4", - "react/promise-timer": "^1.11" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Socket\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", - "keywords": [ - "Connection", - "Socket", - "async", - "reactphp", - "stream" - ], - "support": { - "issues": "https://github.com/reactphp/socket/issues", - "source": "https://github.com/reactphp/socket/tree/v1.16.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2024-07-26T10:38:09+00:00" - }, - { - "name": "react/stream", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/stream.git", - "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d", - "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.8", - "react/event-loop": "^1.2" - }, - "require-dev": { - "clue/stream-filter": "~1.2", - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Stream\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", - "keywords": [ - "event-driven", - "io", - "non-blocking", - "pipe", - "reactphp", - "readable", - "stream", - "writable" - ], - "support": { - "issues": "https://github.com/reactphp/stream/issues", - "source": "https://github.com/reactphp/stream/tree/v1.4.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2024-06-11T12:45:25+00:00" - }, - { - "name": "sebastian/diff", - "version": "4.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", - "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3", - "symfony/process": "^4.2 || ^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2024-03-02T06:30:58+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "symfony/console", - "version": "v5.4.47", + "version": "v6.4.26", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed" + "reference": "492de6dfd93910d7d7a729c5a04ddcd2b9e99c4f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", - "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", + "url": "https://api.github.com/repos/symfony/console/zipball/492de6dfd93910d7d7a729c5a04ddcd2b9e99c4f", + "reference": "492de6dfd93910d7d7a729c5a04ddcd2b9e99c4f", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" + "symfony/service-contracts": "^2.5|^3", + "symfony/string": "^5.4|^6.0|^7.0" }, "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" }, "provide": { - "psr/log-implementation": "1.0|2.0" + "psr/log-implementation": "1.0|2.0|3.0" }, "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/lock": "^5.4|^6.0|^7.0", + "symfony/messenger": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/stopwatch": "^5.4|^6.0|^7.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -1383,7 +192,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.47" + "source": "https://github.com/symfony/console/tree/v6.4.26" }, "funding": [ { @@ -1394,29 +203,33 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-11-06T11:30:55+00:00" + "time": "2025-09-26T12:13:46+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.4", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918" + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918", - "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1" }, "type": "library", "extra": { @@ -1425,7 +238,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.6-dev" } }, "autoload": { @@ -1450,7 +263,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" }, "funding": [ { @@ -1466,370 +279,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:11:13+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v5.4.45", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/72982eb416f61003e9bb6e91f8b3213600dcf9e9", - "reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/event-dispatcher-contracts": "^2|^3", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "symfony/dependency-injection": "<4.4" - }, - "provide": { - "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "2.0" - }, - "require-dev": { - "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/http-foundation": "^4.4|^5.0|^6.0", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/stopwatch": "^4.4|^5.0|^6.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.45" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-25T14:11:13+00:00" - }, - { - "name": "symfony/event-dispatcher-contracts", - "version": "v2.5.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f", - "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/event-dispatcher": "^1" - }, - "suggest": { - "symfony/event-dispatcher-implementation": "" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/contracts", - "name": "symfony/contracts" - }, - "branch-alias": { - "dev-main": "2.5-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to dispatching event", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.4" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-25T14:11:13+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v5.4.45", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "57c8294ed37d4a055b77057827c67f9558c95c54" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/57c8294ed37d4a055b77057827c67f9558c95c54", - "reference": "57c8294ed37d4a055b77057827c67f9558c95c54", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" - }, - "require-dev": { - "symfony/process": "^5.4|^6.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides basic utilities for the filesystem", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.45" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-10-22T13:05:35+00:00" - }, - { - "name": "symfony/finder", - "version": "v5.4.45", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "63741784cd7b9967975eec610b256eed3ede022b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/63741784cd7b9967975eec610b256eed3ede022b", - "reference": "63741784cd7b9967975eec610b256eed3ede022b", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Finds files and directories via an intuitive fluent interface", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.45" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-28T13:32:08+00:00" - }, - { - "name": "symfony/options-resolver", - "version": "v5.4.45", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "74e5b6f0db3e8589e6cfd5efb317a1fc2bb52fb6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/74e5b6f0db3e8589e6cfd5efb317a1fc2bb52fb6", - "reference": "74e5b6f0db3e8589e6cfd5efb317a1fc2bb52fb6", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php73": "~1.0", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an improved replacement for the array_replace PHP function", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], - "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.4.45" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-25T14:11:13+00:00" + "time": "2024-09-25T14:21:43+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2166,337 +616,28 @@ ], "time": "2024-12-23T08:48:59+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.33.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", - "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.33.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.33.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", - "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2025-01-02T08:10:11+00:00" - }, - { - "name": "symfony/polyfill-php81", - "version": "v1.33.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, - { - "name": "symfony/process", - "version": "v5.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/5d1662fb32ebc94f17ddb8d635454a776066733d", - "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Executes commands in sub-processes", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/process/tree/v5.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-11-06T11:36:42+00:00" - }, { "name": "symfony/service-contracts", - "version": "v2.5.4", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "f37b419f7aea2e9abf10abd261832cace12e3300" + "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300", - "reference": "f37b419f7aea2e9abf10abd261832cace12e3300", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4", + "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" + "php": ">=8.1", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { "ext-psr": "<1.1|>=2" }, - "suggest": { - "symfony/service-implementation": "" - }, "type": "library", "extra": { "thanks": { @@ -2504,13 +645,16 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.6-dev" } }, "autoload": { "psr-4": { "Symfony\\Contracts\\Service\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2537,7 +681,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.4" + "source": "https://github.com/symfony/service-contracts/tree/v3.6.0" }, "funding": [ { @@ -2553,100 +697,38 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:11:13+00:00" - }, - { - "name": "symfony/stopwatch", - "version": "v5.4.45", - "source": { - "type": "git", - "url": "https://github.com/symfony/stopwatch.git", - "reference": "fb2c199cf302eb207f8c23e7ee174c1c31a5c004" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/fb2c199cf302eb207f8c23e7ee174c1c31a5c004", - "reference": "fb2c199cf302eb207f8c23e7ee174c1c31a5c004", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/service-contracts": "^1|^2|^3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides a way to profile code", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.45" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-25T14:11:13+00:00" + "time": "2025-04-25T09:37:31+00:00" }, { "name": "symfony/string", - "version": "v5.4.47", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "136ca7d72f72b599f2631aca474a4f8e26719799" + "reference": "f96476035142921000338bad71e5247fbc138872" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799", - "reference": "136ca7d72f72b599f2631aca474a4f8e26719799", + "url": "https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872", + "reference": "f96476035142921000338bad71e5247fbc138872", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.2", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" + "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": ">=3.0" + "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" + "symfony/emoji": "^7.1", + "symfony/http-client": "^6.4|^7.0", + "symfony/intl": "^6.4|^7.0", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -2685,7 +767,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.47" + "source": "https://github.com/symfony/string/tree/v7.3.4" }, "funding": [ { @@ -2696,36 +778,39 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-11-10T20:33:58+00:00" + "time": "2025-09-11T14:36:48+00:00" }, { "name": "twig/twig", - "version": "v3.11.3", + "version": "v3.21.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e" + "reference": "285123877d4dd97dd7c11842ac5fb7e86e60d81d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e", - "reference": "3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/285123877d4dd97dd7c11842ac5fb7e86e60d81d", + "reference": "285123877d4dd97dd7c11842ac5fb7e86e60d81d", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.1.0", "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php80": "^1.22", - "symfony/polyfill-php81": "^1.29" + "symfony/polyfill-mbstring": "^1.3" }, "require-dev": { + "phpstan/phpstan": "^2.0", "psr/container": "^1.0|^2.0", "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, @@ -2769,7 +854,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.11.3" + "source": "https://github.com/twigphp/Twig/tree/v3.21.1" }, "funding": [ { @@ -2781,7 +866,7 @@ "type": "tidelift" } ], - "time": "2024-11-07T12:34:41+00:00" + "time": "2025-05-03T07:21:55+00:00" } ], "aliases": [], @@ -2790,11 +875,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4" + "php": ">=8.2" }, "platform-dev": {}, "platform-overrides": { - "php": "7.4.0" + "php": "8.2.99" }, "plugin-api-version": "2.6.0" } diff --git a/example.xml b/example.xml index 583311c..a84001d 100644 --- a/example.xml +++ b/example.xml @@ -24,6 +24,10 @@ Indepnet + + 0.1.0 + ~11.0.0 + 0.0.1 ~10.0.0 diff --git a/front/config.php b/front/config.php index 34dc261..a05f021 100644 --- a/front/config.php +++ b/front/config.php @@ -37,7 +37,7 @@ //header("Location:../../central.php"); // Entry menu case -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkRight('config', UPDATE); @@ -45,5 +45,5 @@ Session::checkRight('config', UPDATE); Plugin::load('example'); Html::header('TITRE', $_SERVER['PHP_SELF'], 'config', 'plugins'); -echo __('This is the plugin config page', 'example'); +echo __s('This is the plugin config page', 'example'); Html::footer(); diff --git a/front/devicecamera.form.php b/front/devicecamera.form.php index df30c36..2402500 100644 --- a/front/devicecamera.form.php +++ b/front/devicecamera.form.php @@ -35,7 +35,7 @@ use GlpiPlugin\Example\DeviceCamera; -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkLoginUser(); $dropdown = new DeviceCamera(); diff --git a/front/devicecamera.php b/front/devicecamera.php index 0abc8c0..54f625d 100644 --- a/front/devicecamera.php +++ b/front/devicecamera.php @@ -33,7 +33,7 @@ // Purpose of file: // ---------------------------------------------------------------------- -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkLoginUser(); $dropdown = new DeviceCamera(); diff --git a/front/dropdown.form.php b/front/dropdown.form.php index 2c514f7..dae3250 100644 --- a/front/dropdown.form.php +++ b/front/dropdown.form.php @@ -35,7 +35,7 @@ use GlpiPlugin\Example\Dropdown; -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkLoginUser(); Plugin::load('example', true); diff --git a/front/dropdown.php b/front/dropdown.php index 4bb99a4..8271b1d 100644 --- a/front/dropdown.php +++ b/front/dropdown.php @@ -35,7 +35,7 @@ use GlpiPlugin\Example\Dropdown; -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkLoginUser(); Plugin::load('example', true); diff --git a/front/example.form.php b/front/example.form.php index 3180563..e9b8877 100644 --- a/front/example.form.php +++ b/front/example.form.php @@ -35,7 +35,7 @@ use GlpiPlugin\Example\Example; -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkLoginUser(); if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { diff --git a/front/example.php b/front/example.php index da6a757..c4cdc76 100644 --- a/front/example.php +++ b/front/example.php @@ -35,7 +35,7 @@ use GlpiPlugin\Example\Example; -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkRight(Example::$rightname, READ); if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { diff --git a/front/popup.php b/front/popup.php index a75896b..0276296 100644 --- a/front/popup.php +++ b/front/popup.php @@ -28,7 +28,7 @@ * ------------------------------------------------------------------------- */ -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkLoginUser(); @@ -39,21 +39,16 @@ if (isset($_GET['popup'])) { if (isset($_SESSION['glpipopup']['name'])) { switch ($_SESSION['glpipopup']['name']) { case 'test_rule': - Html::popHeader(__('Test'), $_SERVER['PHP_SELF']); - include '../../../front/rule.test.php'; + Html::popHeader(__s('Test'), $_SERVER['PHP_SELF']); + include __DIR__ . '/../../../front/rule.test.php'; break; case 'test_all_rules': - Html::popHeader(__('Test rules engine'), $_SERVER['PHP_SELF']); - include '../../../front/rulesengine.test.php'; - break; - - case 'show_cache': - Html::popHeader(__('Cache information'), $_SERVER['PHP_SELF']); - include '../../../front/rule.cache.php'; + Html::popHeader(__s('Test rules engine'), $_SERVER['PHP_SELF']); + include __DIR__ . '/../../../front/rulesengine.test.php'; break; } - echo "

" . __('Back') . ''; + echo "'; Html::popFooter(); } diff --git a/front/ruletest.form.php b/front/ruletest.form.php index e48a834..6235f3c 100644 --- a/front/ruletest.form.php +++ b/front/ruletest.form.php @@ -35,7 +35,7 @@ use GlpiPlugin\Example\RuleTestCollection; -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkLoginUser(); $rulecollection = new RuleTestCollection(); diff --git a/front/ruletest.php b/front/ruletest.php index 16ea9e6..22dd6f1 100644 --- a/front/ruletest.php +++ b/front/ruletest.php @@ -35,7 +35,7 @@ use GlpiPlugin\Example\RuleTestCollection; -include('../../../inc/includes.php'); +include(__DIR__ . '/../../../inc/includes.php'); Session::checkLoginUser(); $rulecollection = new RuleTestCollection(); diff --git a/hook.php b/hook.php index 2484b2e..c7c5983 100644 --- a/hook.php +++ b/hook.php @@ -33,9 +33,7 @@ // Purpose of file: // ---------------------------------------------------------------------- -use GlpiPlugin\Example\Dropdown; use GlpiPlugin\Example\Example; -use Dropdown as GlpiDropdown; function plugin_change_profile_example() { @@ -54,7 +52,7 @@ function plugin_example_getDatabaseRelations() function plugin_example_getDropdown() { // Table => Name - return [Dropdown::class => __('Plugin Example Dropdown', 'example')]; + return [Dropdown::class => __s('Plugin Example Dropdown', 'example')]; } @@ -70,9 +68,8 @@ function plugin_example_getAddSearchOptions($itemtype) $sopt[1001]['table'] = 'glpi_plugin_example_dropdowns'; $sopt[1001]['field'] = 'name'; $sopt[1001]['linkfield'] = 'plugin_example_dropdowns_id'; - $sopt[1001]['name'] = __('Example plugin', 'example'); + $sopt[1001]['name'] = __s('Example plugin', 'example'); } - return $sopt; } @@ -86,10 +83,9 @@ function plugin_example_getAddSearchOptionsNew($itemtype) 'table' => 'glpi_plugin_example_dropdowns', 'field' => 'name', 'linkfield' => 'plugin_example_dropdowns_id', - 'name' => __('Example plugin new', 'example'), + 'name' => __s('Example plugin new', 'example'), ]; } - return $options; } @@ -201,7 +197,6 @@ function plugin_example_forceGroupBy($type) // Force add GROUP BY IN REQUEST return true; } - return false; } @@ -212,7 +207,7 @@ function plugin_example_addWhere($link, $nott, $type, $ID, $val, $searchtype) $table = $searchopt[$ID]['table']; $field = $searchopt[$ID]['field']; - $SEARCH = Search::makeTextSearch($val, $nott); + Search::makeTextSearch($val, $nott); // Example of standard Where clause but use it ONLY for specific Where // No need of the function if you do not have specific cases @@ -250,7 +245,7 @@ function plugin_example_addHaving($link, $nott, $type, $ID, $val, $num) $ADD = " OR ITEM_$num IS NULL"; } - return " $LINK ( ITEM_" . $num . $SEARCH . " $ADD ) "; + return " $link ( ITEM_" . $num . $SEARCH . " $ADD ) "; } return ''; @@ -260,8 +255,6 @@ function plugin_example_addHaving($link, $nott, $type, $ID, $val, $num) function plugin_example_addSelect($type, $ID, $num) { $searchopt = &Search::getOptions($type); - $table = $searchopt[$ID]['table']; - $field = $searchopt[$ID]['field']; // Example of standard Select clause but use it ONLY for specific Select // No need of the function if you do not have specific cases @@ -276,8 +269,6 @@ function plugin_example_addSelect($type, $ID, $num) function plugin_example_addOrderBy($type, $ID, $order, $key = 0) { $searchopt = &Search::getOptions($type); - $table = $searchopt[$ID]['table']; - $field = $searchopt[$ID]['field']; // Example of standard OrderBy clause but use it ONLY for specific order by // No need of the function if you do not have specific cases @@ -299,7 +290,7 @@ function plugin_example_MassiveActions($type) switch ($type) { // New action for core and other plugin types : name = plugin_PLUGINNAME_actionname case 'Computer': - return [Example::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'DoIt' => __('plugin_example_DoIt', 'example')]; + return [Example::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'DoIt' => __s('plugin_example_DoIt', 'example')]; // Actions for types provided by the plugin are included inside the classes } @@ -316,13 +307,12 @@ function plugin_example_MassiveActionsFieldsDisplay($options = []) $table = $options['options']['table']; $field = $options['options']['field']; - $linkfield = $options['options']['linkfield']; if ($table == getTableForItemType($options['itemtype'])) { // Table fields switch ($table . '.' . $field) { case 'glpi_plugin_example_examples.serial': - echo __('Not really specific - Just for example', 'example'); + echo __s('Not really specific - Just for example', 'example'); // Dropdown::showYesNo($linkfield); // Need to return true if specific display @@ -332,13 +322,12 @@ function plugin_example_MassiveActionsFieldsDisplay($options = []) // Linked Fields switch ($table . '.' . $field) { case 'glpi_plugin_example_dropdowns.name': - echo __('Not really specific - Just for example', 'example'); + echo __s('Not really specific - Just for example', 'example'); // Need to return true if specific display return true; } } - // Need to return false on non display item return false; } @@ -355,8 +344,8 @@ function plugin_example_searchOptionsValues($options = []) // Table fields switch ($table . '.' . $field) { case 'glpi_plugin_example_examples.serial': - echo __('Not really specific - Use your own dropdown - Just for example', 'example'); - GlpiDropdown::show( + echo __s('Not really specific - Use your own dropdown - Just for example', 'example'); + Dropdown::show( getItemTypeForTable($options['searchoption']['table']), ['value' => $options['value'], 'name' => $options['name'], @@ -382,14 +371,14 @@ function plugin_pre_item_update_example($item) } $item->input['comment'] .= addslashes("\nUpdate: ".date('r')); */ - Session::addMessageAfterRedirect(__('Pre Update Computer Hook', 'example'), true); + Session::addMessageAfterRedirect(__s('Pre Update Computer Hook', 'example'), true); } // Hook done on update item case function plugin_item_update_example($item) { - Session::addMessageAfterRedirect(sprintf(__('Update Computer Hook (%s)', 'example'), implode(',', $item->updates)), true); + Session::addMessageAfterRedirect(sprintf(__s('Update Computer Hook (%s)', 'example'), implode(',', $item->updates)), true); return true; } @@ -399,7 +388,7 @@ function plugin_item_update_example($item) function plugin_item_empty_example($item) { if (empty($_SESSION['Already displayed "Empty Computer Hook"'])) { - Session::addMessageAfterRedirect(__('Empty Computer Hook', 'example'), true); + Session::addMessageAfterRedirect(__s('Empty Computer Hook', 'example'), true); $_SESSION['Already displayed "Empty Computer Hook"'] = true; } @@ -411,14 +400,14 @@ function plugin_item_empty_example($item) function plugin_pre_item_delete_example($object) { // Manipulate data if needed - Session::addMessageAfterRedirect(__('Pre Delete Computer Hook', 'example'), true); + Session::addMessageAfterRedirect(__s('Pre Delete Computer Hook', 'example'), true); } // Hook done on delete item case function plugin_item_delete_example($object) { - Session::addMessageAfterRedirect(__('Delete Computer Hook', 'example'), true); + Session::addMessageAfterRedirect(__s('Delete Computer Hook', 'example'), true); return true; } @@ -428,14 +417,14 @@ function plugin_item_delete_example($object) function plugin_pre_item_purge_example($object) { // Manipulate data if needed - Session::addMessageAfterRedirect(__('Pre Purge Computer Hook', 'example'), true); + Session::addMessageAfterRedirect(__s('Pre Purge Computer Hook', 'example'), true); } // Hook done on purge item case function plugin_item_purge_example($object) { - Session::addMessageAfterRedirect(__('Purge Computer Hook', 'example'), true); + Session::addMessageAfterRedirect(__s('Purge Computer Hook', 'example'), true); return true; } @@ -445,7 +434,7 @@ function plugin_item_purge_example($object) function plugin_pre_item_restore_example($item) { // Manipulate data if needed - Session::addMessageAfterRedirect(__('Pre Restore Computer Hook', 'example')); + Session::addMessageAfterRedirect(__s('Pre Restore Computer Hook', 'example')); } @@ -453,14 +442,14 @@ function plugin_pre_item_restore_example($item) function plugin_pre_item_restore_example2($item) { // Manipulate data if needed - Session::addMessageAfterRedirect(__('Pre Restore Phone Hook', 'example')); + Session::addMessageAfterRedirect(__s('Pre Restore Phone Hook', 'example')); } // Hook done on restore item case function plugin_item_restore_example($item) { - Session::addMessageAfterRedirect(__('Restore Computer Hook', 'example')); + Session::addMessageAfterRedirect(__s('Restore Computer Hook', 'example')); return true; } @@ -471,7 +460,7 @@ function plugin_item_transfer_example($parm) { //TRANS: %1$s is the source type, %2$d is the source ID, %3$d is the destination ID Session::addMessageAfterRedirect(sprintf( - __('Transfer Computer Hook %1$s %2$d -> %3$d', 'example'), + __s('Transfer Computer Hook %1$s %2$d -> %3$d', 'example'), $parm['type'], $parm['id'], $parm['newID'], @@ -551,7 +540,7 @@ function plugin_example_install() PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; - $DB->query($query) or die('error creating glpi_plugin_example_examples ' . $DB->error()); + $DB->doQuery($query); $query = "INSERT INTO `glpi_plugin_example_examples` (`id`, `name`, `serial`, `plugin_example_dropdowns_id`, `is_deleted`, @@ -559,7 +548,7 @@ function plugin_example_install() VALUES (1, 'example 1', 'serial 1', 1, 0, 0, NULL), (2, 'example 2', 'serial 2', 2, 0, 0, NULL), (3, 'example 3', 'serial 3', 1, 0, 0, NULL)"; - $DB->query($query) or die('error populate glpi_plugin_example ' . $DB->error()); + $DB->doQuery($query); } if (!$DB->tableExists('glpi_plugin_example_dropdowns')) { @@ -571,14 +560,14 @@ function plugin_example_install() KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; - $DB->query($query) or die('error creating glpi_plugin_example_dropdowns' . $DB->error()); + $DB->doQuery($query); $query = "INSERT INTO `glpi_plugin_example_dropdowns` (`id`, `name`, `comment`) VALUES (1, 'dp 1', 'comment 1'), (2, 'dp2', 'comment 2')"; - $DB->query($query) or die('error populate glpi_plugin_example_dropdowns' . $DB->error()); + $DB->doQuery($query); } if (!$DB->tableExists('glpi_plugin_example_devicecameras')) { @@ -592,7 +581,7 @@ function plugin_example_install() KEY `manufacturers_id` (`manufacturers_id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; - $DB->query($query) or die('error creating glpi_plugin_example_examples ' . $DB->error()); + $DB->doQuery($query); } if (!$DB->tableExists('glpi_plugin_example_items_devicecameras')) { @@ -610,13 +599,12 @@ function plugin_example_install() KEY `is_dynamic` (`is_dynamic`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; - $DB->query($query) or die('error creating glpi_plugin_example_examples ' . $DB->error()); + $DB->doQuery($query); } // To be called for each task the plugin manage // task in class CronTask::Register(Example::class, 'Sample', DAY_TIMESTAMP, ['param' => 50]); - return true; } @@ -645,28 +633,28 @@ function plugin_example_uninstall() // Old version tables if ($DB->tableExists('glpi_dropdown_plugin_example')) { $query = 'DROP TABLE `glpi_dropdown_plugin_example`'; - $DB->query($query) or die('error deleting glpi_dropdown_plugin_example'); + $DB->doQuery($query); } if ($DB->tableExists('glpi_plugin_example')) { $query = 'DROP TABLE `glpi_plugin_example`'; - $DB->query($query) or die('error deleting glpi_plugin_example'); + $DB->doQuery($query); } // Current version tables if ($DB->tableExists('glpi_plugin_example_example')) { $query = 'DROP TABLE `glpi_plugin_example_example`'; - $DB->query($query) or die('error deleting glpi_plugin_example_example'); + $DB->doQuery($query); } if ($DB->tableExists('glpi_plugin_example_dropdowns')) { $query = 'DROP TABLE `glpi_plugin_example_dropdowns`;'; - $DB->query($query) or die('error deleting glpi_plugin_example_dropdowns'); + $DB->doQuery($query); } if ($DB->tableExists('glpi_plugin_example_devicecameras')) { $query = 'DROP TABLE `glpi_plugin_example_devicecameras`;'; - $DB->query($query) or die('error deleting glpi_plugin_example_devicecameras'); + $DB->doQuery($query); } if ($DB->tableExists('glpi_plugin_example_items_devicecameras')) { $query = 'DROP TABLE `glpi_plugin_example_items_devicecameras`;'; - $DB->query($query) or die('error deleting glpi_plugin_example_items_devicecameras'); + $DB->doQuery($query); } return true; @@ -683,13 +671,13 @@ function plugin_example_AssignToTicket($types) function plugin_example_get_events(NotificationTargetTicket $target) { - $target->events['plugin_example'] = __('Example event', 'example'); + $target->events['plugin_example'] = __s('Example event', 'example'); } function plugin_example_get_datas(NotificationTargetTicket $target) { - $target->data['##ticket.example##'] = __('Example datas', 'example'); + $target->data['##ticket.example##'] = __s('Example datas', 'example'); } @@ -710,7 +698,7 @@ function plugin_example_postinit() * * @param $datas array * - * @return un tableau + * @return array **/ function plugin_retrieve_more_data_from_ldap_example(array $datas) { @@ -723,7 +711,7 @@ function plugin_retrieve_more_data_from_ldap_example(array $datas) * * @param $fields array * - * @return un tableau + * @return array **/ function plugin_retrieve_more_field_from_ldap_example($fields) { @@ -736,6 +724,7 @@ function plugin_example_Status($param) // Do checks (no check for example) $ok = true; echo 'example plugin: example'; + if ($ok) { echo '_OK'; } else { @@ -744,7 +733,6 @@ function plugin_example_Status($param) $param['ok'] = false; } echo "\n"; - return $param; } @@ -752,7 +740,7 @@ function plugin_example_display_central() { echo ""; echo "
"; - echo __('Plugin example displays on central page', 'example'); + echo __s('Plugin example displays on central page', 'example'); echo '
'; echo ''; } @@ -760,21 +748,20 @@ function plugin_example_display_central() function plugin_example_display_login() { echo "
"; - echo __('Plugin example displays on login page', 'example'); + echo __s('Plugin example displays on login page', 'example'); echo '
'; } function plugin_example_infocom_hook($params) { echo ""; - echo __('Plugin example displays on central page', 'example'); + echo __s('Plugin example displays on central page', 'example'); echo ''; } function plugin_example_filter_actors(array $params = []): array { $itemtype = $params['params']['itemtype']; - $items_id = $params['params']['items_id']; // remove users_id = 1 for assignee list if ($itemtype == 'Ticket' && $params['params']['actortype'] == 'assign') { @@ -790,12 +777,15 @@ function plugin_example_filter_actors(array $params = []): array function plugin_example_set_impact_icon(array $params) { + /** @var array $CFG_GLPI */ + global $CFG_GLPI; + $itemtype = $params['itemtype']; $items_id = $params['items_id']; $item = getItemForItemtype($itemtype); if ($item instanceof Computer && $item->getFromDB($items_id)) { - return Plugin::getWebDir('example', true, false) . '/public/computer_icon.svg'; + return $CFG_GLPI['root_doc'] . '/plugins/example/public/computer_icon.svg'; } return null; diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..8cf33ad --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,19 @@ +parameters: + parallel: + maximumNumberOfProcesses: 2 + level: 5 + paths: + - front + - src + - hook.php + - report.php + - setup.php + - stat.php + scanDirectories: + - ../../inc + - ../../src + - ../../front + bootstrapFiles: + - ../../stubs/glpi_constants.php + - ../../vendor/autoload.php + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..7958e23 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..5b24fa4 --- /dev/null +++ b/rector.php @@ -0,0 +1,97 @@ +. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2006-2022 by Example plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/example + * ------------------------------------------------------------------------- + */ + +require_once __DIR__ . '/../../src/Plugin.php'; + +use Rector\Caching\ValueObject\Storage\FileCacheStorage; +use Rector\CodeQuality\Rector as CodeQuality; +use Rector\Config\RectorConfig; +use Rector\DeadCode\Rector as DeadCode; +use Rector\ValueObject\PhpVersion; + +return RectorConfig::configure() + ->withPaths([ + __DIR__ . '/front', + __DIR__ . '/src', + ]) + ->withPhpVersion(PhpVersion::PHP_82) + ->withCache( + cacheClass: FileCacheStorage::class, + cacheDirectory: sys_get_temp_dir() . '/example-rector', + ) + ->withRootFiles() + ->withParallel(timeoutSeconds: 300) + ->withImportNames(removeUnusedImports: true) + ->withRules([ + CodeQuality\Assign\CombinedAssignRector::class, + CodeQuality\BooleanAnd\RemoveUselessIsObjectCheckRector::class, + CodeQuality\BooleanAnd\SimplifyEmptyArrayCheckRector::class, + CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class, + CodeQuality\Catch_\ThrowWithPreviousExceptionRector::class, + CodeQuality\Empty_\SimplifyEmptyCheckOnEmptyArrayRector::class, + CodeQuality\Expression\InlineIfToExplicitIfRector::class, + CodeQuality\Expression\TernaryFalseExpressionToIfRector::class, + CodeQuality\For_\ForRepeatedCountToOwnVariableRector::class, + CodeQuality\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class, + CodeQuality\Foreach_\ForeachToInArrayRector::class, + CodeQuality\Foreach_\SimplifyForeachToCoalescingRector::class, + CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class, + CodeQuality\FuncCall\ChangeArrayPushToArrayAssignRector::class, + CodeQuality\FuncCall\CompactToVariablesRector::class, + CodeQuality\FuncCall\InlineIsAInstanceOfRector::class, + CodeQuality\FuncCall\IsAWithStringWithThirdArgumentRector::class, + CodeQuality\FuncCall\RemoveSoleValueSprintfRector::class, + CodeQuality\FuncCall\SetTypeToCastRector::class, + CodeQuality\FuncCall\SimplifyFuncGetArgsCountRector::class, + CodeQuality\FuncCall\SimplifyInArrayValuesRector::class, + CodeQuality\FuncCall\SimplifyStrposLowerRector::class, + CodeQuality\FuncCall\UnwrapSprintfOneArgumentRector::class, + CodeQuality\Identical\BooleanNotIdenticalToNotIdenticalRector::class, + CodeQuality\Identical\SimplifyArraySearchRector::class, + CodeQuality\Identical\SimplifyConditionsRector::class, + CodeQuality\Identical\StrlenZeroToIdenticalEmptyStringRector::class, + CodeQuality\If_\CombineIfRector::class, + CodeQuality\If_\CompleteMissingIfElseBracketRector::class, + CodeQuality\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, + CodeQuality\If_\ExplicitBoolCompareRector::class, + CodeQuality\If_\ShortenElseIfRector::class, + CodeQuality\If_\SimplifyIfElseToTernaryRector::class, + CodeQuality\If_\SimplifyIfNotNullReturnRector::class, + CodeQuality\If_\SimplifyIfNullableReturnRector::class, + CodeQuality\If_\SimplifyIfReturnBoolRector::class, + CodeQuality\Include_\AbsolutizeRequireAndIncludePathRector::class, + CodeQuality\LogicalAnd\AndAssignsToSeparateLinesRector::class, + CodeQuality\LogicalAnd\LogicalToBooleanRector::class, + CodeQuality\NotEqual\CommonNotEqualRector::class, + CodeQuality\Ternary\UnnecessaryTernaryExpressionRector::class, + DeadCode\Assign\RemoveUnusedVariableAssignRector::class, + ]) + ->withPhpSets(php74: true) // apply PHP sets up to PHP 7.4 +; diff --git a/setup.php b/setup.php index 8d71794..7a24a49 100644 --- a/setup.php +++ b/setup.php @@ -27,24 +27,24 @@ * @link https://github.com/pluginsGLPI/example * ------------------------------------------------------------------------- */ - use Glpi\Plugin\Hooks; use GlpiPlugin\Example\Computer; use GlpiPlugin\Example\Config; -use GlpiPlugin\Example\Dropdown; use GlpiPlugin\Example\DeviceCamera; +use GlpiPlugin\Example\Dropdown; use GlpiPlugin\Example\Example; use GlpiPlugin\Example\Filters\ComputerModelFilter; use GlpiPlugin\Example\ItemForm; +use GlpiPlugin\Example\Profile; use GlpiPlugin\Example\RuleTestCollection; use GlpiPlugin\Example\Showtabitem; -define('PLUGIN_EXAMPLE_VERSION', '0.0.1'); +define('PLUGIN_EXAMPLE_VERSION', '0.1.0'); // Minimal GLPI version, inclusive -define('PLUGIN_EXAMPLE_MIN_GLPI', '10.0.0'); +define('PLUGIN_EXAMPLE_MIN_GLPI', '11.0.0'); // Maximum GLPI version, exclusive -define('PLUGIN_EXAMPLE_MAX_GLPI', '10.0.99'); +define('PLUGIN_EXAMPLE_MAX_GLPI', '11.0.99'); /** * Init hooks of the plugin. @@ -86,13 +86,11 @@ function plugin_init_example() ['device_types' => true], ); - if (version_compare(GLPI_VERSION, '9.1', 'ge')) { - if (class_exists(Example::class)) { - Link::registerTag(Example::$tags); - } + if (version_compare(GLPI_VERSION, '9.1', 'ge') && class_exists(Example::class)) { + Link::registerTag(Example::$tags); } // Display a menu entry ? - Plugin::registerClass(\GlpiPlugin\Example\Profile::class, ['addtabon' => ['Profile']]); + Plugin::registerClass(Profile::class, ['addtabon' => ['Profile']]); if (Example::canView()) { // Right set in change_profile hook $PLUGIN_HOOKS['menu_toadd']['example'] = ['plugins' => Example::class, 'tools' => Example::class]; @@ -250,9 +248,6 @@ function plugin_init_example() $PLUGIN_HOOKS['status']['example'] = 'plugin_example_Status'; - // CSRF compliance : All actions must be done via POST and forms closed by Html::closeForm(); - $PLUGIN_HOOKS[Hooks::CSRF_COMPLIANT]['example'] = true; - $PLUGIN_HOOKS[Hooks::DISPLAY_CENTRAL]['example'] = 'plugin_example_display_central'; $PLUGIN_HOOKS[Hooks::DISPLAY_LOGIN]['example'] = 'plugin_example_display_login'; $PLUGIN_HOOKS[Hooks::INFOCOM]['example'] = 'plugin_example_infocom_hook'; @@ -267,11 +262,8 @@ function plugin_init_example() $PLUGIN_HOOKS[Hooks::PRE_ITEM_FORM]['example'] = [ItemForm::class, 'preItemForm']; $PLUGIN_HOOKS[Hooks::POST_ITEM_FORM]['example'] = [ItemForm::class, 'postItemForm']; - //TODO: remove check when GLPI 11.0.0 is released - if (version_compare(GLPI_VERSION, '11.0.0', 'ge')) { - $PLUGIN_HOOKS[Hooks::PRE_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'preSection']; - $PLUGIN_HOOKS[Hooks::POST_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'postSection']; - } + $PLUGIN_HOOKS[Hooks::PRE_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'preSection']; + $PLUGIN_HOOKS[Hooks::POST_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'postSection']; // Add new actions to timeline $PLUGIN_HOOKS[Hooks::TIMELINE_ACTIONS]['example'] = [ @@ -297,11 +289,8 @@ function plugin_init_example() ComputerModelFilter::class, ]; - //TODO: remove check when GLPI 11.0.0 is released - if (version_compare(GLPI_VERSION, '11.0.0', 'ge')) { - // Icon in the impact analysis - $PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon'; - } + // Icon in the impact analysis + $PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon'; } @@ -337,11 +326,7 @@ function plugin_version_example() */ function plugin_example_check_prerequisites() { - if (false) { - return false; - } - - return true; + return !false; } /** @@ -358,8 +343,7 @@ function plugin_example_check_config($verbose = false) } if ($verbose) { - echo __('Installed / not configured', 'example'); + echo __s('Installed / not configured', 'example'); } - return false; } diff --git a/src/Child.php b/src/Child.php index b2960c8..e58a8b4 100644 --- a/src/Child.php +++ b/src/Child.php @@ -59,25 +59,25 @@ class Child extends CommonDBChild // - CommonDBConnexity::HAVE_SAME_RIGHT_ON_ITEM we must have at least update right // on the item // * $mustBeAttached: some CommonDBChild can be free, without any parent. - public static function canCreate() + public static function canCreate(): bool { return (Session::haveRight('internet', UPDATE) && parent::canCreate()); } - public static function canView() + public static function canView(): bool { return (Session::haveRight('internet', READ) && parent::canView()); } - public static function canUpdate() + public static function canUpdate(): bool { return (Session::haveRight('internet', UPDATE) && parent::canUpdate()); } - public static function canDelete() + public static function canDelete(): bool { return (Session::haveRight('internet', DELETE) && parent::canDelete()); diff --git a/src/Computer.php b/src/Computer.php index 31a4cd5..efe4e63 100644 --- a/src/Computer.php +++ b/src/Computer.php @@ -37,23 +37,17 @@ namespace GlpiPlugin\Example; use CommonDBTM; -// Class of the defined type - -if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); -} - class Computer extends CommonDBTM { public static function showInfo() { echo ''; echo ''; - echo ''; + echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . __('More information') . '' . __s('More information') . '
'; - echo __('Test successful'); + echo __s('Test successful'); echo '
'; @@ -71,7 +65,7 @@ class Computer extends CommonDBTM public static function add_default_where($in) { - list($itemtype, $condition) = $in; + [$itemtype, $condition] = $in; if ($itemtype == 'Computer') { $table = getTableForItemType($itemtype); $condition .= ' (' . $table . '.groups_id NOT IN (' . implode(',', $_SESSION['glpigroups']) . '))'; diff --git a/src/Config.php b/src/Config.php index baf00b3..9f1f602 100644 --- a/src/Config.php +++ b/src/Config.php @@ -44,10 +44,8 @@ class Config extends CommonDBTM public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - if (!$withtemplate) { - if ($item->getType() == 'Config') { - return __('Example plugin'); - } + if (!$withtemplate && $item->getType() == 'Config') { + return __s('Example plugin'); } return ''; @@ -73,10 +71,10 @@ class Config extends CommonDBTM echo "
"; echo "
"; echo ""; - echo "'; - echo ''; + echo "'; + echo ''; echo "'; @@ -96,5 +94,6 @@ class Config extends CommonDBTM $config = new self(); $config->showFormExample(); } + return true; } } diff --git a/src/DeviceCamera.php b/src/DeviceCamera.php index 83e56a1..8fdb024 100644 --- a/src/DeviceCamera.php +++ b/src/DeviceCamera.php @@ -37,17 +37,11 @@ namespace GlpiPlugin\Example; use CommonDevice; -// Class of the defined type - -if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); -} - /// Class DeviceCamera class DeviceCamera extends CommonDevice { public static function getTypeName($nb = 0) { - return _n('Camera', 'Cameras', $nb); + return _sn('Camera', 'Cameras', $nb); } } diff --git a/src/Document.php b/src/Document.php index 267b40a..fc81200 100644 --- a/src/Document.php +++ b/src/Document.php @@ -1,30 +1,31 @@ . --------------------------------------------------------------------------- +/** + * ------------------------------------------------------------------------- + * Example plugin for GLPI + * ------------------------------------------------------------------------- + * + * LICENSE + * + * This file is part of Example. + * + * Example is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Example is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Example. If not, see . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2006-2022 by Example plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/example + * ------------------------------------------------------------------------- */ /** @@ -58,10 +59,6 @@ namespace GlpiPlugin\Example; use Document as GlpiDocument; -if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access this file directly"); -} - class Document extends GlpiDocument { /** @@ -74,9 +71,9 @@ class Document extends GlpiDocument public static function getTable($classname = null) { if ($classname === null) { - $classname = get_called_class(); + $classname = static::class; } - if ($classname == get_called_class()) { + if ($classname == static::class) { return parent::getTable(Document::class); } @@ -128,11 +125,9 @@ class Document extends GlpiDocument public function post_getFromDB() { // Check the user can view this itemtype and can view this item - if ($this->canView() && $this->canViewItem()) { - if (isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] == 'application/octet-stream' - || isset($_GET['alt']) && $_GET['alt'] == 'media') { - $this->sendFile(); // and terminate script - } + if ($this->canView() && $this->canViewItem() && (isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] == 'application/octet-stream' || isset($_GET['alt']) && $_GET['alt'] == 'media')) { + $this->sendFile(); + // and terminate script } } @@ -167,14 +162,12 @@ class Document extends GlpiDocument } // set range if specified by the client - if (isset($_SERVER['HTTP_RANGE'])) { - if (preg_match('/bytes=\h*(\d+)?-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) { - if (!empty($matches[1])) { - $begin = intval($matches[1]); - } - if (!empty($matches[2])) { - $end = min(intval($matches[2]), $end); - } + if (isset($_SERVER['HTTP_RANGE']) && preg_match('/bytes=\h*(\d+)?-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) { + if (!empty($matches[1])) { + $begin = intval($matches[1]); + } + if (!empty($matches[2])) { + $end = min(intval($matches[2]), $end); } } diff --git a/src/Dropdown.php b/src/Dropdown.php index c3f29ea..468796b 100644 --- a/src/Dropdown.php +++ b/src/Dropdown.php @@ -43,9 +43,9 @@ class Dropdown extends CommonDropdown public static function getTypeName($nb = 0) { if ($nb > 0) { - return __('Plugin Example Dropdowns', 'example'); + return __s('Plugin Example Dropdowns', 'example'); } - return __('Plugin Example Dropdowns', 'example'); + return __s('Plugin Example Dropdowns', 'example'); } } diff --git a/src/Example.php b/src/Example.php index 2d1e90c..23e3df8 100644 --- a/src/Example.php +++ b/src/Example.php @@ -35,13 +35,19 @@ namespace GlpiPlugin\Example; +use Central; use CommonDBTM; use CommonGLPI; use Computer; use Html; +use Item_Disk; use Log; use MassiveAction; +use Notification; +use Phone; +use Preference; use Session; +use Supplier; // Class of the defined type class Example extends CommonDBTM @@ -57,7 +63,7 @@ class Example extends CommonDBTM public static function getMenuName() { - return __('Example plugin'); + return __s('Example plugin'); } public static function getAdditionalMenuLinks() @@ -90,7 +96,7 @@ class Example extends CommonDBTM echo ""; - echo ''; + echo ''; echo ''; @@ -106,28 +112,28 @@ class Example extends CommonDBTM $tab[] = [ 'id' => 'common', - 'name' => __('Header Needed'), + 'name' => __s('Header Needed'), ]; $tab[] = [ 'id' => '1', 'table' => 'glpi_plugin_example_examples', 'field' => 'name', - 'name' => __('Name'), + 'name' => __s('Name'), ]; $tab[] = [ 'id' => '2', 'table' => 'glpi_plugin_example_dropdowns', 'field' => 'name', - 'name' => __('Dropdown'), + 'name' => __s('Dropdown'), ]; $tab[] = [ 'id' => '3', 'table' => 'glpi_plugin_example_examples', 'field' => 'serial', - 'name' => __('Serial number'), + 'name' => __s('Serial number'), 'usehaving' => true, 'searchtype' => 'equals', ]; @@ -136,7 +142,7 @@ class Example extends CommonDBTM 'id' => '30', 'table' => 'glpi_plugin_example_examples', 'field' => 'id', - 'name' => __('ID'), + 'name' => __s('ID'), 'usehaving' => true, 'searchtype' => 'equals', ]; @@ -155,8 +161,8 @@ class Example extends CommonDBTM { switch ($name) { case 'Sample': - return ['description' => __('Cron description for example', 'example'), - 'parameter' => __('Cron parameter for example', 'example')]; + return ['description' => __s('Cron description for example', 'example'), + 'parameter' => __s('Cron parameter for example', 'example')]; } return []; @@ -167,7 +173,7 @@ class Example extends CommonDBTM * * @param $task Object of CronTask class for log / stat * - * @return interger + * @return int * >0 : done * <0 : to be run again (not finished) * 0 : nothing to do @@ -211,33 +217,34 @@ class Example extends CommonDBTM public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if (!$withtemplate) { - switch ($item->getType()) { - case 'Profile': - if ($item->getField('central')) { - return __('Example', 'example'); - } - break; + if ($item instanceof Profile) { + if ($item->getField('central')) { + return __s('Example', 'example'); + } - case 'Phone': - if ($_SESSION['glpishow_count_on_tabs']) { - return self::createTabEntry( - __('Example', 'example'), - countElementsInTable($this->getTable()), - ); - } + } elseif ($item instanceof Phone) { + if ($_SESSION['glpishow_count_on_tabs']) { + return self::createTabEntry( + __s('Example', 'example'), + countElementsInTable($this->getTable()), + ); + } - return __('Example', 'example'); + return __s('Example', 'example'); - case 'ComputerDisk': - case 'Supplier': - return [1 => __('Test Plugin', 'example'), - 2 => __('Test Plugin 2', 'example')]; + } elseif ($item instanceof Item_Disk || $item instanceof Supplier) { + return [ + 1 => __s('Test Plugin', 'example'), + 2 => __s('Test Plugin 2', 'example'), + ]; - case 'Computer': - case 'Central': - case 'Preference': - case 'Notification': - return [1 => __('Test Plugin', 'example')]; + } elseif ($item instanceof Computer + || $item instanceof Central + || $item instanceof Preference + || $item instanceof Notification) { + return [ + 1 => __s('Test Plugin', 'example'), + ]; } } @@ -246,53 +253,46 @@ class Example extends CommonDBTM public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - switch ($item->getType()) { - case 'Phone': - echo __('Plugin Example on Phone', 'example'); - break; + if ($item instanceof Phone) { + echo __s('Plugin Example on Phone', 'example'); - case 'Central': - echo __('Plugin central action', 'example'); - break; + } elseif ($item instanceof Central) { + echo __s('Plugin central action', 'example'); - case 'Preference': - // Complete form display - $data = plugin_version_example(); + } elseif ($item instanceof Preference) { + // Complete form display + $data = plugin_version_example(); - echo ""; - echo "
" . __('Example setup') . '
' . __('My boolean choice :') . '
" . __s('Example setup') . '
' . __s('My boolean choice :') . '"; - echo ""; + echo ""; echo ""; Dropdown::showYesNo('configuration', $my_config['configuration']); echo '
' . __('ID') . '' . __s('ID') . ''; echo $ID; echo '
"; - echo "'; + echo ""; + echo "
" . $data['name'] . ' - ' . $data['version']; - echo '
"; + echo "'; - echo ""; - echo ''; + echo ""; + echo ''; - echo ""; - echo ''; + echo ""; + echo ''; - echo '
" . $data['name'] . ' - ' . $data['version']; + echo '
Name of the prefInput to set the pref
Name of the prefInput to set the pref
'; - echo ''; - break; + echo ''; + echo ''; - case 'Notification': - echo __('Plugin mailing action', 'example'); - break; + } elseif ($item instanceof Notification) { + echo __s('Plugin mailing action', 'example'); - case 'ComputerDisk': - case 'Supplier': - if ($tabnum == 1) { - echo __('First tab of Plugin example', 'example'); - } else { - echo __('Second tab of Plugin example', 'example'); - } - break; + } elseif ($item instanceof Item_Disk || $item instanceof Supplier) { + if ($tabnum == 1) { + echo __s('First tab of Plugin example', 'example'); + } else { + echo __s('Second tab of Plugin example', 'example'); + } - default: - //TRANS: %1$s is a class name, %2$d is an item ID - printf(__('Plugin example CLASS=%1$s id=%2$d', 'example'), $item->getType(), $item->getField('id')); - break; + } else { + //TRANS: %1$s is a class name, %2$d is an item ID + printf(__s('Plugin example CLASS=%1$s', 'example'), get_class($item)); } + return true; } @@ -320,7 +320,7 @@ class Example extends CommonDBTM $key = $parm['begin'] . '$$$' . 'plugin_example1'; $output[$key]['begin'] = date('Y-m-d 17:00:00'); $output[$key]['end'] = date('Y-m-d 18:00:00'); - $output[$key]['name'] = __('test planning example 1', 'example'); + $output[$key]['name'] = __s('test planning example 1', 'example'); // Specify the itemtype to be able to use specific display system $output[$key]['itemtype'] = Example::class; // Set the ID using the ID of the item in the database to have unique ID @@ -337,7 +337,7 @@ class Example extends CommonDBTM * @param $type position of the item in the time block (in, through, begin or end) * @param $complete complete display (more details) * - * @return Nothing (display function) + * @return void (display function) **/ public static function displayPlanningItem(array $val, $who, $type = '', $complete = 0) { @@ -347,7 +347,7 @@ class Example extends CommonDBTM case 'in': //TRANS: %1$s is the start time of a planned item, %2$s is the end printf( - __('From %1$s to %2$s :'), + __s('From %1$s to %2$s :'), date('H:i', strtotime($val['begin'])), date('H:i', strtotime($val['end'])), ); @@ -359,12 +359,12 @@ class Example extends CommonDBTM case 'begin': //TRANS: %s is the start time of a planned item - printf(__('Start at %s:'), date('H:i', strtotime($val['begin']))); + printf(__s('Start at %s:'), date('H:i', strtotime($val['begin']))); break; case 'end': //TRANS: %s is the end time of a planned item - printf(__('End at %s:'), date('H:i', strtotime($val['end']))); + printf(__s('End at %s:'), date('H:i', strtotime($val['end']))); break; } echo '
'; @@ -384,7 +384,7 @@ class Example extends CommonDBTM { switch ($data['linked_action'] - Log::HISTORY_PLUGIN) { case 0: - return __('History from plugin example', 'example'); + return __s('History from plugin example', 'example'); } return ''; @@ -397,7 +397,7 @@ class Example extends CommonDBTM $actions = parent::getSpecificMassiveActions($checkitem); $actions['Document_Item' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add'] = _x('button', 'Add a document'); // GLPI core one - $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'do_nothing'] = __('Do Nothing - just for fun', 'example'); // Specific one + $actions[self::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'do_nothing'] = __s('Do Nothing - just for fun', 'example'); // Specific one return $actions; } @@ -408,12 +408,12 @@ class Example extends CommonDBTM case 'DoIt': echo " " . Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']) . - ' ' . __('Write in item history', 'example'); + ' ' . __s('Write in item history', 'example'); return true; case 'do_nothing': echo ' ' . Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']) . - ' ' . __('but do nothing :)', 'example'); + ' ' . __s('but do nothing :)', 'example'); return true; } @@ -436,8 +436,8 @@ class Example extends CommonDBTM switch ($ma->getAction()) { case 'DoIt': if ($item->getType() == 'Computer') { - Session::addMessageAfterRedirect(__('Right it is the type I want...', 'example')); - Session::addMessageAfterRedirect(__('Write in item history', 'example')); + Session::addMessageAfterRedirect(__s('Right it is the type I want...', 'example')); + Session::addMessageAfterRedirect(__s('Write in item history', 'example')); $changes = [0, 'old value', 'new value']; foreach ($ids as $id) { if ($item->getFromDB($id)) { @@ -464,8 +464,8 @@ class Example extends CommonDBTM case 'do_nothing': if ($item->getType() == Example::class) { - Session::addMessageAfterRedirect(__('Right it is the type I want...', 'example')); - Session::addMessageAfterRedirect(__( + Session::addMessageAfterRedirect(__s('Right it is the type I want...', 'example')); + Session::addMessageAfterRedirect(__s( 'But... I say I will do nothing for:', 'example', )); @@ -487,27 +487,27 @@ class Example extends CommonDBTM parent::processMassiveActionsForOneItemtype($ma, $item, $ids); } - public static function generateLinkContents($link, CommonDBTM $item) + public static function generateLinkContents($link, CommonDBTM $item, bool $safe_url = true) { if (strstr($link, '[EXAMPLE_ID]')) { - $link = str_replace('[EXAMPLE_ID]', $item->getID(), $link); + $link = str_replace('[EXAMPLE_ID]', (string) $item->getID(), $link); return [$link]; } - return parent::generateLinkContents($link, $item); + return parent::generateLinkContents($link, $item, $safe_url); } public static function dashboardTypes() { return [ 'example' => [ - 'label' => __('Plugin Example', 'example'), + 'label' => __s('Plugin Example', 'example'), 'function' => Example::class . '::cardWidget', 'image' => 'https://via.placeholder.com/100x86?text=example', ], 'example_static' => [ - 'label' => __('Plugin Example (static)', 'example'), + 'label' => __s('Plugin Example (static)', 'example'), 'function' => Example::class . '::cardWidgetWithoutProvider', 'image' => 'https://via.placeholder.com/100x86?text=example+static', ], @@ -522,16 +522,16 @@ class Example extends CommonDBTM $new_cards = [ 'plugin_example_card' => [ 'widgettype' => ['example'], - 'label' => __('Plugin Example card'), + 'label' => __s('Plugin Example card'), 'provider' => Example::class . '::cardDataProvider', ], 'plugin_example_card_without_provider' => [ 'widgettype' => ['example_static'], - 'label' => __('Plugin Example card without provider'), + 'label' => __s('Plugin Example card without provider'), ], 'plugin_example_card_with_core_widget' => [ 'widgettype' => ['bigNumber'], - 'label' => __('Plugin Example card with core provider'), + 'label' => __s('Plugin Example card with core provider'), 'provider' => Example::class . '::cardBigNumberProvider', ], ]; @@ -605,14 +605,8 @@ class Example extends CommonDBTM public static function cardBigNumberProvider(array $params = []) { - $default_params = [ - 'label' => null, - 'icon' => null, - ]; - $params = array_merge($default_params, $params); - return [ - 'number' => rand(), + 'number' => random_int(0, mt_getrandmax()), 'url' => 'https://www.linux.org/', 'label' => 'plugin example - some text', 'icon' => 'fab fa-linux', // font awesome icon diff --git a/src/Filters/ComputerModelFilter.php b/src/Filters/ComputerModelFilter.php index d97b325..a258023 100644 --- a/src/Filters/ComputerModelFilter.php +++ b/src/Filters/ComputerModelFilter.php @@ -38,7 +38,7 @@ class ComputerModelFilter extends AbstractFilter { public static function getName(): string { - return __('Computer model'); + return __s('Computer model'); } public static function getId(): string @@ -48,6 +48,7 @@ class ComputerModelFilter extends AbstractFilter public static function canBeApplied(string $table): bool { + /** @var DBmysql $DB */ global $DB; return $DB->fieldExists($table, ComputerModel::getForeignKeyField()); diff --git a/src/ItemForm.php b/src/ItemForm.php index d1ba3c3..2aaafaa 100644 --- a/src/ItemForm.php +++ b/src/ItemForm.php @@ -50,9 +50,6 @@ class ItemForm */ public static function preSection($params) { - $item = $params['item']; - $options = $params['options']; - echo TemplateRenderer::getInstance()->renderFromStringTemplate(<<

@@ -81,9 +78,6 @@ TWIG, []); */ public static function postSection($params) { - $item = $params['item']; - $options = $params['options']; - echo TemplateRenderer::getInstance()->renderFromStringTemplate(<<

@@ -119,25 +113,25 @@ TWIG, []); $out = ''; $out .= sprintf( - __('Start %1$s hook call for %2$s type'), + __s('Start %1$s hook call for %2$s type'), 'pre_item_form', $item::getType(), ); $out .= ''; $out .= "<$firstelt>"; - $out .= ''; + $out .= ''; $out .= ""; $out .= ''; $out .= "<$firstelt>"; - $out .= ''; + $out .= ''; $out .= ""; $out .= ''; $out .= ''; $out .= ''; $out .= sprintf( - __('End %1$s hook call for %2$s type'), + __s('End %1$s hook call for %2$s type'), 'pre_item_form', $item::getType(), ); @@ -162,25 +156,25 @@ TWIG, []); $out = ''; $out .= sprintf( - __('Start %1$s hook call for %2$s type'), + __s('Start %1$s hook call for %2$s type'), 'post_item_form', $item::getType(), ); $out .= ''; $out .= "<$firstelt>"; - $out .= ''; + $out .= ''; $out .= ""; $out .= ''; $out .= "<$firstelt>"; - $out .= ''; + $out .= ''; $out .= ""; $out .= ''; $out .= ''; $out .= ''; $out .= sprintf( - __('End %1$s hook call for %2$s type'), + __s('End %1$s hook call for %2$s type'), 'post_item_form', $item::getType(), ); @@ -209,7 +203,7 @@ JAVASCRIPT; echo "
  • " . - __('Send a notification') . + __s('Send a notification') . Html::scriptBlock($JS) . '
  • '; } diff --git a/src/Item_DeviceCamera.php b/src/Item_DeviceCamera.php index 19ae9fc..25e9311 100644 --- a/src/Item_DeviceCamera.php +++ b/src/Item_DeviceCamera.php @@ -40,10 +40,6 @@ namespace GlpiPlugin\Example; use GlpiPlugin\Example\DeviceCamera; use Item_Devices; -if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); -} - /** * Relation between item and devices **/ diff --git a/src/NotificationTargetExample.php b/src/NotificationTargetExample.php index 0bf18c3..2ed5d0f 100644 --- a/src/NotificationTargetExample.php +++ b/src/NotificationTargetExample.php @@ -32,10 +32,6 @@ namespace GlpiPlugin\Example; use NotificationTarget; -if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); -} - // Class NotificationTarget class NotificationTargetExample extends NotificationTarget { @@ -46,8 +42,6 @@ class NotificationTargetExample extends NotificationTarget public function addDataForTemplate($event, $options = []) { - global $DB, $CFG_GLPI; - - $this->data['##example.name##'] = __('Example', 'example'); + $this->data['##example.name##'] = __s('Example', 'example'); } } diff --git a/src/Profile.php b/src/Profile.php index 17dfa37..404fddc 100644 --- a/src/Profile.php +++ b/src/Profile.php @@ -34,17 +34,27 @@ use CommonGLPI; use Html; use Session; -final class Profile extends \Profile +class Profile extends \Profile { public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - return __('Example plugin'); + if ( + $item instanceof \Profile + && $item->getField('id') + ) { + return self::createTabEntry(__s('Example plugin')); + } + + return ''; } public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - $profile = new self(); - $profile->showFormExample($item->getID()); + if ($item instanceof self) { + $profile = new self(); + $profile->showFormExample($item->getID()); + } + return true; } public function showFormExample(int $profiles_id): void diff --git a/src/RuleTest.php b/src/RuleTest.php index 3690099..09eb7e9 100644 --- a/src/RuleTest.php +++ b/src/RuleTest.php @@ -37,11 +37,6 @@ namespace GlpiPlugin\Example; use Rule; -if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); -} - - /** * Rule class store all informations about a GLPI rule : * - description @@ -69,7 +64,7 @@ class RuleTest extends Rule { $criterias = []; $criterias['name']['field'] = 'name'; - $criterias['name']['name'] = __('Software'); + $criterias['name']['name'] = __s('Software'); $criterias['name']['table'] = 'glpi_softwares'; return $criterias; @@ -78,7 +73,7 @@ class RuleTest extends Rule public function getActions() { $actions = []; - $actions['softwarecategories_id']['name'] = __('Category (class)', 'example'); + $actions['softwarecategories_id']['name'] = __s('Category (class)', 'example'); $actions['softwarecategories_id']['type'] = 'dropdown'; $actions['softwarecategories_id']['table'] = 'glpi_softwarecategories'; diff --git a/src/RuleTestCollection.php b/src/RuleTestCollection.php index 8f531ad..031ca5f 100644 --- a/src/RuleTestCollection.php +++ b/src/RuleTestCollection.php @@ -37,11 +37,6 @@ namespace GlpiPlugin\Example; use RuleCollection; -if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); -} - - class RuleTestCollection extends RuleCollection { // From RuleCollection diff --git a/src/Showtabitem.php b/src/Showtabitem.php index 89469fb..74834f4 100644 --- a/src/Showtabitem.php +++ b/src/Showtabitem.php @@ -68,14 +68,15 @@ class Showtabitem { switch ($params['item']->getType()) { case 'Ticket': - if ($params['options']['itemtype'] == 'TicketValidation' && $params['options']['tabnum'] == 2) { - // if tasks are not all done - // then prevent solution div to show - // this is an example to prevent solving of ticket - if (true) { // here you should test if some tasks are in todo status. - $params['options']['prevent_solution'] = true; // this will be passed to the post_show hook - echo "