Skip to content
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

Fix some cases of PhanTypeSuspiciousStringExpression #28751

Merged

Conversation

mdeweerd
Copy link
Contributor

Fix some cases of PhanTypeSuspiciousStringExpression

PhanTypeSuspiciousStringExpression is generally about using a boolean in "concatenation" to a string.
Fixed mostly by converting to a string value. There were a few cases with a misplaced parentheses in a (cond?X:Y) expression.

@mdeweerd mdeweerd marked this pull request as ready for review March 11, 2024 00:32
@mdeweerd mdeweerd force-pushed the fix/PhanTypeSuspiciousStringExpression/1 branch from 56cb9b5 to 13bf3bd Compare March 11, 2024 01:19
@mdeweerd mdeweerd force-pushed the fix/PhanTypeSuspiciousStringExpression/1 branch from 723dd68 to 552ac11 Compare March 11, 2024 01:56
@mdeweerd mdeweerd force-pushed the fix/PhanTypeSuspiciousStringExpression/1 branch from 4f30477 to 290f82f Compare March 11, 2024 09:38
@@ -297,6 +297,10 @@ private function amountToLetters($montant, $devise1 = '', $devise2 = '')
$prim = array();
$secon = array();
$trio = array();
'@phan-var string[] $prim
Copy link
Member

Choose a reason for hiding this comment

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

Did you try to use
/** var string[] $prim */
before the $prim = array();
So this avoid to introduce phan specific code. Dos this trick works ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use phan in other projects - as far as I am used to using PHPDoc does not work here for phan, so I do not try '/** @var ... */ anymore when the case corresponds to something where that would not work.

The documentation explains that this is a limition of AST:
https://github.com/phan/phan/wiki/Annotating-Your-Source-Code#inline-type-checks-via-string-literals

I try to avoid specific code as much as possible myself too.

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Mar 11, 2024
@eldy eldy merged commit b72cf19 into Dolibarr:develop Mar 11, 2024
5 checks passed
@mdeweerd mdeweerd deleted the fix/PhanTypeSuspiciousStringExpression/1 branch March 11, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Some questions or discussions are opened and wait answers of author or other people to be processed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants