Add HPHP support for newInstanceWithoutConstructor

Add support for PHP >=5.4 ReflectionClass::newInstanceWithoutConstructor
Esse commit está contido em:
seanc
2013-03-29 16:47:38 -07:00
commit de Sara Golemon
commit c6d10ce255
7 arquivos alterados com 52 adições e 0 exclusões
+17
Ver Arquivo
@@ -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",
+4
Ver Arquivo
@@ -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);
}
+1
Ver Arquivo
@@ -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);
+13
Ver Arquivo
@@ -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
+1
Ver Arquivo
@@ -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 */",
+13
Ver Arquivo
@@ -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!