Skip to content

Améliorations de code et corrections de comportement (PHPStan lvl 1)#3260

Open
kwizer15 wants to merge 3 commits intojeedom:developfrom
kwizer15:fix/phpstan-behavior-fixes
Open

Améliorations de code et corrections de comportement (PHPStan lvl 1)#3260
kwizer15 wants to merge 3 commits intojeedom:developfrom
kwizer15:fix/phpstan-behavior-fixes

Conversation

@kwizer15
Copy link
Copy Markdown
Contributor

Description

Corrections qui améliorent la robustesse du code, détectées par PHPStan au niveau 1. Contrairement aux autres PRs de cette série, certaines de ces modifications changent légèrement le comportement pour corriger des problèmes réels.

Corrections de comportement :

  • cmd::historyInfluxAll() — Remplacement de l'appel direct à historyInflux('all') par la création d'une tâche cron dédiée, évitant un timeout sur les gros volumes
  • jeeObject.class.php — Réordonnancement du guard class_exists('virtual') avant l'appel à $plugin->isActive() pour éviter un crash si la classe n'est pas chargée
  • network.class.php — Ajout de class_exists('openvpn') dans le guard pour la même raison
  • jsonrpcClient.class.php — Remplacement du while par do...while (la boucle doit s'exécuter au moins une fois)
  • scenario::export() — Ajout de return explicites dans chaque branche pour éviter un return ambigu en fin de méthode
  • core/php/utils.inc.php redirect()exit(header(...)) remplacé par header(); exit car header() retourne void
  • core/php/utils.inc.php evaluate() — Restructuration du bloc if/else pour protéger correctement les chaînes entre guillemets

Nettoyage sans changement de comportement :

  • plugin.class.php — Suppression du isset($listPlugin) redondant (la variable est toujours définie)
  • market.repo.php — Remplacement de la fonction globale cmp() par une closure avec l'opérateur spaceship <=>
  • install/backup.php — Suppression du isset() redondant après trim()
  • jeedom.config.php — Suppression du genericType THERMOSTAT_HUMIDITY non utilisé
  • phpstan.neon — Ajout du bootstrap elfinder pour l'analyse statique

Suggested changelog entry

Améliorations de robustesse du code (guards, boucles, retours de méthodes)

Related issues/external references

Découpage de #3122

Types of changes

  • Bug fix (non-breaking change which fixes)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

  • I have checked there is no other PR open for the same change.
  • I have read the Contribution guidelines for this project.
  • I grant the project the right to include and distribute the code under the GNU.
  • I have added tests to cover my changes.
  • I have verified that the code complies with the projects coding standards.
  • [Required for new sniffs] I have added MD documentation for the sniff.

Comment thread core/class/cmd.class.php Outdated

public function historyInfluxAll() {
cmd::historyInflux('all');
public static function historyInfluxAll() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd::historyInflux('all'); is already creating a cron, why moving this code?
anyway, as others discussions are ongoing on influx (#3039), I prefer we do not modify this for now

However, keep the fix on static declaration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd::historyInflux is not static. It's just a copy/paste

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, now I got it
I made a refacto so solve the "static issue" without copy/paster

Comment thread core/config/jeedom.config.php
Comment thread core/php/utils.inc.php
Comment thread core/config/jeedom.config.php
Comment thread core/class/cmd.class.php Outdated

public function historyInfluxAll() {
cmd::historyInflux('all');
public static function historyInfluxAll() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd::historyInflux is not static. It's just a copy/paste

Comment thread core/config/jeedom.config.php
Comment thread core/php/utils.inc.php
@Mips2648 Mips2648 self-assigned this Apr 18, 2026
Comment thread core/php/utils.inc.php
@Mips2648
Copy link
Copy Markdown
Collaborator

Mips2648 commented Apr 20, 2026

ok for me
I suspect that you will tell me that the change I made on historyInflux is in theory a breaking change (I change the signature) but today it doesn't work anyway, and after that it will still not work because dependencies are incorrect.
So as anyway there is #3039 ongoing, I propose we let it like that, at least the code is syntactically correct.

@Mips2648 Mips2648 requested review from Salvialf and zoic21 April 20, 2026 14:03
@Mips2648 Mips2648 added Need review changelog-fix Use to generate release notes / changelog To be apply on PR labels Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-fix Use to generate release notes / changelog To be apply on PR Need review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants