comparison vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
12:7a779792577d 13:5fb285c0d0e3
1 <?php 1 <?php declare(strict_types=1);
2 2
3 namespace PhpParser\Node\Stmt; 3 namespace PhpParser\Node\Stmt;
4 4
5 use PhpParser\Error; 5 use PhpParser\Error;
6 use PhpParser\Node; 6 use PhpParser\Node;
13 const MODIFIER_STATIC = 8; 13 const MODIFIER_STATIC = 8;
14 const MODIFIER_ABSTRACT = 16; 14 const MODIFIER_ABSTRACT = 16;
15 const MODIFIER_FINAL = 32; 15 const MODIFIER_FINAL = 32;
16 16
17 const VISIBILITY_MODIFIER_MASK = 7; // 1 | 2 | 4 17 const VISIBILITY_MODIFIER_MASK = 7; // 1 | 2 | 4
18 /** @deprecated */
19 const VISIBILITY_MODIFER_MASK = self::VISIBILITY_MODIFIER_MASK;
20 18
21 /** @var int Type */ 19 /** @var int Type */
22 public $flags; 20 public $flags;
23 /** @var null|Node\Name Name of extended class */ 21 /** @var null|Node\Name Name of extended class */
24 public $extends; 22 public $extends;
25 /** @var Node\Name[] Names of implemented interfaces */ 23 /** @var Node\Name[] Names of implemented interfaces */
26 public $implements; 24 public $implements;
27 25
28 /** @deprecated Use $flags instead */
29 public $type;
30
31 protected static $specialNames = array(
32 'self' => true,
33 'parent' => true,
34 'static' => true,
35 );
36
37 /** 26 /**
38 * Constructs a class node. 27 * Constructs a class node.
39 * 28 *
40 * @param string|null $name Name 29 * @param string|Node\Identifier|null $name Name
41 * @param array $subNodes Array of the following optional subnodes: 30 * @param array $subNodes Array of the following optional subnodes:
42 * 'flags' => 0 : Flags 31 * 'flags' => 0 : Flags
43 * 'extends' => null : Name of extended class 32 * 'extends' => null : Name of extended class
44 * 'implements' => array(): Names of implemented interfaces 33 * 'implements' => array(): Names of implemented interfaces
45 * 'stmts' => array(): Statements 34 * 'stmts' => array(): Statements
46 * @param array $attributes Additional attributes 35 * @param array $attributes Additional attributes
47 */ 36 */
48 public function __construct($name, array $subNodes = array(), array $attributes = array()) { 37 public function __construct($name, array $subNodes = [], array $attributes = []) {
49 parent::__construct($attributes); 38 parent::__construct($attributes);
50 $this->flags = isset($subNodes['flags']) ? $subNodes['flags'] 39 $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0;
51 : (isset($subNodes['type']) ? $subNodes['type'] : 0); 40 $this->name = \is_string($name) ? new Node\Identifier($name) : $name;
52 $this->type = $this->flags; 41 $this->extends = $subNodes['extends'] ?? null;
53 $this->name = $name; 42 $this->implements = $subNodes['implements'] ?? [];
54 $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : null; 43 $this->stmts = $subNodes['stmts'] ?? [];
55 $this->implements = isset($subNodes['implements']) ? $subNodes['implements'] : array();
56 $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
57 } 44 }
58 45
59 public function getSubNodeNames() { 46 public function getSubNodeNames() : array {
60 return array('flags', 'name', 'extends', 'implements', 'stmts'); 47 return ['flags', 'name', 'extends', 'implements', 'stmts'];
61 } 48 }
62 49
63 public function isAbstract() { 50 /**
51 * Whether the class is explicitly abstract.
52 *
53 * @return bool
54 */
55 public function isAbstract() : bool {
64 return (bool) ($this->flags & self::MODIFIER_ABSTRACT); 56 return (bool) ($this->flags & self::MODIFIER_ABSTRACT);
65 } 57 }
66 58
67 public function isFinal() { 59 /**
60 * Whether the class is final.
61 *
62 * @return bool
63 */
64 public function isFinal() : bool {
68 return (bool) ($this->flags & self::MODIFIER_FINAL); 65 return (bool) ($this->flags & self::MODIFIER_FINAL);
69 } 66 }
70 67
71 public function isAnonymous() { 68 /**
69 * Whether the class is anonymous.
70 *
71 * @return bool
72 */
73 public function isAnonymous() : bool {
72 return null === $this->name; 74 return null === $this->name;
73 } 75 }
74 76
75 /** 77 /**
76 * @internal 78 * @internal
94 96
95 if ($a & 48 && $b & 48) { 97 if ($a & 48 && $b & 48) {
96 throw new Error('Cannot use the final modifier on an abstract class member'); 98 throw new Error('Cannot use the final modifier on an abstract class member');
97 } 99 }
98 } 100 }
101
102 public function getType() : string {
103 return 'Stmt_Class';
104 }
99 } 105 }