Skip to content

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

Development

Successfully merging this pull request may close these issues.

3 participants