PHP VERSION: 8.2.17

abstract_syntax_tree_parentheses_affects_behavior.php

<?php
// TODO: see wuzzup!
// example of the effect of the abstract syntax tree rework

$foo_1 = array();
$foo_2 = array();

$foo_2['bar'] = 'baz';
var_dump($foo_2);

(
$foo_1)['bar'] = 'baz';
var_dump($foo_1);

class 
Test
{
    public function 
bar()
    {
        return 
"TEST\n";
    }
}

// conventional syntax
$t = new Test();
echo 
$t->bar();

// introduced in PHP 5.4
echo (new Test())->bar();

// php 7
echo new Test()->bar();


Output



Parse Error
SOURCE CODE