File: ReflectionProperty_getModifiers_basic.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (58 lines) | stat: -rw-r--r-- 1,053 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--TEST--
Test ReflectionProperty::getModifiers() usage.
--FILE--
<?php

class C {
    public $a1;
    protected $a2;
    private $a3;
    static public $a4;
    static protected $a5;
    static private $a6;
    public final $a7;
    public static final $a8;
    public $a9 { set { $this->a9 = strtoupper($value); } }
    public $a10 { get { return 42; } }
}

class D extends C {
    public $a1;
    protected $a2;
    private $a3;
    static public $a4;
    static protected $a5;
    static private $a6;
}

for ($i = 1;$i <= 10;$i++) {
    $rp = new ReflectionProperty("C", "a$i");
    echo "C::a$i: ";
    var_dump($rp->getModifiers());
    $rp = new ReflectionProperty("D", "a$i");
    echo "D::a$i: ";
    var_dump($rp->getModifiers());
}

?>
--EXPECT--
C::a1: int(1)
D::a1: int(1)
C::a2: int(2)
D::a2: int(2)
C::a3: int(4)
D::a3: int(4)
C::a4: int(17)
D::a4: int(17)
C::a5: int(18)
D::a5: int(18)
C::a6: int(20)
D::a6: int(20)
C::a7: int(33)
D::a7: int(33)
C::a8: int(49)
D::a8: int(49)
C::a9: int(1)
D::a9: int(1)
C::a10: int(513)
D::a10: int(513)