Skip to content

Commit 951df56

Browse files
committed
Short tag deprecation V2
1 parent e6c2b28 commit 951df56

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

Zend/zend.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ static void zend_set_default_compile_time_values(void) /* {{{ */
523523
{
524524
/* default compile-time values */
525525
CG(short_tags) = short_tags_default;
526+
CG(short_tags_notice) = 0;
526527
CG(compiler_options) = compiler_options_default;
527528
}
528529
/* }}} */

Zend/zend_globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct _zend_compiler_globals {
8484
zend_bool parse_error;
8585
zend_bool in_compilation;
8686
zend_bool short_tags;
87+
zend_bool short_tags_notice;
8788

8889
zend_bool unclean_shutdown;
8990

Zend/zend_language_scanner.l

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,10 @@ string:
20322032

20332033
<INITIAL>"<?" {
20342034
if (CG(short_tags)) {
2035+
if (CG(short_tags_notice) == 0) {
2036+
zend_error(E_DEPRECATED, "PHP short tags are deprecated. This message will not be printed for further short tags uses. First usage");
2037+
CG(short_tags_notice) = 1;
2038+
}
20352039
BEGIN(ST_IN_SCRIPTING);
20362040
if (PARSER_MODE()) {
20372041
SKIP_TOKEN(T_OPEN_TAG);

tests/lang/short_tags.001.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ short_open_tag=on
77
echo "Used a short tag\n";
88
?>
99
Finished
10-
--EXPECT--
10+
--EXPECTF--
11+
Deprecated: PHP short tags are deprecated. This message will not be printed for further short tags uses. First usage in %s on line %d
1112
Used a short tag
1213
Finished
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Unique PHP short tag deprecation with multiple short tags used
3+
--FILE--
4+
<?php
5+
echo "Used a normal tag\n";
6+
?>
7+
<?
8+
echo "Used a short tag\n";
9+
?>
10+
Non PHP content
11+
<?php
12+
echo "Another normal tag\n";
13+
?>
14+
<?
15+
echo "Another short tag\n";
16+
?>
17+
Finished
18+
--EXPECTF--
19+
Deprecated: PHP short tags are deprecated. This message will not be printed for further short tags uses. First usage in %s on line 4
20+
Used a normal tag
21+
Used a short tag
22+
Non PHP content
23+
Another normal tag
24+
Another short tag
25+
Finished

0 commit comments

Comments
 (0)