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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement bit shift operation on integers and unions #3145

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

thg2k
Copy link
Contributor

@thg2k thg2k commented Jun 10, 2024

This was in my wishlist for a long time.. so I did it 馃槃

@thg2k thg2k marked this pull request as draft June 10, 2024 20:12
@thg2k thg2k force-pushed the pr/shift_range_adv_1 branch 4 times, most recently from d882aa9 to db47c34 Compare June 14, 2024 09:39
@thg2k thg2k marked this pull request as ready for review June 14, 2024 09:51
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@thg2k
Copy link
Contributor Author

thg2k commented Jun 14, 2024

@ondrejmirtes I played with this feature for a few days in my codebase and I feel it is ready to go. Can you review this? Is there anythink that I'm overlooking?

@@ -1468,9 +1469,6 @@ private function callOperatorTypeSpecifyingExtensions(Expr\BinaryOp $expr, Type
return null;
}

/**
* @param BinaryOp\Plus|BinaryOp\Minus|BinaryOp\Mul|BinaryOp\Div $expr
Copy link
Member

Choose a reason for hiding this comment

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

Please add ShiftLeft and ShiftRight here, instead of removing the PHPDoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done for both. This should lead to a unreachable statement for the "else" branch, not sure if that is a problem.

Copy link
Member

Choose a reason for hiding this comment

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

This should lead to

It doesn't in bleeding edge. PHPStan no longer penalizes for unreachable else branch that throws an exception.

@@ -1560,7 +1561,6 @@ private function resolveCommonMath(Expr\BinaryOp $expr, Type $leftType, Type $ri

/**
* @param ConstantIntegerType|IntegerRangeType $range
* @param BinaryOp\Div|BinaryOp\Minus|BinaryOp\Mul|BinaryOp\Plus $node
Copy link
Member

Choose a reason for hiding this comment

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

Please add ShiftLeft and ShiftRight here, instead of removing the PHPDoc.

@thg2k
Copy link
Contributor Author

thg2k commented Jun 14, 2024

Please note that this would conflict with #3152 if it gets merged. That should have the priority as I think it's a bad bug. I'm happy to rebase this (or the other) in case.

@ondrejmirtes ondrejmirtes merged commit dd534ea into phpstan:1.11.x Jun 14, 2024
74 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@thg2k thg2k deleted the pr/shift_range_adv_1 branch June 15, 2024 00:22
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