Skip to content

Conversation

@cedric-anne
Copy link
Member

Instead of forcing developers to add PHPDoc for all global variables, we can resolve their type automatically.

The resolution is based on the variable name and the risk that a plugin declares a variable with the same name that a global variable of GLPI exists, but, in this case, it is still possible to enforce the type with a dedicated PHPDoc block (see the tests/data/GlobalTypeResolver/global-statement-with-phpdoc.php test file).

This will permit, for instance, in a future GLPI version, to change the type the $CFG_GLPI or the $PLUGIN_HOOKS variables if we decide to replace it by dedicated objects that implements the ArrayAccess interface.

@cedric-anne cedric-anne force-pushed the feature/autodetect-global-types branch from fb7979f to 32e14ec Compare August 11, 2025 10:17
@cedric-anne cedric-anne merged commit a2c8fe6 into glpi-project:main Aug 11, 2025
2 checks passed
@cedric-anne cedric-anne deleted the feature/autodetect-global-types branch August 11, 2025 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants