Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
232da51
Initial flexibly heredoc/nowdoc implementation
tpunt Sep 15, 2017
0f151de
Fix \t bug in heredocs
tpunt Sep 15, 2017
fe13a33
Remove new line requirement after terminating marker
tpunt Sep 16, 2017
1041f61
Add whitespace constraints
tpunt Sep 21, 2017
e3f8833
Fix some implementation bugs
tpunt Sep 26, 2017
9044e32
Fix another bug
tpunt Sep 27, 2017
0c8cf6d
Remove irrelevant tests
tpunt Sep 27, 2017
6518b64
Fix yet another bug
tpunt Sep 27, 2017
0fce83f
Only consider literal spacing as indentation
tpunt Sep 27, 2017
3e4f702
Fix line numebrs...
tpunt Sep 27, 2017
a5619a9
Some touchups
tpunt Nov 15, 2017
ecdc006
Ensure compatibility with C89
tpunt Nov 15, 2017
a01b7dd
Second time lucky...
tpunt Nov 15, 2017
8b4b3f6
For parity with the other two indentation checking styles
tpunt Dec 9, 2017
abe82f3
Use stateful forward scan
tpunt Dec 11, 2017
ef81d09
Fix compile globals line number (ignore forward scans)
tpunt Dec 11, 2017
6bd3821
Copying the state stack shouldn't be necessary. Also, just return retval
tpunt Dec 16, 2017
140ae25
Fix uninitialised zendlvals
tpunt Mar 11, 2018
ddebc25
Delay exception handling
tpunt Mar 11, 2018
5120ebe
Return early
tpunt Mar 11, 2018
9b21e2f
Improve line number test
tpunt Mar 11, 2018
afe83dc
Fix new line detection for indented closing markers
tpunt Mar 11, 2018
e684241
Clear exception using the appropriate API
tpunt Mar 11, 2018
6ae4f7b
Remove superfluous code
tpunt Mar 11, 2018
31166bb
Fix compiler line number information
tpunt Mar 11, 2018
d8b6a44
No need for a separate variable anymore
tpunt Mar 11, 2018
8b0329b
Add a basic test for ext/tokenizer
tpunt Mar 11, 2018
1d425d7
Update test with some error cases
tpunt Mar 11, 2018
21f9a23
Fix TOKEN_PARSE scanning
tpunt Mar 11, 2018
a2c6218
Partially fix token_get_all() output
tpunt Mar 12, 2018
7132107
Partially undo last commit
tpunt Mar 12, 2018
47667dc
Don't return early on exception
tpunt Mar 12, 2018
a7f35ff
Almost complete implementation of WS w/ closing marker
tpunt Mar 12, 2018
ebeba79
Fix implementation (no idea what I was thinking...)
tpunt Mar 12, 2018
bf341c2
Switch definitions around for parity with heredoc
tpunt Mar 12, 2018
23b7d40
Redo newline calculation
tpunt Mar 18, 2018
482516a
Partially support latest lexer changes...
tpunt Mar 19, 2018
24a8b91
Finish tokenizer updates with latest master changes
tpunt Mar 20, 2018
4a12f44
Use the right macro
nikic Mar 20, 2018
6e56536
Don't adjust heredoc label length
nikic Mar 24, 2018
6d680f3
Add one more test case
nikic Mar 24, 2018
ab02291
Move function defs above macros
nikic Mar 24, 2018
16939ad
Run all tokenizer tests w/ and w/o TOKEN_PARSE
nikic Mar 25, 2018
9f5435f
Make sure to reset lookahead state
nikic Mar 25, 2018
1990cb2
Always reset increment_lineno after scan ahead
nikic Mar 25, 2018
82c156c
Correctly handle unterminated heredoc with trailing WS
nikic Mar 25, 2018
b252ee6
Fix unindented interpolated variable problem
tpunt Mar 26, 2018
6ad9bf6
Unindented interpolated variables are only invalid when there is inde…
tpunt Mar 26, 2018
2cb4531
Cater for other variable interpolation types
tpunt Apr 9, 2018
ea719d5
Terminate test scripts with ?> (where possible)
tpunt Apr 9, 2018
0057e4b
use ZEND_STRINGL instead of zend_copy_value
tpunt Apr 9, 2018
2e8826e
Show erroneous line in exception error message
tpunt Apr 9, 2018
1c22f73
Return T_ERROR on error in parser mode
nikic Apr 13, 2018
5aee65a
Fix newline counting in tokenizer
nikic Apr 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Zend/tests/flexible-heredoc-complex-test1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Flexible heredoc syntax complex test 1: interpolated nested heredocs
with different delimiter names
--FILE--
<?php

$a = 'b';
${"b\nb\n d"} = 'b';

var_dump(<<<DOC1
a
${<<<DOC2
b
${<<<DOC3
a
DOC3}
d
DOC2
}
c
DOC1);

?>
--EXPECT--
string(5) "a
b
c"
27 changes: 27 additions & 0 deletions Zend/tests/flexible-heredoc-complex-test2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Flexible heredoc syntax complex test 2: interpolated nested heredocs
with the same delimiter name
--FILE--
<?php

$a = 'b';
${"b\nb\n d"} = 'b';

var_dump(<<<DOC1
a
${<<<DOC1
b
${<<<DOC1
a
DOC1}
d
DOC1
}
c
DOC1);

?>
--EXPECT--
string(5) "a
b
c"
27 changes: 27 additions & 0 deletions Zend/tests/flexible-heredoc-complex-test3.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Flexible heredoc syntax complex test 3: interpolated nested heredocs
with the same delimiter name with different levels of indentation
--FILE--
<?php

${' a'} = ' b';
${' b'} = 'c';
${"b\n b"} = 'b';

var_dump(<<<DOC1
a
${<<<DOC2
b
${<<<DOC3
a
DOC3}
DOC2
}
c
DOC1);

?>
--EXPECT--
string(8) " a
b
c"
35 changes: 35 additions & 0 deletions Zend/tests/flexible-heredoc-complex-test4.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--TEST--
Flexible heredoc syntax complex test 4: interpolated variable with
the same delimiter name as the heredoc
--FILE--
<?php

{
$FOO = "FOO";
define("FOO", "FOO");
$b = <<<FOO
Test
${
FOO
}
FOO;
var_dump($b);
}

{
$FOO = "FOO";
$b = <<<FOO
Test
${
FOO
}
FOO;
var_dump($b);
}

?>
--EXPECT--
string(8) "Test
FOO"
string(16) " Test
FOO"
14 changes: 14 additions & 0 deletions Zend/tests/flexible-heredoc-error1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Flexible heredoc syntax 1: different indentation for body (spaces) ending marker (tabs)
--FILE--
<?php

echo <<<END
a
b
c
END;

?>
--EXPECTF--
Parse error: Invalid indentation - tabs and spaces cannot be mixed in %s on line %d
13 changes: 13 additions & 0 deletions Zend/tests/flexible-heredoc-error10.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Flexible heredoc syntax error 10: unindented variable interpolation (as first value)
--FILE--
<?php

$var = 'Bar';
var_dump(<<<TEST
$var
TEST);

?>
--EXPECTF--
Parse error: Invalid body indentation level (expecting an indentation level of at least 1) in %s on line %d
13 changes: 13 additions & 0 deletions Zend/tests/flexible-heredoc-error11.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Flexible heredoc syntax error 11: show erroneous line in error message (variable interpolation)
--FILE--
<?php

echo <<<END
a
$a
END;

?>
--EXPECTF--
Parse error: Invalid body indentation level (expecting an indentation level of at least 1) in %s on line 5
13 changes: 13 additions & 0 deletions Zend/tests/flexible-heredoc-error12.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Flexible heredoc syntax error 12: show erroneous line in error message (mixed indentation)
--FILE--
<?php

echo <<<END
a
b
END;

?>
--EXPECTF--
Parse error: Invalid indentation - tabs and spaces cannot be mixed in %s on line 5
13 changes: 13 additions & 0 deletions Zend/tests/flexible-heredoc-error13.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Flexible heredoc syntax error 12: show erroneous line in error message (lacking indentation)
--FILE--
<?php

echo <<<END
a
b
END;

?>
--EXPECTF--
Parse error: Invalid body indentation level (expecting an indentation level of at least 1) in %s on line 5
14 changes: 14 additions & 0 deletions Zend/tests/flexible-heredoc-error2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Flexible heredoc syntax 2: mixing spaces and tabs in body
--FILE--
<?php

echo <<<END
a
b
c
END;

?>
--EXPECTF--
Parse error: Invalid indentation - tabs and spaces cannot be mixed in %s on line %d
14 changes: 14 additions & 0 deletions Zend/tests/flexible-heredoc-error3.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Flexible heredoc syntax error 3: mixing spaces and tabs in ending marker
--FILE--
<?php

echo <<<END
a
b
c
END;

?>
--EXPECTF--
Parse error: Invalid indentation - tabs and spaces cannot be mixed in %s on line %d
14 changes: 14 additions & 0 deletions Zend/tests/flexible-heredoc-error4.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Flexible heredoc syntax error 4: not enough body indentation
--FILE--
<?php

echo <<<END
a
b
c
END;

?>
--EXPECTF--
Parse error: Invalid body indentation level (expecting an indentation level of at least 5) in %s on line %d
11 changes: 11 additions & 0 deletions Zend/tests/flexible-heredoc-error5.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Flexible heredoc syntax error 5: mixing spaces and tabs in ending marker for 0 length body
--FILE--
<?php

echo <<<END
END;

?>
--EXPECTF--
Parse error: Invalid indentation - tabs and spaces cannot be mixed in %s on line %d
10 changes: 10 additions & 0 deletions Zend/tests/flexible-heredoc-error6.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
Flexible heredoc syntax error 6: no ending token on 0 length body
--DESCRIPTION--
Note: the closing ?> has been deliberately elided.
--FILE--
<?php

echo <<<END
--EXPECTF--
Parse error: syntax error, unexpected end of file in %s on line %d
11 changes: 11 additions & 0 deletions Zend/tests/flexible-heredoc-error7.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Flexible heredoc syntax error 7: no ending token
--DESCRIPTION--
Note: the closing ?> has been deliberately elided.
--FILE--
<?php

echo <<<END

--EXPECTF--
Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or heredoc end (T_END_HEREDOC) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in %s on line %d
12 changes: 12 additions & 0 deletions Zend/tests/flexible-heredoc-error8.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Flexible heredoc syntax error 8: don't interpret \t as indentation
--FILE--
<?php

<<<end
\ta
end);

?>
--EXPECTF--
Parse error: Invalid body indentation level (expecting an indentation level of at least 1) in %s on line %d
14 changes: 14 additions & 0 deletions Zend/tests/flexible-heredoc-error9.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Flexible heredoc syntax error 9: unindented variable interpolation
--FILE--
<?php

$var = 'Bar';
var_dump(<<<TEST
Foo
$var
TEST);

?>
--EXPECTF--
Parse error: Invalid body indentation level (expecting an indentation level of at least 2) in %s on line %d
30 changes: 30 additions & 0 deletions Zend/tests/flexible-heredoc-nowdoc-lineno.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Flexible heredoc lineno: ensure the compiler globals line number is correct
--FILE--
<?php

$heredoc = <<<EOT
hello world
EOT;

$heredoc = <<<'EOT'
hello world
EOT;

$heredoc = <<<EOT
hello world
EOT;

$heredoc = <<<'EOT'
hello world
EOT;

try {
throw new exception();
} catch (Exception $e) {
var_dump($e->getLine());
}

?>
--EXPECT--
int(20)
Loading