Skip to content

[RFC] Short Open Tag deprecation V2 #4263

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ static void zend_set_default_compile_time_values(void) /* {{{ */
{
/* default compile-time values */
CG(short_tags) = short_tags_default;
CG(short_tags_notice) = 0;
CG(compiler_options) = compiler_options_default;
}
/* }}} */
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct _zend_compiler_globals {
zend_bool parse_error;
zend_bool in_compilation;
zend_bool short_tags;
zend_bool short_tags_notice;

zend_bool unclean_shutdown;

Expand Down
4 changes: 4 additions & 0 deletions Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,10 @@ string:

<INITIAL>"<?" {
if (CG(short_tags)) {
if (CG(short_tags_notice) == 0) {
zend_error(E_DEPRECATED, "PHP short tags are deprecated. This message will not be printed for further short tags uses. First usage");
CG(short_tags_notice) = 1;
}
BEGIN(ST_IN_SCRIPTING);
if (PARSER_MODE()) {
SKIP_TOKEN(T_OPEN_TAG);
Expand Down
3 changes: 2 additions & 1 deletion tests/lang/short_tags.001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ short_open_tag=on
echo "Used a short tag\n";
?>
Finished
--EXPECT--
--EXPECTF--
Deprecated: PHP short tags are deprecated. This message will not be printed for further short tags uses. First usage in %s on line %d
Used a short tag
Finished
25 changes: 25 additions & 0 deletions tests/lang/short_tags_unique_deprecation_notice.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Unique PHP short tag deprecation with multiple short tags used
--FILE--
<?php
echo "Used a normal tag\n";
?>
<?
echo "Used a short tag\n";
?>
Non PHP content
<?php
echo "Another normal tag\n";
?>
<?
echo "Another short tag\n";
?>
Finished
--EXPECTF--
Deprecated: PHP short tags are deprecated. This message will not be printed for further short tags uses. First usage in %s on line 4
Used a normal tag
Used a short tag
Non PHP content
Another normal tag
Another short tag
Finished