php-parser
Advanced tools
Comparing version 3.1.5 to 3.2.0
@@ -5,3 +5,3 @@ /*! | ||
* Parse PHP code from JS and returns its AST | ||
* Build: 966fc2556208046b400c - 6/7/2023 | ||
* Build: bca436a86711b8dbc856 - 11/6/2024 | ||
* Copyright (C) 2021 Glayzzle (BSD-3-Clause) | ||
@@ -8,0 +8,0 @@ * @authors https://github.com/glayzzle/php-parser/graphs/contributors |
{ | ||
"name": "php-parser", | ||
"version": "3.1.5", | ||
"version": "3.2.0", | ||
"description": "Parse PHP code from JS and returns its AST", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -22,3 +22,5 @@ /** | ||
* @property {string} visibility | ||
* @property {bool} final | ||
* @property {boolean} final | ||
* @property {boolean} nullable | ||
* @property {TypeReference|IntersectionType|UnionType|null} type | ||
* @property {AttrGroup[]} attrGroups | ||
@@ -28,5 +30,16 @@ */ | ||
KIND, | ||
function ClassConstant(kind, constants, flags, attrGroups, docs, location) { | ||
function ClassConstant( | ||
kind, | ||
constants, | ||
flags, | ||
nullable, | ||
type, | ||
attrGroups, | ||
docs, | ||
location | ||
) { | ||
ConstantStatement.apply(this, [kind || KIND, constants, docs, location]); | ||
this.parseFlags(flags); | ||
this.nullable = nullable; | ||
this.type = type; | ||
this.attrGroups = attrGroups; | ||
@@ -33,0 +46,0 @@ } |
@@ -241,3 +241,4 @@ /** | ||
) { | ||
this.consume(2); | ||
this.consume(1); | ||
this.begin("ST_LOOKING_FOR_PROPERTY").input(); | ||
return this.tok.T_NULLSAFE_OBJECT_OPERATOR; | ||
@@ -244,0 +245,0 @@ } |
@@ -229,3 +229,3 @@ /** | ||
* ```ebnf | ||
* constant_list ::= T_CONST (constant_declaration ',')* constant_declaration | ||
* constant_list ::= T_CONST [type] (constant_declaration ',')* constant_declaration | ||
* ``` | ||
@@ -237,2 +237,6 @@ */ | ||
} | ||
const [nullable, type] = | ||
this.version >= 830 ? this.read_optional_type() : [false, null]; | ||
const result = this.node("classconstant"); | ||
@@ -271,3 +275,3 @@ const items = this.read_list( | ||
return result(null, items, flags, attrs || []); | ||
return result(null, items, flags, nullable, type, attrs || []); | ||
}, | ||
@@ -314,7 +318,7 @@ /* | ||
if (asInterface) { | ||
if (idx == 0 && val == 2) { | ||
if (idx === 0 && val === 2) { | ||
// an interface can't be private | ||
this.expect([this.tok.T_PUBLIC, this.tok.T_PROTECTED]); | ||
val = -1; | ||
} else if (idx == 2 && val == 1) { | ||
} else if (idx === 2 && val === 1) { | ||
// an interface cant be abstract | ||
@@ -334,4 +338,4 @@ this.error(); | ||
if (result[1] == -1) result[1] = 0; | ||
if (result[2] == -1) result[2] = 0; | ||
if (result[1] === -1) result[1] = 0; | ||
if (result[2] === -1) result[2] = 0; | ||
return result; | ||
@@ -364,5 +368,4 @@ }, | ||
read_optional_type: function () { | ||
let nullable = false; | ||
if (this.token === "?") { | ||
nullable = true; | ||
const nullable = this.token === "?"; | ||
if (nullable) { | ||
this.next(); | ||
@@ -445,3 +448,3 @@ } | ||
// check constant | ||
if (this.token == this.tok.T_CONST) { | ||
if (this.token === this.tok.T_CONST) { | ||
const constants = this.read_constant_list(flags, attrs); | ||
@@ -448,0 +451,0 @@ if (this.expect(";")) { |
@@ -323,3 +323,3 @@ /** | ||
}, | ||
read_types() { | ||
read_types: function () { | ||
const MODE_UNSET = "unset"; | ||
@@ -378,3 +378,3 @@ const MODE_UNION = "union"; | ||
}, | ||
read_promoted() { | ||
read_promoted: function () { | ||
const MODIFIER_PUBLIC = 1; | ||
@@ -381,0 +381,0 @@ const MODIFIER_PROTECTED = 2; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
808483
22595