Skip to content

Commit

Permalink
- Fix #52854 (ReflectionClass::newInstanceArgs does not work for clas…
Browse files Browse the repository at this point in the history
…ses without constructors
  • Loading branch information
johannes committed Nov 21, 2010
1 parent 1ac484d commit 9ea04e1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- Fixed bug #53366 (Reflection doesnt get dynamic property value from
getProperty()). (Felipe)
- Fixed bug #53362 (Segmentation fault when extending SplFixedArray). (Felipe)
- Fixed bug #52854 (ReflectionClass::newInstanceArgs does not work for classes
without constructors). (Johannes)
- Fixed bug #50987 (unaligned memory access in phar.c).
(geissert at debian dot org, Ilia)
- Fixed bug #47168 (printf of floating point variable prints maximum of 40
Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -4013,7 +4013,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
if (params) {
efree(params);
}
} else if (!ZEND_NUM_ARGS()) {
} else if (!ZEND_NUM_ARGS() || !argc) {
object_init_ex(return_value, ce);
} else {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name);
Expand Down
28 changes: 28 additions & 0 deletions ext/reflection/tests/bug52854.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
Bug #52854: ReflectionClass::newInstanceArgs does not work for classes without constructors
--FILE--
<?php
class Test {
}
$c = new ReflectionClass('Test');
var_dump(new Test);
var_dump(new Test());
var_dump($c->newInstance());
var_dump($c->newInstanceArgs(array()));

try {
var_dump($c->newInstanceArgs(array(1)));
} catch(ReflectionException $e) {
echo $e->getMessage()."\n";
}
?>
--EXPECTF--
object(Test)#2 (0) {
}
object(Test)#2 (0) {
}
object(Test)#2 (0) {
}
object(Test)#2 (0) {
}
Class Test does not have a constructor, so you cannot pass any constructor arguments

0 comments on commit 9ea04e1

Please sign in to comment.