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 phpstan #31805

Merged
merged 6 commits into from
Nov 13, 2024
Merged

fix phpstan #31805

merged 6 commits into from
Nov 13, 2024

Conversation

frederic34
Copy link
Member

No description provided.

$permissiontoread = $user->hasRight('societe', 'lire');
$permissiontodelete = $user->hasRight('societe', 'supprimer');
$permissiontoadd = $user->hasRight('societe', 'creer');
$permissiontoread = ($user->hasRight('societe', 'lire') == 1);
Copy link
Member

Choose a reason for hiding this comment

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

Does not look a good idea to do
$permissiontoread = ($user->hasRight('societe', 'lire') == 1);
everywhere when this is more natural :
$permissiontoread = $user->hasRight('societe', 'lire');

What's wrong with having
$permissiontoread = 1 ?
May be can set such var to be both boolean and int ?

Copy link
Member Author

Choose a reason for hiding this comment

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

image
if ($permissiontoread) with $permissiontoread is int phpstan can't determine if test if right

Copy link
Member

Choose a reason for hiding this comment

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

Stupid phpstan. So what do you think of:
$permissiontoread = (bool) $user->hasRight('societe', 'lire');
instead of
$permissiontoread = ($user->hasRight('societe', 'lire') == 1);

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried...

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Nov 13, 2024
@eldy eldy merged commit 2c4d103 into Dolibarr:develop Nov 13, 2024
7 checks passed
@frederic34 frederic34 deleted the fix_fix_phpstan branch November 13, 2024 21:37
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