-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qual: Fix some phan typing in actions_massactions.inc.php #30733
Conversation
000efbf
to
5d83c6b
Compare
@@ -47,6 +47,13 @@ | |||
} | |||
$error = 0; | |||
|
|||
// Note: list of strings for objectclass could be extended to accepted/expected classes | |||
' | |||
@phan-var-force "Societe"|"Contact"|"ExpenseReport"|"Partnership"|"Holiday"|"ConferenceOrBoothAttendee"|"Facture"|"CommandeFournisseur" $objectclass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$objectclass can be any Dolibarr business object here.
Is it possible to have instead a generic object class, may be CommonObject class ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find often that putting CommonObject alone generates issues with the typing as some fields are missing and expected by the algorithm.
I propose to "add" CommonObject and also leave the other options that are tested for in the code. In case there is a typing issue it will indicate which classes are not compatible.
Ideally - in some future - the code would do a test using "instanceof" rather than relying on the 'element' field and the typing hints.
That implies risks of course: the "instanceof" condition could be too strict vs. what the code was actually expecting and introduce some bugs in the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to "add" CommonObject and also leave the other options that are tested for in the code. In case there is a typing issue it will indicate which classes are not compatible.
You mean having this
@phan-var-force "CommonObject"|"Societe"|"Contact"|"ExpenseReport"|"Partnership"|"Holiday"|"ConferenceOrBoothAttendee"|"Facture"|"CommandeFournisseur" $objectclass ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
FYI, phan has more than 50 notices for this file.
For instance, we have:
htdocs\core\actions_massactions.inc.php:1288 PhanUndeclaredProperty Reference to undeclared property \CommonObject->price
htdocs\core\actions_massactions.inc.php:1289 PhanUndeclaredProperty Reference to undeclared property \CommonObject->price_min
There is no check on the object type: it is implied by the 'updateprice' action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but most of them are strange. For example this one:
UndefError PhanUndeclaredProperty Reference to undeclared property \CommonObject->rowid on line 1175
The $obj is a result of fetch_object() with no declaration that it is CommonObject, so I don't understand this warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is because we have the following in the configuration for phan:
dev/tools/phan/config.php: 'obj' => '\CommonObject', // Deprecated
We could check what the result is if this is commented in a separate PR (I guess there will be some notifications that pop up).
35a5ad3
to
ee5424b
Compare
I've now extended to fixing all the notices in Some observations:
Regarding the issues:
|
3999143
to
0e1a2d3
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
0efa150
to
bc5114c
Compare
I've reduced this PR to only the changes in actions_massactions.inc.php . The rest of the PR was moved to #30747 |
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
8bd1e40
to
d50447c
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
d50447c
to
6cac05a
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
6cac05a
to
3bc1713
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
3bc1713
to
25c1202
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
25c1202
to
7c878a8
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
7c878a8
to
48255b8
Compare
* Qual: Fix phan notices in actions_massactions.inc # Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from #30733. * Adjust baseline for actions_massactions.inc improvements * Update actions_massactions.inc.php --------- Co-authored-by: Laurent Destailleur <[email protected]>
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
48255b8
to
3c7f13d
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
3c7f13d
to
d1133b6
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
d1133b6
to
dcf6c17
Compare
# Qual: Fix phan notices in actions_massactions.inc This fixes up the notices in htdocs/core/actions_massactions.inc.php Separated from Dolibarr#30733.
dcf6c17
to
cd0480b
Compare
@@ -49,6 +49,18 @@ | |||
@phan-var-force ?string $deliveryreceipt | |||
'; | |||
|
|||
' | |||
@phan-var-force ?string $permissiontoread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems duplicate of line 41 to 49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly because this PR and changes still pending here are "old" and repeated in more recent PRs. I'll clean that up.
The main reason this PR is still open is for these phan notices:
Warning: actions_massactions.inc.php: PhanUndeclaredProperty: Reference to undeclared property \CommonObject->fk_soc
Warning: actions_massactions.inc.php: PhanUndeclaredProperty: Reference to undeclared property \User->email_aliases
Warning: actions_massactions.inc.php: PhanPossiblyUndeclaredGlobalVariable: Global variable $pagecount is possibly undeclared
I am tending to think that I should simply extract the code changes to a separate PR and close this one - the real technical debt is likely not going to be fixed until almost all of the pending phpdoc changes and false positives are identified.
Qual: Fix some phan typing in actions_massactions.inc.php
Fix phan in actions_massactions.inc.php