2727use PhpParser \Node \Stmt \UseUse ;
2828use PhpParser \NodeVisitorAbstract ;
2929use PhpParser \PrettyPrinter \Standard ;
30+ use PhpParser \Node \Scalar \LNumber ;
31+ use PhpParser \Node \Scalar \DNumber ;
32+ use PhpParser \Node \Scalar \MagicConst ;
3033
3134abstract class AbstractPhpStructVisitor extends NodeVisitorAbstract {
3235
@@ -122,9 +125,8 @@ protected function visitConstants(ClassConst $node) {
122125 }
123126
124127 protected function visitConstant (Const_ $ node , Doc $ doc = null ) {
125- $ const = new PhpConstant ($ node ->name , $ this ->getValue ($ node ));
126- $ const ->setValue ($ this ->getValue ($ node ->value ));
127-
128+ $ const = new PhpConstant ($ node ->name );
129+ $ this ->setDefault ($ const , $ node ->value );
128130 $ this ->parseMemberDocblock ($ const , $ doc );
129131
130132 $ this ->struct ->setConstant ($ const );
@@ -244,7 +246,7 @@ private function parseMemberDocblock($member, Doc $doc = null) {
244246 }
245247 }
246248
247- private function setDefault ($ obj , $ default ) {
249+ private function setDefault ($ obj , Node $ default ) {
248250 if ($ default instanceof String_) {
249251 $ obj ->setValue ($ this ->getValue ($ default ));
250252 } else {
@@ -268,9 +270,13 @@ private function getValue(Node $node) {
268270 return $ const ;
269271 }
270272
271- if ($ node instanceof String_) {
273+ if ($ node instanceof String_ || $ node instanceof LNumber || $ node instanceof DNumber ) {
272274 return $ node ->value ;
273275 }
276+
277+ if ($ node instanceof MagicConst) {
278+ return $ node ->getName ();
279+ }
274280 }
275281
276282 /**
0 commit comments