Add HPHP support for newInstanceWithoutConstructor
Add support for PHP >=5.4 ReflectionClass::newInstanceWithoutConstructor
Esse commit está contido em:
@@ -251,6 +251,23 @@ DefineFunction(
|
||||
'taint_observer' => false,
|
||||
));
|
||||
|
||||
DefineFunction(
|
||||
array(
|
||||
'name' => "hphp_create_object_without_constructor",
|
||||
'desc' => "Used by FFI interface for other languages to call into PHP.",
|
||||
'flags' => HasDocComment | HipHopSpecific | NoInjection,
|
||||
'return' => array(
|
||||
'type' => Object,
|
||||
),
|
||||
'args' => array(
|
||||
array(
|
||||
'name' => "name",
|
||||
'type' => String,
|
||||
),
|
||||
),
|
||||
'taint_observer' => false,
|
||||
));
|
||||
|
||||
DefineFunction(
|
||||
array(
|
||||
'name' => "hphp_get_property",
|
||||
|
||||
@@ -862,6 +862,10 @@ Object f_hphp_create_object(CStrRef name, CArrRef params) {
|
||||
return g_vmContext->createObject(name.get(), params);
|
||||
}
|
||||
|
||||
Object f_hphp_create_object_without_constructor(CStrRef name) {
|
||||
return g_vmContext->createObject(name.get(), nullptr, false);
|
||||
}
|
||||
|
||||
Variant f_hphp_get_property(CObjRef obj, CStrRef cls, CStrRef prop) {
|
||||
return obj->o_get(prop);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ Variant f_hphp_invoke(CStrRef name, CArrRef params);
|
||||
Variant f_hphp_invoke_method(CVarRef obj, CStrRef cls, CStrRef name, CArrRef params);
|
||||
bool f_hphp_instanceof(CObjRef obj, CStrRef name);
|
||||
Object f_hphp_create_object(CStrRef name, CArrRef params);
|
||||
Object f_hphp_create_object_without_constructor(CStrRef name);
|
||||
Variant f_hphp_get_property(CObjRef obj, CStrRef cls, CStrRef prop);
|
||||
void f_hphp_set_property(CObjRef obj, CStrRef cls, CStrRef prop, CVarRef value);
|
||||
Variant f_hphp_get_static_property(CStrRef cls, CStrRef prop);
|
||||
|
||||
@@ -1257,6 +1257,19 @@ class ReflectionClass implements Reflector {
|
||||
return hphp_create_object($this->name, array_values($args));
|
||||
}
|
||||
|
||||
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
|
||||
/**
|
||||
* ( excerpt from
|
||||
* http://php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php )
|
||||
*
|
||||
* Creates a new instance of the class without invoking the constructor.
|
||||
*
|
||||
* @return mixed Returns a new instance of the class.
|
||||
*/
|
||||
public function newInstanceWithoutConstructor() {
|
||||
return hphp_create_object_without_constructor($this->name);
|
||||
}
|
||||
|
||||
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
|
||||
/**
|
||||
* ( excerpt from
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"hphp_invoke_method", T(Variant), S(0), "obj", T(Variant), NULL, S(0), NULL, S(0), "cls", T(String), NULL, S(0), NULL, S(0), "name", T(String), NULL, S(0), NULL, S(0), "params", T(Array), NULL, S(0), NULL, S(0), NULL, S(4276224), "/**\n * ( HipHop specific )\n *\n * Used by FFI interface for other languages to call into PHP.\n *\n * @obj mixed\n * @cls string\n * @name string\n * @params vector\n *\n * @return mixed\n */",
|
||||
"hphp_instanceof", T(Boolean), S(0), "obj", T(Object), NULL, S(0), NULL, S(0), "name", T(String), NULL, S(0), NULL, S(0), NULL, S(4276224), "/**\n * ( HipHop specific )\n *\n * Used by FFI interface for other languages to call into PHP.\n *\n * @obj object\n * @name string\n *\n * @return bool\n */",
|
||||
"hphp_create_object", T(Object), S(0), "name", T(String), NULL, S(0), NULL, S(0), "params", T(Array), NULL, S(0), NULL, S(0), NULL, S(4276224), "/**\n * ( HipHop specific )\n *\n * Used by FFI interface for other languages to call into PHP.\n *\n * @name string\n * @params vector\n *\n * @return object\n */",
|
||||
"hphp_create_object_without_constructor", T(Object), S(0), "name", T(String), NULL, S(0), NULL, S(0), NULL, S(4276224), "/**\n * ( HipHop specific )\n *\n * Used by FFI interface for other languages to call into PHP.\n *\n * @name string\n *\n * @return object\n */",
|
||||
"hphp_get_property", T(Variant), S(0), "obj", T(Object), NULL, S(0), NULL, S(0), "cls", T(String), NULL, S(0), NULL, S(0), "prop", T(String), NULL, S(0), NULL, S(0), NULL, S(4276224), "/**\n * ( HipHop specific )\n *\n * Used by FFI interface for other languages to call into PHP.\n *\n * @obj object\n * @cls string\n * @prop string\n *\n * @return mixed\n */",
|
||||
"hphp_set_property", T(Void), S(0), "obj", T(Object), NULL, S(0), NULL, S(0), "cls", T(String), NULL, S(0), NULL, S(0), "prop", T(String), NULL, S(0), NULL, S(0), "value", T(Variant), NULL, S(0), NULL, S(0), NULL, S(4276224), "/**\n * ( HipHop specific )\n *\n * Used by FFI interface for other languages to call into PHP.\n *\n * @obj object\n * @cls string\n * @prop string\n * @value mixed\n */",
|
||||
"hphp_get_static_property", T(Variant), S(0), "cls", T(String), NULL, S(0), NULL, S(0), "prop", T(String), NULL, S(0), NULL, S(0), NULL, S(4276224), "/**\n * ( HipHop specific )\n *\n * Used by FFI interface for other languages to call into PHP.\n *\n * @cls string\n * @prop string\n *\n * @return mixed\n */",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
class foo {
|
||||
|
||||
public function __construct() {
|
||||
print "this should only be printed three times!\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$c1 = new foo();
|
||||
$c2 = (new ReflectionClass('foo'))->newInstance();
|
||||
$c3 = (new ReflectionClass('foo'))->newInstanceArgs(array());
|
||||
$no_c = (new ReflectionClass('foo'))->newInstanceWithoutConstructor();
|
||||
@@ -0,0 +1,3 @@
|
||||
this should only be printed three times!
|
||||
this should only be printed three times!
|
||||
this should only be printed three times!
|
||||
Referência em uma Nova Issue
Bloquear um usuário