Conversation
7f88387 to
2bb29c1
Compare
|
It looks like applying the new fixer on the project codebase changes lots of files, which looks wrong as I think the codebase already uses brances everywhere. It looks like there is a bug in your fixer |
|
Also, I think it will break for codebases using the following syntax: if (2 > 1):
echo 'This is always reached':
echo 'More code';
endif;the fixer should take such code into account to avoid breaking it |
Symfony/CS/Tokens.php
Outdated
There was a problem hiding this comment.
shouldn't you check for $index < count($this) to be safe against exceptions too ?
There was a problem hiding this comment.
I do not see a case when this will break on valid php code. Could you provide one?
There was a problem hiding this comment.
if you pass a $startBraceIndex which is not the opening brace, I think it might create weird issues
There was a problem hiding this comment.
Actually whole project do not validate input parameters, so you can use almost any method in the way to blow up in your face.
It will be added, no harm
|
There was a problem hiding this comment.
All this loop is the same than $tokens->findBracesBlockEnd but using parenthesis instead of braces. I suggest making findBracesBlockEnd able to handle both cases instead
62adc8f to
deb41e9
Compare
|
fix |
61520ec to
63fb018
Compare
|
(just rebase on master) |
|
Next to task done:
|
|
@stof Be aware that if (2 > 1):
echo 'This is always reached':
echo 'More code';
endif;syntax is not touched yet |
|
@keradus I don't have such codebase (the case where it is common to use such syntax is in templates, and I use Twig for that) |
|
@stof OK. I think I will ignore this syntax, at least for now. Maybe some day. The intresting thing is that the fixer do not only add missing braces, but also correct indent inside it ;) |
|
@keradus IMO, changing the if/endif syntax to the brace syntax is a job for a different fixer, as you might now want it globally |
|
@stof Then agreed, this fixer should ignore that syntax. |
|
👍 |
|
You are great @Nyholm ! Thanks ! |
There was a problem hiding this comment.
This line is not executed on HHVM (3.0.1). T_FINALLY is not defined. I don't know why. Sorry...
There was a problem hiding this comment.
Finally was added in hhvm 3.2.0 btw.
There was a problem hiding this comment.
Thanks @Nyholm !
Then I will just skip test if T_FINALLY is not defined.
There was a problem hiding this comment.
T_FINALLY is defined on newer hhvm versions? If not, this is a bug, and should be reported to the hhvm team.
There was a problem hiding this comment.
And travis uses hhvm 3.2.0, so how can this be happening?
There was a problem hiding this comment.
Updated to HipHop VM 3.2.0 (rel) . Same error there.
There was a problem hiding this comment.
This looks like a genuine bug in hhvm then.
1e27854 to
07fe844
Compare
|
Wow, I see some ghost comments here ! :D |
|
link facebook/hhvm#3703 |
|
merged |
Braces for structure blocks, fix #98
T_FORtoken syntax}and T_ELSE, E_ELSEIF, T_CATCH