49
49
* SOFTWARE.
50
50
*/
51
51
final class ASTConverter {
52
+ // The release version of this class.
53
+ const ASTCONVERTER_VERSION = '0.1.0 ' ;
54
+
52
55
// The latest stable version of php-ast.
53
56
// For something > 50, update the library's release.
54
57
// For something < 40, there are no releases.
55
58
const AST_VERSION = 50 ;
56
59
// The versions that this supports
57
- const SUPPORTED_AST_VERSIONS = [40 , 50 ];
60
+ const SUPPORTED_AST_VERSIONS = [40 , 45 , 50 ];
58
61
59
62
/**
60
63
* @var int - A version in SUPPORTED_AST_VERSIONS
@@ -1893,13 +1896,13 @@ private static function phpParserDeclareListToAstDeclares(array $declares, int $
1893
1896
];
1894
1897
$ doc_comment = self ::extractPhpdocComment ($ declare ->getAttribute ('comments ' )) ?? $ first_doc_comment ;
1895
1898
$ first_doc_comment = null ;
1896
- if (self ::$ ast_version >= 50 ) {
1899
+ if (self ::$ ast_version >= 45 ) {
1897
1900
if (PHP_VERSION_ID >= 70100 ) {
1898
1901
$ children ['docComment ' ] = $ doc_comment ;
1899
1902
}
1900
1903
}
1901
1904
$ 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 )) {
1903
1906
if (PHP_VERSION_ID >= 70100 ) {
1904
1907
$ node ->docComment = $ doc_comment ;
1905
1908
}
@@ -2070,7 +2073,7 @@ private static function phpParserNameToString(PhpParser\Node\Name $name) : strin
2070
2073
* @return ast\Node
2071
2074
*/
2072
2075
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 ) {
2074
2077
if (is_string ($ doc_comment ) || array_key_exists ($ kind , self ::_NODES_WITH_NULL_DOC_COMMENT )) {
2075
2078
if ($ kind !== \ast \AST_CONST_ELEM || PHP_VERSION_ID >= 70100 ) {
2076
2079
$ children ['docComment ' ] = $ doc_comment ;
@@ -2096,15 +2099,15 @@ private static function newAstNode(int $kind, int $flags, array $children, int $
2096
2099
* @suppress PhanUndeclaredProperty
2097
2100
*/
2098
2101
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 ;
2104
2107
if ($ decl_id >= 0 && self ::$ ast_version >= 50 ) {
2105
- $ children45 ['__declId ' ] = $ decl_id ;
2108
+ $ children50 ['__declId ' ] = $ decl_id ;
2106
2109
}
2107
- $ node = new ast \Node ($ kind , $ flags , $ children45 , $ lineno );
2110
+ $ node = new ast \Node ($ kind , $ flags , $ children50 , $ lineno );
2108
2111
if (is_int ($ end_lineno )) {
2109
2112
$ node ->endLineno = $ end_lineno ;
2110
2113
}
0 commit comments