annotate vendor/nikic/php-parser/test/code/parser/stmt/class/modifier.test @ 1:1a348b17ec81

Logo and header background
author Chris Cannam
date Thu, 30 Nov 2017 14:56:35 +0000
parents 4c8ae668cc8c
children 5fb285c0d0e3
rev   line source
Chris@0 1 Invalid modifier combination
Chris@0 2 -----
Chris@0 3 <?php class A { public public $a; }
Chris@0 4 -----
Chris@0 5 Multiple access type modifiers are not allowed from 1:24 to 1:29
Chris@0 6 array(
Chris@0 7 0: Stmt_Class(
Chris@0 8 flags: 0
Chris@0 9 name: A
Chris@0 10 extends: null
Chris@0 11 implements: array(
Chris@0 12 )
Chris@0 13 stmts: array(
Chris@0 14 0: Stmt_Property(
Chris@0 15 flags: MODIFIER_PUBLIC (1)
Chris@0 16 props: array(
Chris@0 17 0: Stmt_PropertyProperty(
Chris@0 18 name: a
Chris@0 19 default: null
Chris@0 20 )
Chris@0 21 )
Chris@0 22 )
Chris@0 23 )
Chris@0 24 )
Chris@0 25 )
Chris@0 26 -----
Chris@0 27 <?php class A { public protected $a; }
Chris@0 28 -----
Chris@0 29 Multiple access type modifiers are not allowed from 1:24 to 1:32
Chris@0 30 array(
Chris@0 31 0: Stmt_Class(
Chris@0 32 flags: 0
Chris@0 33 name: A
Chris@0 34 extends: null
Chris@0 35 implements: array(
Chris@0 36 )
Chris@0 37 stmts: array(
Chris@0 38 0: Stmt_Property(
Chris@0 39 flags: MODIFIER_PUBLIC | MODIFIER_PROTECTED (3)
Chris@0 40 props: array(
Chris@0 41 0: Stmt_PropertyProperty(
Chris@0 42 name: a
Chris@0 43 default: null
Chris@0 44 )
Chris@0 45 )
Chris@0 46 )
Chris@0 47 )
Chris@0 48 )
Chris@0 49 )
Chris@0 50 -----
Chris@0 51 <?php class A { abstract abstract function a(); }
Chris@0 52 -----
Chris@0 53 Multiple abstract modifiers are not allowed from 1:26 to 1:33
Chris@0 54 array(
Chris@0 55 0: Stmt_Class(
Chris@0 56 flags: 0
Chris@0 57 name: A
Chris@0 58 extends: null
Chris@0 59 implements: array(
Chris@0 60 )
Chris@0 61 stmts: array(
Chris@0 62 0: Stmt_ClassMethod(
Chris@0 63 flags: MODIFIER_ABSTRACT (16)
Chris@0 64 byRef: false
Chris@0 65 name: a
Chris@0 66 params: array(
Chris@0 67 )
Chris@0 68 returnType: null
Chris@0 69 stmts: null
Chris@0 70 )
Chris@0 71 )
Chris@0 72 )
Chris@0 73 )
Chris@0 74 -----
Chris@0 75 <?php class A { static static $a; }
Chris@0 76 -----
Chris@0 77 Multiple static modifiers are not allowed from 1:24 to 1:29
Chris@0 78 array(
Chris@0 79 0: Stmt_Class(
Chris@0 80 flags: 0
Chris@0 81 name: A
Chris@0 82 extends: null
Chris@0 83 implements: array(
Chris@0 84 )
Chris@0 85 stmts: array(
Chris@0 86 0: Stmt_Property(
Chris@0 87 flags: MODIFIER_STATIC (8)
Chris@0 88 props: array(
Chris@0 89 0: Stmt_PropertyProperty(
Chris@0 90 name: a
Chris@0 91 default: null
Chris@0 92 )
Chris@0 93 )
Chris@0 94 )
Chris@0 95 )
Chris@0 96 )
Chris@0 97 )
Chris@0 98 -----
Chris@0 99 <?php class A { final final function a() {} }
Chris@0 100 -----
Chris@0 101 Multiple final modifiers are not allowed from 1:23 to 1:27
Chris@0 102 array(
Chris@0 103 0: Stmt_Class(
Chris@0 104 flags: 0
Chris@0 105 name: A
Chris@0 106 extends: null
Chris@0 107 implements: array(
Chris@0 108 )
Chris@0 109 stmts: array(
Chris@0 110 0: Stmt_ClassMethod(
Chris@0 111 flags: MODIFIER_FINAL (32)
Chris@0 112 byRef: false
Chris@0 113 name: a
Chris@0 114 params: array(
Chris@0 115 )
Chris@0 116 returnType: null
Chris@0 117 stmts: array(
Chris@0 118 )
Chris@0 119 )
Chris@0 120 )
Chris@0 121 )
Chris@0 122 )
Chris@0 123 -----
Chris@0 124 <?php class A { abstract final function a(); }
Chris@0 125 -----
Chris@0 126 Cannot use the final modifier on an abstract class member from 1:26 to 1:30
Chris@0 127 array(
Chris@0 128 0: Stmt_Class(
Chris@0 129 flags: 0
Chris@0 130 name: A
Chris@0 131 extends: null
Chris@0 132 implements: array(
Chris@0 133 )
Chris@0 134 stmts: array(
Chris@0 135 0: Stmt_ClassMethod(
Chris@0 136 flags: MODIFIER_ABSTRACT | MODIFIER_FINAL (48)
Chris@0 137 byRef: false
Chris@0 138 name: a
Chris@0 139 params: array(
Chris@0 140 )
Chris@0 141 returnType: null
Chris@0 142 stmts: null
Chris@0 143 )
Chris@0 144 )
Chris@0 145 )
Chris@0 146 )
Chris@0 147 -----
Chris@0 148 <?php abstract final class A { }
Chris@0 149 // Type in the partial parse could conceivably be any of 0, 16 or 32
Chris@0 150 -----
Chris@0 151 Syntax error, unexpected T_FINAL, expecting T_CLASS from 1:16 to 1:20
Chris@0 152 array(
Chris@0 153 0: Stmt_Class(
Chris@0 154 flags: MODIFIER_FINAL (32)
Chris@0 155 name: A
Chris@0 156 extends: null
Chris@0 157 implements: array(
Chris@0 158 )
Chris@0 159 stmts: array(
Chris@0 160 )
Chris@0 161 )
Chris@0 162 1: Stmt_Nop(
Chris@0 163 comments: array(
Chris@0 164 0: // Type in the partial parse could conceivably be any of 0, 16 or 32
Chris@0 165 )
Chris@0 166 )
Chris@0 167 )
Chris@0 168 -----
Chris@0 169 <?php class A { abstract $a; }
Chris@0 170 -----
Chris@0 171 Properties cannot be declared abstract from 1:17 to 1:24
Chris@0 172 array(
Chris@0 173 0: Stmt_Class(
Chris@0 174 flags: 0
Chris@0 175 name: A
Chris@0 176 extends: null
Chris@0 177 implements: array(
Chris@0 178 )
Chris@0 179 stmts: array(
Chris@0 180 0: Stmt_Property(
Chris@0 181 flags: MODIFIER_ABSTRACT (16)
Chris@0 182 props: array(
Chris@0 183 0: Stmt_PropertyProperty(
Chris@0 184 name: a
Chris@0 185 default: null
Chris@0 186 )
Chris@0 187 )
Chris@0 188 )
Chris@0 189 )
Chris@0 190 )
Chris@0 191 )
Chris@0 192 -----
Chris@0 193 <?php class A { final $a; }
Chris@0 194 -----
Chris@0 195 Properties cannot be declared final from 1:17 to 1:21
Chris@0 196 array(
Chris@0 197 0: Stmt_Class(
Chris@0 198 flags: 0
Chris@0 199 name: A
Chris@0 200 extends: null
Chris@0 201 implements: array(
Chris@0 202 )
Chris@0 203 stmts: array(
Chris@0 204 0: Stmt_Property(
Chris@0 205 flags: MODIFIER_FINAL (32)
Chris@0 206 props: array(
Chris@0 207 0: Stmt_PropertyProperty(
Chris@0 208 name: a
Chris@0 209 default: null
Chris@0 210 )
Chris@0 211 )
Chris@0 212 )
Chris@0 213 )
Chris@0 214 )
Chris@0 215 )