addFiles([$source]); $compiler->prepareFile($source); $code = file_get_contents($compiler->convertFile($source)); self::assertIsString($code); // Exact new object definition get_class() folds to compile-time literal string self::assertMatchesRegularExpression( '/php_getexactclass\(\) \{.*?tmp_var_\d+ = \(get_str\(\d+\)\);/s', $code, ); // Polymorphic get_class() must NOT fold or blindly invoke unchecked C++ helper; // it must use runtime php::call to enforce PHP argument semantics (TypeError on null) self::assertMatchesRegularExpression( "/php_getpolymorphicclass\(\) \{.*?tmp_var_\d+ = \(php::call\(get_persistent_func\(PersistentFuncId\{0\}, get_str\(3\)\), php::VarList\{animal\}\)\);/s", $code, ); // Exact new object definition static call devirtualizes to cached call self::assertMatchesRegularExpression( '/php_callexactstatic\(\) \{.*?typephp_call_cached\(get_str\(\d+\)/s', $code, ); // Polymorphic static call from global function dispatches dynamically via callStaticMethod self::assertMatchesRegularExpression( '/php_callpolymorphicstatic\(\) \{.*?php::callStaticMethod\([^)]+\)/s', $code, ); // Polymorphic static call from within a class method preserves lexical callable scope self::assertMatchesRegularExpression( "/php_basescopedcaller__exercise\(.*?php::CallableScope (tmp_var_\d+) = php::getCallableScope\(.*?php::callScoped\(php::concat\(.*?, \\1\)/s", $code, ); } }