Skip to content

Instantly share code, notes, and snippets.

@Yurunsoft Yurunsoft/test.php
Last active Oct 23, 2018

Embed
What would you like to do?
eval and new anonymous class bug
<?php
class A{
}
class B{
}
class C{
}
class D{
}
class E{
}
class F{
}
class G{
}
class H{
}
class I{
}
class J{
}
class K{
}
class L{
}
class M{
}
class N{
}
class O{
}
class P{
}
class Q{
}
class R{
}
class S{
}
class T{
}
class U{
}
class V{
}
class W{
}
class X{
}
class Y{
}
class Z{
}
for($i = 0; $i < 10; ++$i)
{
$className = chr(65 + mt_rand(0, 25));
$str = <<<STR
return new class extends {$className}{};
STR;
$object = eval($str);
if(!$object instanceof $className)
{
echo 'object is ', get_parent_class($object), ', but it must be ', $className, PHP_EOL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.