Skip to content

Tidy #6161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Tidy #6161

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Zend/tests/attributes/001_placement.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ $sources = [
];

foreach ($sources as $r) {
$attr = $r->getAttributes();
var_dump(get_class($r), count($attr));
$attr = $r->getAttributes();
var_dump(get_class($r), count($attr));

foreach ($attr as $a) {
var_dump($a->getName(), $a->getArguments());
Expand Down
14 changes: 7 additions & 7 deletions Zend/tests/attributes/003_ast_nodes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define('V1', strtoupper(php_sapi_name()));
#[A1([V1 => V1])]
class C1
{
public const BAR = 'bar';
public const BAR = 'bar';
}

$ref = new \ReflectionClass(C1::class);
Expand Down Expand Up @@ -38,7 +38,7 @@ echo "\n";
#[A1(self::FOO, C1::BAR)]
class C3
{
private const FOO = 'foo';
private const FOO = 'foo';
}

$ref = new \ReflectionClass(C3::class);
Expand All @@ -62,23 +62,23 @@ echo "\n";
#[Attribute]
class C5
{
public function __construct() { }
public function __construct() { }
}

$ref = new \ReflectionFunction(#[C5(MissingClass::SOME_CONST)] function () { });
$attr = $ref->getAttributes();
var_dump(count($attr));

try {
$attr[0]->getArguments();
$attr[0]->getArguments();
} catch (\Error $e) {
var_dump($e->getMessage());
var_dump($e->getMessage());
}

try {
$attr[0]->newInstance();
$attr[0]->newInstance();
} catch (\Error $e) {
var_dump($e->getMessage());
var_dump($e->getMessage());
}

?>
Expand Down
46 changes: 23 additions & 23 deletions Zend/tests/attributes/005_objects.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,68 @@ Attributes can be converted into objects.
#[Attribute(Attribute::TARGET_FUNCTION)]
class A1
{
public string $name;
public int $ttl;

public function __construct(string $name, int $ttl = 50)
{
$this->name = $name;
$this->ttl = $ttl;
}
public string $name;
public int $ttl;

public function __construct(string $name, int $ttl = 50)
{
$this->name = $name;
$this->ttl = $ttl;
}
}

$ref = new \ReflectionFunction(#[A1('test')] function () { });

foreach ($ref->getAttributes() as $attr) {
$obj = $attr->newInstance();
$obj = $attr->newInstance();

var_dump(get_class($obj), $obj->name, $obj->ttl);
var_dump(get_class($obj), $obj->name, $obj->ttl);
}

echo "\n";

$ref = new \ReflectionFunction(#[A1] function () { });

try {
$ref->getAttributes()[0]->newInstance();
$ref->getAttributes()[0]->newInstance();
} catch (\ArgumentCountError $e) {
var_dump('ERROR 1', $e->getMessage());
var_dump('ERROR 1', $e->getMessage());
}

echo "\n";

$ref = new \ReflectionFunction(#[A1([])] function () { });

try {
$ref->getAttributes()[0]->newInstance();
$ref->getAttributes()[0]->newInstance();
} catch (\TypeError $e) {
var_dump('ERROR 2', $e->getMessage());
var_dump('ERROR 2', $e->getMessage());
}

echo "\n";

$ref = new \ReflectionFunction(#[A2] function () { });

try {
$ref->getAttributes()[0]->newInstance();
$ref->getAttributes()[0]->newInstance();
} catch (\Error $e) {
var_dump('ERROR 3', $e->getMessage());
var_dump('ERROR 3', $e->getMessage());
}

echo "\n";

#[Attribute]
class A3
{
private function __construct() { }
private function __construct() { }
}

$ref = new \ReflectionFunction(#[A3] function () { });

try {
$ref->getAttributes()[0]->newInstance();
$ref->getAttributes()[0]->newInstance();
} catch (\Error $e) {
var_dump('ERROR 4', $e->getMessage());
var_dump('ERROR 4', $e->getMessage());
}

echo "\n";
Expand All @@ -78,9 +78,9 @@ class A4 { }
$ref = new \ReflectionFunction(#[A4(1)] function () { });

try {
$ref->getAttributes()[0]->newInstance();
$ref->getAttributes()[0]->newInstance();
} catch (\Error $e) {
var_dump('ERROR 5', $e->getMessage());
var_dump('ERROR 5', $e->getMessage());
}

echo "\n";
Expand All @@ -90,9 +90,9 @@ class A5 { }
$ref = new \ReflectionFunction(#[A5] function () { });

try {
$ref->getAttributes()[0]->newInstance();
$ref->getAttributes()[0]->newInstance();
} catch (\Error $e) {
var_dump('ERROR 6', $e->getMessage());
var_dump('ERROR 6', $e->getMessage());
}

?>
Expand Down
8 changes: 4 additions & 4 deletions Zend/tests/attributes/006_filter.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ echo "\n";
$ref = new \ReflectionFunction(function () { });

try {
$ref->getAttributes(A1::class, 3);
$ref->getAttributes(A1::class, 3);
} catch (\Error $e) {
var_dump('ERROR 1', $e->getMessage());
var_dump('ERROR 1', $e->getMessage());
}

$ref = new \ReflectionFunction(function () { });

try {
$ref->getAttributes(SomeMissingClass::class, \ReflectionAttribute::IS_INSTANCEOF);
$ref->getAttributes(SomeMissingClass::class, \ReflectionAttribute::IS_INSTANCEOF);
} catch (\Error $e) {
var_dump('ERROR 2', $e->getMessage());
var_dump('ERROR 2', $e->getMessage());
}

?>
Expand Down
20 changes: 10 additions & 10 deletions Zend/tests/attributes/011_inheritance.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ Attributes comply with inheritance rules.
#[A2]
class C1
{
#[A1]
public function foo() { }
#[A1]
public function foo() { }
}

class C2 extends C1
{
public function foo() { }
public function foo() { }
}

class C3 extends C1
{
#[A1]
public function bar() { }
#[A1]
public function bar() { }
}

$ref = new \ReflectionClass(C1::class);
Expand All @@ -37,20 +37,20 @@ echo "\n";

trait T1
{
#[A2]
public $a;
#[A2]
public $a;
}

class C4
{
use T1;
use T1;
}

class C5
{
use T1;
use T1;

public $a;
public $a;
}

$ref = new \ReflectionClass(T1::class);
Expand Down
12 changes: 6 additions & 6 deletions Zend/tests/attributes/012_ast_export.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ assert(0 && ($a = #[A1] #[A2] function ($a, #[A3(1)] $b) { }));
assert(0 && ($a = #[A1(1, 2, 1 + 2)] fn () => 1));

assert(0 && ($a = new #[A1] class() {
#[A1]#[A2] const FOO = 'foo';
#[A2] public $x;
#[A3] function a() { }
#[A1]#[A2] const FOO = 'foo';
#[A2] public $x;
#[A3] function a() { }
}));

assert(0 && ($a = function () {
#[A1] class Test1 { }
#[A2] interface Test2 { }
#[A3] trait Test3 { }
#[A1] class Test1 { }
#[A2] interface Test2 { }
#[A3] trait Test3 { }
}));

?>
Expand Down
40 changes: 20 additions & 20 deletions Zend/tests/attributes/013_class_scope.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Attributes make use of class scope.
#[A1(self::class, self::FOO)]
class C1
{
#[A1(self::class, self::FOO)]
private const FOO = 'foo';
#[A1(self::class, self::FOO)]
private const FOO = 'foo';

#[A1(self::class, self::FOO)]
public $a;
#[A1(self::class, self::FOO)]
public $a;

#[A1(self::class, self::FOO)]
public function bar(#[A1(self::class, self::FOO)] $p) { }
#[A1(self::class, self::FOO)]
public function bar(#[A1(self::class, self::FOO)] $p) { }
}

$ref = new \ReflectionClass(C1::class);
Expand All @@ -27,15 +27,15 @@ echo "\n";

trait T1
{
#[A1(self::class, self::FOO)]
public function foo() { }
#[A1(self::class, self::FOO)]
public function foo() { }
}

class C2
{
use T1;
use T1;

private const FOO = 'bar';
private const FOO = 'bar';
}

$ref = new \ReflectionClass(C2::class);
Expand All @@ -45,7 +45,7 @@ $ref = new \ReflectionClass(T1::class);
$attr = $ref->getMethod('foo')->getAttributes()[0];

try {
$attr->getArguments();
$attr->getArguments();
} catch (\Error $e) {
var_dump('ERROR 1', $e->getMessage());
}
Expand All @@ -54,17 +54,17 @@ echo "\n";

class C3
{
private const FOO = 'foo';
private const FOO = 'foo';

public static function foo()
{
return new #[A1(self::class, self::FOO)] class() {
private const FOO = 'bar';
public static function foo()
{
return new #[A1(self::class, self::FOO)] class() {
private const FOO = 'bar';

#[A1(self::class, self::FOO)]
public function bar() { }
};
}
#[A1(self::class, self::FOO)]
public function bar() { }
};
}
}

$ref = new \ReflectionObject(C3::foo());
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/attributes/014_class_const_group.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Attributes cannot be applied to groups of class constants.

class C1
{
#[A1]
public const A = 1, B = 2;
#[A1]
public const A = 1, B = 2;
}

?>
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/attributes/015_property_group.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Attributes cannot be applied to groups of properties.

class C1
{
#[A1]
public $x, $y;
#[A1]
public $x, $y;
}

?>
Expand Down
12 changes: 6 additions & 6 deletions Zend/tests/attributes/017_closure_scope.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Attributes make use of closure scope.

class Test1
{
private const FOO = 'bar';
private const FOO = 'bar';
}

class C1
{
private const FOO = 'foo';
private const FOO = 'foo';

public static function foo()
{
return #[A1(self::class, self::FOO)] function (#[A1(self::class, self::FOO)] $p) { };
}
public static function foo()
{
return #[A1(self::class, self::FOO)] function (#[A1(self::class, self::FOO)] $p) { };
}
}

$ref = new \ReflectionFunction(C1::foo());
Expand Down
Loading