Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
run: |
yarn build-types
[ $(git diff types.d.ts | wc -l) -gt 0 ] && echo 'Diff exists in types.d.ts. Please change jsdoc.' && exit 1
tsc --noEmit types.d.ts
tsc --noEmit types.d.ts --skipLibCheck
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
"devDependencies": {
"@babel/core": "^7.27.4",
"@babel/preset-env": "^7.27.2",
"@eslint/js": "^9.29.0",
"@eslint/js": "^10.0.1",
"@types/node": "^25.2.3",
"babel-loader": "^10.0.0",
"benchmark": "^2.1.4",
"coveralls": "^3.0.3",
"eslint": "^9.29.0",
"eslint": "^10.0.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-prettier": "^5.5.0",
Expand Down
3 changes: 1 addition & 2 deletions src/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ AST.prototype.prepare = function (kind, docs, parser) {
const self = this;
// returns the node
const result = function () {
let location = null;
const args = Array.prototype.slice.call(arguments);
args.push(docs);
if (self.withPositions || self.withSource) {
Expand All @@ -373,7 +372,7 @@ AST.prototype.prepare = function (kind, docs, parser) {
src = parser.lexer._input.substring(start.offset, parser.prev[2]);
}
// if with source, need location on swapLocations function
location = new Location(
const location = new Location(
src,
start,
new Position(parser.prev[0], parser.prev[1], parser.prev[2]),
Expand Down
4 changes: 2 additions & 2 deletions src/lexer/attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module.exports = {
attributeIndex: 0,
attributeListDepth: {},
matchST_ATTRIBUTE() {
let ch = this.input();
const ch = this.input();
if (this.is_WHITESPACE()) {
do {
ch = this.input();
this.input();
} while (this.is_WHITESPACE());
this.unput(1);
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/parser/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
* ```
*/
read_array() {
let expect = null;
let expect;
let shortForm = false;
const result = this.node("array");

Expand Down Expand Up @@ -74,7 +74,7 @@ module.exports = {
const entry = this.node("entry");

let key = null;
let value = null;
let value;
let byRef = false;
let unpack = false;

Expand Down
6 changes: 2 additions & 4 deletions src/parser/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ module.exports = {
* ```
*/
read_interface_body() {
let result = [],
attrs = [];
let result = [];
let attrs;

while (this.token !== this.EOF && this.token !== "}") {
if (this.token === this.tok.T_COMMENT) {
Expand All @@ -458,7 +458,6 @@ module.exports = {
this.next();
}
result = result.concat(constants);
attrs = [];
} else if (this.token === this.tok.T_FUNCTION) {
// reads a function
const method = this.read_function_declaration(
Expand All @@ -472,7 +471,6 @@ module.exports = {
if (this.expect(";")) {
this.next();
}
attrs = [];
} else {
// raise an error
this.error([this.tok.T_CONST, this.tok.T_FUNCTION]);
Expand Down
6 changes: 2 additions & 4 deletions src/parser/expr.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,11 @@ module.exports = {
if (this.version < 800) {
this.raiseError("Match statements are not allowed before PHP 8");
}
let cond = null;
let arms = [];
if (this.expect("(")) this.next();
cond = this.read_expr();
const cond = this.read_expr();
if (this.expect(")")) this.next();
if (this.expect("{")) this.next();
arms = this.read_match_arms();
const arms = this.read_match_arms();
if (this.expect("}")) this.next();
return node(cond, arms);
},
Expand Down
3 changes: 1 addition & 2 deletions src/parser/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ module.exports = {
const node = this.node("parameter");
let parameterName = null;
let value = null;
let types = null;
let nullable = false;
let readonly = false;
let attrs = [];
Expand Down Expand Up @@ -290,7 +289,7 @@ module.exports = {
this.next();
nullable = true;
}
types = this.read_types();
const types = this.read_types();
if (nullable && !types) {
this.raiseError(
"Expecting a type definition combined with nullable operator",
Expand Down
2 changes: 1 addition & 1 deletion src/parser/if.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
read_if() {
const result = this.node("if");
const test = this.next().read_if_expr();
let body = null;
let body;
let alternate = null;
let shortForm = false;

Expand Down
15 changes: 6 additions & 9 deletions src/parser/loops.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ module.exports = {
read_while() {
const result = this.node("while");
this.expect(this.tok.T_WHILE) && this.next();
let test = null;
let body = null;
let body;
let shortForm = false;
if (this.expect("(")) this.next();
test = this.read_expr();
const test = this.read_expr();
if (this.expect(")")) this.next();
if (this.token === ":") {
shortForm = true;
Expand All @@ -43,8 +42,7 @@ module.exports = {
const result = this.node("do");
this.expect(this.tok.T_DO) && this.next();
let test = null;
let body = null;
body = this.read_statement();
const body = this.read_statement();
if (this.expect(this.tok.T_WHILE)) {
if (this.next().expect("(")) this.next();
test = this.read_expr();
Expand All @@ -69,7 +67,7 @@ module.exports = {
let init = [];
let test = [];
let increment = [];
let body = null;
let body;
let shortForm = false;
if (this.expect("(")) this.next();
if (this.token !== ";") {
Expand Down Expand Up @@ -109,13 +107,12 @@ module.exports = {
read_foreach() {
const result = this.node("foreach");
this.expect(this.tok.T_FOREACH) && this.next();
let source = null;
let key = null;
let value = null;
let body = null;
let body;
let shortForm = false;
if (this.expect("(")) this.next();
source = this.read_expr();
const source = this.read_expr();
if (this.expect(this.tok.T_AS)) {
this.next();
value = this.read_foreach_variable();
Expand Down
3 changes: 1 addition & 2 deletions src/parser/scalar.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ module.exports = {
curly = true;
// dynamic variable name
// https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1239
name = null;
if (this.next().token === this.tok.T_STRING_VARNAME) {
name = this.node("variable");
const varName = this.text();
Expand Down Expand Up @@ -433,7 +432,7 @@ module.exports = {
this.next();
const start = this.lexer.yylloc.prev_offset - (isBinary ? 1 : 0);
const value = [];
let type = null;
let type;

if (expect === "`") {
type = this.ast.encapsed.TYPE_SHELL;
Expand Down
4 changes: 2 additions & 2 deletions src/parser/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ module.exports = {
},

read_what(is_static_lookup = false) {
let what = null;
let name = null;
let what;
let name;
switch (this.next().token) {
case this.tok.T_STRING:
what = this.node("identifier");
Expand Down
Loading