4949 * SOFTWARE.
5050 */
5151final class ASTConverter {
52+ // The release version of this class.
53+ const ASTCONVERTER_VERSION = '0.1.0 ' ;
54+
5255 // The latest stable version of php-ast.
5356 // For something > 50, update the library's release.
5457 // For something < 40, there are no releases.
5558 const AST_VERSION = 50 ;
5659 // The versions that this supports
57- const SUPPORTED_AST_VERSIONS = [40 , 50 ];
60+ const SUPPORTED_AST_VERSIONS = [40 , 45 , 50 ];
5861
5962 /**
6063 * @var int - A version in SUPPORTED_AST_VERSIONS
@@ -1893,13 +1896,13 @@ private static function phpParserDeclareListToAstDeclares(array $declares, int $
18931896 ];
18941897 $ doc_comment = self ::extractPhpdocComment ($ declare ->getAttribute ('comments ' )) ?? $ first_doc_comment ;
18951898 $ first_doc_comment = null ;
1896- if (self ::$ ast_version >= 50 ) {
1899+ if (self ::$ ast_version >= 45 ) {
18971900 if (PHP_VERSION_ID >= 70100 ) {
18981901 $ children ['docComment ' ] = $ doc_comment ;
18991902 }
19001903 }
19011904 $ node = new ast \Node (ast \AST_CONST_ELEM , 0 , $ children , $ declare ->getAttribute ('startLine ' ));
1902- if (self ::$ ast_version < 50 && is_string ($ doc_comment )) {
1905+ if (self ::$ ast_version < 45 && is_string ($ doc_comment )) {
19031906 if (PHP_VERSION_ID >= 70100 ) {
19041907 $ node ->docComment = $ doc_comment ;
19051908 }
@@ -2070,7 +2073,7 @@ private static function phpParserNameToString(PhpParser\Node\Name $name) : strin
20702073 * @return ast\Node
20712074 */
20722075 private static function newAstNode (int $ kind , int $ flags , array $ children , int $ lineno , string $ doc_comment = null ) : ast \Node {
2073- if (self ::$ ast_version >= 45 ) {
2076+ if (self ::$ ast_version >= 50 ) {
20742077 if (is_string ($ doc_comment ) || array_key_exists ($ kind , self ::_NODES_WITH_NULL_DOC_COMMENT )) {
20752078 if ($ kind !== \ast \AST_CONST_ELEM || PHP_VERSION_ID >= 70100 ) {
20762079 $ children ['docComment ' ] = $ doc_comment ;
@@ -2096,15 +2099,15 @@ private static function newAstNode(int $kind, int $flags, array $children, int $
20962099 * @suppress PhanUndeclaredProperty
20972100 */
20982101 private static function newAstDecl (int $ kind , int $ flags , array $ children , int $ lineno , string $ doc_comment = null , string $ name = null , int $ end_lineno = 0 , int $ decl_id = -1 ) : ast \Node {
2099- if (self ::$ ast_version >= 45 ) {
2100- $ children45 = [];
2101- $ children45 ['name ' ] = $ name ;
2102- $ children45 ['docComment ' ] = $ doc_comment ;
2103- $ children45 += $ children ;
2102+ if (self ::$ ast_version >= 50 ) {
2103+ $ children50 = [];
2104+ $ children50 ['name ' ] = $ name ;
2105+ $ children50 ['docComment ' ] = $ doc_comment ;
2106+ $ children50 += $ children ;
21042107 if ($ decl_id >= 0 && self ::$ ast_version >= 50 ) {
2105- $ children45 ['__declId ' ] = $ decl_id ;
2108+ $ children50 ['__declId ' ] = $ decl_id ;
21062109 }
2107- $ node = new ast \Node ($ kind , $ flags , $ children45 , $ lineno );
2110+ $ node = new ast \Node ($ kind , $ flags , $ children50 , $ lineno );
21082111 if (is_int ($ end_lineno )) {
21092112 $ node ->endLineno = $ end_lineno ;
21102113 }
0 commit comments