peachpiecompiler / peachpie

PeachPie - the PHP compiler and runtime for .NET and .NET Core
https://www.peachpie.io
Apache License 2.0
2.31k stars 202 forks source link

class declaration is postponed even it shouldn't #992

Open jakubmisek opened 2 years ago

jakubmisek commented 2 years ago

The compiler treats class declaration as postponed even if it could be declared immediately upon script include. This results in classes not being declared as expected.

Sample:

<?php
include_once "x.php";
<?php // x.php
include_once "y.php";
assert(class_exists(X::class));
class X { } // X is declared immediately
<?php // y.php
assert(class_exists(Y::class)); // X was defined, so Y should be declared when entering this file already
class Y extends X { }