Problem/Motivation
While working on fixing coding standards issues with the core test classes regarding the naming of class properties ($this->web_user should be $this->webUser), it became obvious that there are many, many instances where class properties are assigned and used but not documented or declared in the class definition itself. PHP does not strictly require declaration prior to use, but from a documentation point of view, it is ideal for such properties to be declared.
Proposed resolution
This patch adds an optional warning about undeclared variables to SimpleTest. When active, it compares the object variables before and after the test run to identify those that were not declared at the outset.
Remaining tasks
Needs review.
User interface changes
This adds a new checkbox to the SimpleTest settings page to enable/disable the feature, and adds a new command-line argument (--warn-undeclared-vars) to run-tests.sh.
API changes
No API changes, but this does add a new setting to the SimpleTest configuration schema.
Beta phase evaluation
Issue category | Feature, because this adds new functionality to SimpleTest. |
---|---|
Issue priority | Normal |
Unfrozen changes | Unfrozen because it only affects automated tests. |
Prioritized changes | The main goal of this issue is to assist in reducing fragility and improving documentation of automated tests. |
Disruption | This is not disruptive in and of itself as changes are limited to the SimpleTest module and do not impose re-factoring requirements elsewhere. |
Comment | File | Size | Author |
---|---|---|---|
simpletest-warn-undeclared-0.patch | 6.67 KB | tibbsa | |
Comments
Comment #2
markdorisonPatch no longer applies cleanly.
Comment #16
mondrakeI think PHP 8.2 and PHPStan have addressed this space quite enough.