Skip to content

Commit 031621d

Browse files
committed
Attempt to fix PHP 8.0
1 parent 3ea4fc3 commit 031621d

File tree

2 files changed

+63
-59
lines changed

2 files changed

+63
-59
lines changed

stubs/runtime/Attribute.php

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,66 @@
11
<?php
22

3-
if (class_exists('Attribute', false)) {
4-
return;
5-
}
3+
if (\PHP_VERSION_ID < 80000) {
4+
if (class_exists('Attribute', false)) {
5+
return;
6+
}
7+
8+
#[Attribute(Attribute::TARGET_CLASS)]
9+
class Attribute
10+
{
611

7-
#[Attribute(Attribute::TARGET_CLASS)]
8-
class Attribute
9-
{
12+
/** @var int */
13+
public $flags;
1014

11-
/** @var int */
12-
public $flags;
15+
/**
16+
* Marks that attribute declaration is allowed only in classes.
17+
*/
18+
const TARGET_CLASS = 1;
1319

14-
/**
15-
* Marks that attribute declaration is allowed only in classes.
16-
*/
17-
const TARGET_CLASS = 1;
20+
/**
21+
* Marks that attribute declaration is allowed only in functions.
22+
*/
23+
const TARGET_FUNCTION = 1 << 1;
1824

19-
/**
20-
* Marks that attribute declaration is allowed only in functions.
21-
*/
22-
const TARGET_FUNCTION = 1 << 1;
25+
/**
26+
* Marks that attribute declaration is allowed only in class methods.
27+
*/
28+
const TARGET_METHOD = 1 << 2;
2329

24-
/**
25-
* Marks that attribute declaration is allowed only in class methods.
26-
*/
27-
const TARGET_METHOD = 1 << 2;
30+
/**
31+
* Marks that attribute declaration is allowed only in class properties.
32+
*/
33+
const TARGET_PROPERTY = 1 << 3;
2834

29-
/**
30-
* Marks that attribute declaration is allowed only in class properties.
31-
*/
32-
const TARGET_PROPERTY = 1 << 3;
35+
/**
36+
* Marks that attribute declaration is allowed only in class constants.
37+
*/
38+
const TARGET_CLASS_CONSTANT = 1 << 4;
3339

34-
/**
35-
* Marks that attribute declaration is allowed only in class constants.
36-
*/
37-
const TARGET_CLASS_CONSTANT = 1 << 4;
40+
/**
41+
* Marks that attribute declaration is allowed only in function or method parameters.
42+
*/
43+
const TARGET_PARAMETER = 1 << 5;
3844

39-
/**
40-
* Marks that attribute declaration is allowed only in function or method parameters.
41-
*/
42-
const TARGET_PARAMETER = 1 << 5;
45+
/**
46+
* Marks that attribute declaration is allowed anywhere.
47+
*/
48+
const TARGET_ALL = (1 << 6) - 1;
4349

44-
/**
45-
* Marks that attribute declaration is allowed anywhere.
46-
*/
47-
const TARGET_ALL = (1 << 6) - 1;
50+
/**
51+
* Notes that an attribute declaration in the same place is
52+
* allowed multiple times.
53+
*/
54+
const IS_REPEATABLE = 1 << 10;
4855

49-
/**
50-
* Notes that an attribute declaration in the same place is
51-
* allowed multiple times.
52-
*/
53-
const IS_REPEATABLE = 1 << 10;
56+
/**
57+
* @param int $flags A value in the form of a bitmask indicating the places
58+
* where attributes can be defined.
59+
*/
60+
public function __construct($flags = self::TARGET_ALL)
61+
{
62+
$this->flags = $flags;
63+
}
5464

55-
/**
56-
* @param int $flags A value in the form of a bitmask indicating the places
57-
* where attributes can be defined.
58-
*/
59-
public function __construct($flags = self::TARGET_ALL)
60-
{
61-
$this->flags = $flags;
6265
}
63-
6466
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?php
22

3-
if (class_exists('ReflectionUnionType', false)) {
4-
return;
5-
}
6-
7-
class ReflectionUnionType extends ReflectionType
8-
{
3+
if (\PHP_VERSION_ID < 80000) {
4+
if (class_exists('ReflectionUnionType', false)) {
5+
return;
6+
}
97

10-
/** @return ReflectionType[] */
11-
public function getTypes()
8+
class ReflectionUnionType extends ReflectionType
129
{
13-
return [];
14-
}
1510

11+
/** @return ReflectionType[] */
12+
public function getTypes()
13+
{
14+
return [];
15+
}
16+
17+
}
1618
}

0 commit comments

Comments
 (0)