1--TEST-- 2Immediate access on new anonymous class 3--FILE-- 4<?php 5 6echo new class { 7 const C = 'constant' . PHP_EOL; 8}::C; 9 10echo new class { 11 const C = 'constant' . PHP_EOL; 12}::{'C'}; 13 14echo new class { 15 public $property = 'property' . PHP_EOL; 16}->property; 17 18echo new class { 19 public static $property = 'static property' . PHP_EOL; 20}::$property; 21 22new class { 23 public function method() { echo 'method' . PHP_EOL; } 24}->method(); 25 26new class { 27 public static function method() { echo 'static method' . PHP_EOL; } 28}::method(); 29 30new class { 31 public function __invoke() { echo '__invoke' . PHP_EOL; } 32}(); 33 34new class () implements ArrayAccess { 35 public function offsetExists(mixed $offset): bool { return true; } 36 37 public function offsetGet(mixed $offset): mixed { echo 'offsetGet' . PHP_EOL; return null; } 38 39 public function offsetSet(mixed $offset, mixed $value): void {} 40 41 public function offsetUnset(mixed $offset): void {} 42}['key']; 43 44isset(new class () implements ArrayAccess { 45 public function offsetExists(mixed $offset): bool { echo 'offsetExists' . PHP_EOL; return true; } 46 47 public function offsetGet(mixed $offset): mixed { return null; } 48 49 public function offsetSet(mixed $offset, mixed $value): void {} 50 51 public function offsetUnset(mixed $offset): void {} 52}['key']); 53 54?> 55--EXPECT-- 56constant 57constant 58property 59static property 60method 61static method 62__invoke 63offsetGet 64offsetExists 65