Property::isStatic()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace PhpParser\Node\Stmt;
4
5
use PhpParser\Node;
6
use PhpParser\Error;
7
8
class Property extends Node\Stmt
9
{
10
    /** @var int Modifiers */
11
    public $type;
12
    /** @var PropertyProperty[] Properties */
13
    public $props;
14
15
    /**
16
     * Constructs a class property list node.
17
     *
18
     * @param int                $type       Modifiers
19
     * @param PropertyProperty[] $props      Properties
20
     * @param array              $attributes Additional attributes
21
     */
22
    public function __construct($type, array $props, array $attributes = array()) {
23
        if ($type & Class_::MODIFIER_ABSTRACT) {
24
            throw new Error('Properties cannot be declared abstract');
25
        }
26
27
        if ($type & Class_::MODIFIER_FINAL) {
28
            throw new Error('Properties cannot be declared final');
29
        }
30
31
        parent::__construct($attributes);
32
        $this->type = $type;
33
        $this->props = $props;
34
    }
35
36
    public function getSubNodeNames() {
37
        return array('type', 'props');
38
    }
39
40
    public function isPublic() {
41
        return ($this->type & Class_::MODIFIER_PUBLIC) !== 0
42
            || ($this->type & Class_::VISIBILITY_MODIFER_MASK) === 0;
43
    }
44
45
    public function isProtected() {
46
        return (bool) ($this->type & Class_::MODIFIER_PROTECTED);
47
    }
48
49
    public function isPrivate() {
50
        return (bool) ($this->type & Class_::MODIFIER_PRIVATE);
51
    }
52
53
    public function isStatic() {
54
        return (bool) ($this->type & Class_::MODIFIER_STATIC);
55
    }
56
}
57