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

sizeof() is an alias of count() #647

Merged
merged 3 commits into from Aug 27, 2021
Merged

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 26, 2021

@staabm staabm changed the title sizeof() is a alias of count() sizeof() is an alias of count() Aug 26, 2021
@ondrejmirtes
Copy link
Member

  1. This change needs a test.
  2. There are definitely more places that need fixing. Search for 'count' in src/

@staabm
Copy link
Contributor Author

staabm commented Aug 27, 2021

great feedback - as always. I think the PR is now in better shape.

@ondrejmirtes ondrejmirtes merged commit fc7bcff into phpstan:master Aug 27, 2021
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the patch-1 branch August 27, 2021 07:26
@staabm
Copy link
Contributor Author

staabm commented Aug 27, 2021

I was not sure whether I should have added sizeof here to:

if (
$expr->left instanceof FuncCall
&& count($expr->left->args) === 1
&& $expr->left->name instanceof Name
&& in_array(strtolower((string) $expr->left->name), ['count', 'strlen'], true)
&& (
!$expr->right instanceof FuncCall
|| !$expr->right->name instanceof Name
|| !in_array(strtolower((string) $expr->right->name), ['count', 'strlen'], true)
)
) {
$inverseOperator = $expr instanceof Node\Expr\BinaryOp\Smaller
? new Node\Expr\BinaryOp\SmallerOrEqual($expr->right, $expr->left)
: new Node\Expr\BinaryOp\Smaller($expr->right, $expr->left);
return $this->specifyTypesInCondition(
$scope,
new Node\Expr\BooleanNot($inverseOperator),
$context
);
}

maybe you can give me a hint

@ondrejmirtes
Copy link
Member

Yeah, probably, this branch probably solves something like count($a) > 0 or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants