-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Concat operations with variables #953 #2
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
Changes from all commits
f795a1a
33b6f30
9735971
abe0c54
c4eaf4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -485,10 +485,44 @@ public function unaryMinusNowdoc(): float | |
{ | ||
return | ||
- | ||
(int) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no cast needed here too, and the type can be changed to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without the typecast, it doesn't compile |
||
<<<'EOF' | ||
1. | ||
2 | ||
EOF | ||
; | ||
} | ||
|
||
public function concatWithVar(): string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. binary plus operator needs same test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reverted, see #2 (comment) |
||
{ | ||
$var1 = 'start'; | ||
|
||
$var1 = | ||
<<<'EOF' | ||
right | ||
EOF | ||
. | ||
$var1 | ||
; | ||
|
||
$var1 = | ||
$var1 | ||
. | ||
<<<'EOF' | ||
left | ||
EOF | ||
; | ||
|
||
return $var1; | ||
} | ||
|
||
public | ||
function | ||
emptyMethod | ||
( | ||
) | ||
: | ||
void | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,7 @@ function baz() | |
|
||
print '*'; | ||
} | ||
|
||
function xyz() | ||
{ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is concat special vs. other binary operators line plus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, but it seems it is special.
I guess it is because it can trigger typecasting on object by a
__toString()
call, wether other binary ops don'tThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your reasoning might make sense, but I still belive the var can be optimized to constant with opcache and thus var. itself should not generate a coverage line. I need to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to revert it, as it is unstable (line is not present in xdebug) when the var expr is known (from constatnt expr).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say, I'm kind of disappointed on how you are handling this contribution.
I created a valid test for a valid use case, I got the test passing, you found another edge case and istead of adding them to the tests, you throw my contribution away?
I'm losing my willingness to help, if you discard my help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry to hear that, I already spent about 2 - 3 MDs on static analyser to be really a minimal subset of xdebug and implementing sebastianbergmann#953 (comment) might take another several MDs. So what I was supposed to do?
test is added in https://github.com/sebastianbergmann/php-code-coverage/blob/c4630fdec1def41d63ce7844d6e91ced5ccfa478/tests/_files/source_with_heavy_indentation.php#L95-L110 (
$xa
is non-const assign,$xb
is const, not an uncommon case)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where exactly are these two cases tested now in sebastianbergmann#949 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(as of PHP 8.0) the variable assignments are covered
the concat const expr does not produce a coverage line if the variable is const expr - this is tested a for ex. in l105 in the example I posted - I also tested locally concat is not different than any other binary operator (like plus) in sense of coverage