@@ -466,6 +466,17 @@ private static function _init_handle_map() : array {
466466 $ startLine
467467 );
468468 },
469+ 'PhpParser\Node\Scalar\Encapsed ' => function (PhpParser \Node \Scalar \Encapsed $ n , int $ startLine ) : \ast \Node {
470+ return astnode (
471+ \ast \AST_ENCAPS_LIST ,
472+ 0 ,
473+ array_map (function (PhpParser \Node $ n ) { return self ::_phpparser_node_to_ast_node ($ n ); }, $ n ->parts ),
474+ $ startLine
475+ );
476+ },
477+ 'PhpParser\Node\Scalar\EncapsedStringPart ' => function (PhpParser \Node \Scalar \EncapsedStringPart $ n , int $ startLine ) : string {
478+ return $ n ->value ;
479+ },
469480 'PhpParser\Node\Scalar\LNumber ' => function (PhpParser \Node \Scalar \LNumber $ n , int $ startLine ) : int {
470481 return (int )$ n ->value ;
471482 },
@@ -501,7 +512,7 @@ private static function _init_handle_map() : array {
501512 },
502513 'PhpParser\Node\Stmt\Catch_ ' => function (PhpParser \Node \Stmt \Catch_ $ n , int $ startLine ) : \ast \Node {
503514 return self ::_ast_stmt_catch (
504- self ::_phpparser_catch_types_to_ast_catch_types ($ n ->types , $ startLine ),
515+ self ::_phpparser_name_list_to_ast_name_list ($ n ->types , $ startLine ),
505516 $ n ->var ,
506517 self ::_phpparser_stmtlist_to_ast_node ($ n ->stmts , $ startLine ),
507518 $ startLine
@@ -663,6 +674,10 @@ private static function _init_handle_map() : array {
663674 $ startLine
664675 );
665676 },
677+ 'PhpParser\Node\Stmt\Nop ' => function (PhpParser \Node \Stmt \Nop $ n , int $ startLine ) : array {
678+ // `;;`
679+ return [];
680+ },
666681 'PhpParser\Node\Stmt\Property ' => function (PhpParser \Node \Stmt \Property $ n , int $ startLine ) : \ast \Node {
667682 return self ::_phpparser_property_to_ast_node ($ n , $ startLine );
668683 },
@@ -704,6 +719,36 @@ private static function _init_handle_map() : array {
704719 self ::_extract_phpdoc_comment ($ n ->getAttribute ('comments ' ))
705720 );
706721 },
722+ 'PhpParser\Node\Stmt\TraitUse ' => function (PhpParser \Node \Stmt \TraitUse $ n , int $ startLine ) : \ast \Node {
723+ if (\is_array ($ n ->adaptations ) && \count ($ n ->adaptations ) > 0 ) {
724+ $ adaptations_inner = array_map (function (PhpParser \Node \Stmt \TraitUseAdaptation $ n ) : \ast \Node {
725+ return self ::_phpparser_node_to_ast_node ($ n );
726+ }, $ n ->adaptations );
727+ $ adaptations = astnode (\ast \AST_TRAIT_ADAPTATIONS , 0 , $ adaptations_inner , $ adaptations_inner [0 ]->lineno ?: $ startLine );
728+ } else {
729+ $ adaptations = null ;
730+ }
731+ return astnode (
732+ \ast \AST_USE_TRAIT ,
733+ 0 ,
734+ [
735+ 'traits ' => self ::_phpparser_name_list_to_ast_name_list ($ n ->traits , $ startLine ),
736+ 'adaptations ' => $ adaptations ,
737+ ],
738+ $ startLine
739+ );
740+ },
741+ 'PhpParser\Node\Stmt\TraitUseAdaptation\Alias ' => function (PhpParser \Node \Stmt \TraitUseAdaptation \Alias $ n , int $ startLine ) : \ast \Node {
742+ $ old_class = $ n ->trait !== null ? self ::_phpparser_name_to_string ($ n ->trait ) : null ;
743+ // TODO: flags for visibility
744+ return astnode (\ast \AST_TRAIT_ALIAS , self ::_phpparser_visibility_to_ast_visibility ($ n ->newModifier ?? 0 ), [
745+ 'method ' => astnode (\ast \AST_METHOD_REFERENCE , 0 , [
746+ 'class ' => $ old_class ,
747+ 'method ' => $ n ->method ,
748+ ], $ startLine ),
749+ 'alias ' => $ n ->newName ,
750+ ], $ startLine );
751+ },
707752 'PhpParser\Node\Stmt\TryCatch ' => function (PhpParser \Node \Stmt \TryCatch $ n , int $ startLine ) : \ast \Node {
708753 if (!is_array ($ n ->catches )) {
709754 throw new \Error (sprintf ("Unsupported type %s \n%s " , get_class ($ n ), var_export ($ n ->catches , true )));
@@ -785,7 +830,7 @@ private static function _phpparser_catchlist_to_ast_catchlist(array $catches, in
785830 return $ node ;
786831 }
787832
788- private static function _phpparser_catch_types_to_ast_catch_types (array $ types , int $ line ) : \ast \Node {
833+ private static function _phpparser_name_list_to_ast_name_list (array $ types , int $ line ) : \ast \Node {
789834 $ astTypes = [];
790835 foreach ($ types as $ type ) {
791836 $ astTypes [] = self ::_phpparser_node_to_ast_node ($ type );
0 commit comments