Req #77776 [NEW]: if inline goto
| From: | xxalfa at gmail dot com | Date: | Thu, 21 Mar 2019 03:11:21 +0000 |
| Subject: | Req #77776 [NEW]: if inline goto | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220104@lists.php.net to get a copy of this message | ||
From: xxalfa at gmail dot com
Operating system:
PHP version: Irrelevant
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:if inline goto
Description:
------------
I don't understand why "goto" is not treated like "require_once"?
Test script:
---------------
<?php
//-------------------------------------------------
// HEAD
//-------------------------------------------------
declare( strict_types = 1 );
header( 'Content-Type:text/plain' );
error_reporting( E_ALL );
ini_set( 'display_errors', '1' );
ini_set( 'html_errors', '0' );
define( 'CORE_DIR', dirname( __FILE__ ) . DIRECTORY_SEPARATOR );
isset( $argv ) or trigger_error( 'This is a command terminal
application.', E_USER_ERROR );
echo __FILE__ . ' [PID:' . getmypid() . '][PHP:' . phpversion() .
']' . PHP_EOL . PHP_EOL;
function process_recording( $process_message ) { echo 'event ' .
$process_message . PHP_EOL; }
//-------------------------------------------------
// WORKS AS DESIRED
//-------------------------------------------------
$test = 'foo';
$file_path = CORE_DIR . 'test.php'; // file content: <?php $test =
'bar';
file_exists( $file_path ) and process_recording( 'require_once ' .
$file_path ) . ( require_once $file_path ) or process_recording(
'file_not_found ' . $file_path );
echo $test . PHP_EOL;
//-------------------------------------------------
// DOES NOT WORK AS DESIRED
//-------------------------------------------------
$action = 2;
// Parse error: syntax error, unexpected 'goto' (T_GOTO)
// $action === 1 and process_recording( 'goto_action_1' ) . goto
goto_action_1;
// $action === 2 and process_recording( 'goto_action_2' ) . goto
goto_action_2;
// $action === 1 and process_recording( 'goto_action_1' ) . ( goto
goto_action_1 );
// $action === 2 and process_recording( 'goto_action_2' ) . ( goto
goto_action_2 );
// $action === 1 and process_recording( 'goto_action_1' ) . goto(
'goto_action_1' );
// $action === 2 and process_recording( 'goto_action_2' ) . goto(
'goto_action_2' );
//-------------------------------------------------
// LOOKS UGLY, BUT WORKS
//-------------------------------------------------
if ( $action === 1 ): process_recording( 'goto_action_1' ); goto
goto_action_1; endif;
if ( $action === 2 ): process_recording( 'goto_action_2' ); goto
goto_action_2; endif;
exit;
goto_action_1: echo 'action_1' . PHP_EOL . exit;
goto_action_2: echo 'action_2' . PHP_EOL . exit;
goto_end_of_file: echo 'end_of_file' . PHP_EOL . exit;
?>
--
Edit bug report at https://bugs.php.net/bug.php?id=77776&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77776&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77776&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77776&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77776&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77776&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77776&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77776&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77776&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77776&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77776&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77776&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77776&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77776&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77776&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77776&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77776&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77776&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77776&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77776&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77776&r=mysqlcfg