@@ -73,6 +73,9 @@ public function extract(string $code): array
7373 // Wrap code in a dummy class if needed for parsing
7474 $ wrappedCode = "<?php \nclass Dummy { \n" . $ code . "\n} " ;
7575 $ ast = $ this ->parser ->parse ($ wrappedCode );
76+ if ($ ast === null ) {
77+ return [];
78+ }
7679
7780 $ traverser = new NodeTraverser ();
7881 $ traverser ->addVisitor ($ this );
@@ -144,8 +147,13 @@ protected function processMethodCall(MethodCall $methodCall): void
144147 ) {
145148 // Extract the column name and type expression
146149 if (count ($ methodCall ->args ) >= 2 ) {
147- $ columnArg = $ methodCall ->args [0 ]->value ;
148- $ typeArg = $ methodCall ->args [1 ]->value ;
150+ $ columnArgNode = $ methodCall ->args [0 ];
151+ $ typeArgNode = $ methodCall ->args [1 ];
152+ if (!$ columnArgNode instanceof Node \Arg || !$ typeArgNode instanceof Node \Arg) {
153+ return ;
154+ }
155+ $ columnArg = $ columnArgNode ->value ;
156+ $ typeArg = $ typeArgNode ->value ;
149157
150158 // Get column name
151159 $ columnName = $ this ->getStringValue ($ columnArg );
@@ -199,7 +207,11 @@ protected function getTypeExpression(Node $node): ?string
199207 if ($ className === 'EnumType ' || str_ends_with ($ className , '\\EnumType ' )) {
200208 if ($ methodName === 'from ' && count ($ node ->args ) > 0 ) {
201209 // Extract the enum class name
202- $ arg = $ node ->args [0 ]->value ;
210+ $ argNode = $ node ->args [0 ];
211+ if (!$ argNode instanceof Node \Arg) {
212+ return null ;
213+ }
214+ $ arg = $ argNode ->value ;
203215 if ($ arg instanceof Node \Expr \ClassConstFetch) {
204216 if (
205217 $ arg ->class instanceof Node \Name &&
0 commit comments