Skip to content

Commit ea9277b

Browse files
committed
Rename ReflectionAttribute::getAsObject to ReflectionAttribute::newInstance
1 parent efbf7d0 commit ea9277b

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

Zend/tests/attributes/002_rfcexample.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace {
2828

2929
var_dump($attributes[0]->getName());
3030
var_dump($attributes[0]->getArguments());
31-
var_dump($attributes[0]->getAsObject());
31+
var_dump($attributes[0]->newInstance());
3232
}
3333
--EXPECTF--
3434
string(28) "My\Attributes\SingleArgument"

Zend/tests/attributes/005_objects.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class A1
1818
$ref = new \ReflectionFunction(<<A1('test')>> function () { });
1919

2020
foreach ($ref->getAttributes() as $attr) {
21-
$obj = $attr->getAsObject();
22-
21+
$obj = $attr->newInstance();
22+
2323
var_dump(get_class($obj), $obj->name, $obj->ttl);
2424
}
2525

@@ -28,7 +28,7 @@ echo "\n";
2828
$ref = new \ReflectionFunction(<<A1>> function () { });
2929

3030
try {
31-
$ref->getAttributes()[0]->getAsObject();
31+
$ref->getAttributes()[0]->newInstance();
3232
} catch (\ArgumentCountError $e) {
3333
var_dump('ERROR 1', $e->getMessage());
3434
}
@@ -38,7 +38,7 @@ echo "\n";
3838
$ref = new \ReflectionFunction(<<A1([])>> function () { });
3939

4040
try {
41-
$ref->getAttributes()[0]->getAsObject();
41+
$ref->getAttributes()[0]->newInstance();
4242
} catch (\TypeError $e) {
4343
var_dump('ERROR 2', $e->getMessage());
4444
}
@@ -48,7 +48,7 @@ echo "\n";
4848
$ref = new \ReflectionFunction(<<A2>> function () { });
4949

5050
try {
51-
$ref->getAttributes()[0]->getAsObject();
51+
$ref->getAttributes()[0]->newInstance();
5252
} catch (\Error $e) {
5353
var_dump('ERROR 3', $e->getMessage());
5454
}
@@ -63,7 +63,7 @@ class A3
6363
$ref = new \ReflectionFunction(<<A3>> function () { });
6464

6565
try {
66-
$ref->getAttributes()[0]->getAsObject();
66+
$ref->getAttributes()[0]->newInstance();
6767
} catch (\Error $e) {
6868
var_dump('ERROR 4', $e->getMessage());
6969
}
@@ -75,7 +75,7 @@ class A4 { }
7575
$ref = new \ReflectionFunction(<<A4(1)>> function () { });
7676

7777
try {
78-
$ref->getAttributes()[0]->getAsObject();
78+
$ref->getAttributes()[0]->newInstance();
7979
} catch (\Error $e) {
8080
var_dump('ERROR 5', $e->getMessage());
8181
}

Zend/tests/attributes/007_wrong_compiler_attributes.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ class Foo
99
}
1010

1111
$ref = new ReflectionClass(Foo::class);
12-
var_dump($ref->getAttributes()[0]->getAsObject());
12+
var_dump($ref->getAttributes()[0]->newInstance());
1313
--EXPECTF--
1414
Fatal error: The PhpCompilerAttribute can only be used by internal classes, use PhpAttribute instead in %s

ext/reflection/php_reflection.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6647,9 +6647,9 @@ static void attribute_ctor_cleanup(zval *obj, zval *args, uint32_t argc) /* {{{
66476647
}
66486648
/* }}} */
66496649

6650-
/* {{{ proto public string ReflectionAttribute::getAsObject()
6650+
/* {{{ proto public string ReflectionAttribute::newInstance()
66516651
* Returns the attribute as an object */
6652-
ZEND_METHOD(ReflectionAttribute, getAsObject)
6652+
ZEND_METHOD(ReflectionAttribute, newInstance)
66536653
{
66546654
reflection_object *intern;
66556655
attribute_reference *attr;

ext/reflection/php_reflection.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public function getDefaultValueConstantName() {}
541541

542542
/** @return bool */
543543
public function isVariadic() {}
544-
544+
545545
/** @return ReflectionAttribute[] */
546546
public function getAttributes(?string $name = null, int $flags = 0) {}
547547
}
@@ -656,7 +656,7 @@ final class ReflectionAttribute
656656
{
657657
public function getName(): string {}
658658
public function getArguments(): array {}
659-
public function getAsObject(): object {}
659+
public function newInstance(): object {}
660660

661661
private function __clone() {}
662662

ext/reflection/php_reflection_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ ZEND_END_ARG_INFO()
472472

473473
#define arginfo_class_ReflectionAttribute_getArguments arginfo_class_ReflectionUnionType_getTypes
474474

475-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionAttribute_getAsObject, 0, 0, IS_OBJECT, 0)
475+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionAttribute_newInstance, 0, 0, IS_OBJECT, 0)
476476
ZEND_END_ARG_INFO()
477477

478478
#define arginfo_class_ReflectionAttribute___clone arginfo_class_ReflectionFunctionAbstract___clone
@@ -673,7 +673,7 @@ ZEND_METHOD(ReflectionReference, getId);
673673
ZEND_METHOD(ReflectionReference, __construct);
674674
ZEND_METHOD(ReflectionAttribute, getName);
675675
ZEND_METHOD(ReflectionAttribute, getArguments);
676-
ZEND_METHOD(ReflectionAttribute, getAsObject);
676+
ZEND_METHOD(ReflectionAttribute, newInstance);
677677
ZEND_METHOD(ReflectionAttribute, __clone);
678678
ZEND_METHOD(ReflectionAttribute, __construct);
679679

@@ -971,7 +971,7 @@ static const zend_function_entry class_ReflectionReference_methods[] = {
971971
static const zend_function_entry class_ReflectionAttribute_methods[] = {
972972
ZEND_ME(ReflectionAttribute, getName, arginfo_class_ReflectionAttribute_getName, ZEND_ACC_PUBLIC)
973973
ZEND_ME(ReflectionAttribute, getArguments, arginfo_class_ReflectionAttribute_getArguments, ZEND_ACC_PUBLIC)
974-
ZEND_ME(ReflectionAttribute, getAsObject, arginfo_class_ReflectionAttribute_getAsObject, ZEND_ACC_PUBLIC)
974+
ZEND_ME(ReflectionAttribute, newInstance, arginfo_class_ReflectionAttribute_newInstance, ZEND_ACC_PUBLIC)
975975
ZEND_ME(ReflectionAttribute, __clone, arginfo_class_ReflectionAttribute___clone, ZEND_ACC_PRIVATE)
976976
ZEND_ME(ReflectionAttribute, __construct, arginfo_class_ReflectionAttribute___construct, ZEND_ACC_PRIVATE)
977977
ZEND_FE_END

0 commit comments

Comments
 (0)