Skip to content

Commit a02039b

Browse files
committed
Merge branch 'master' into php8
2 parents ad46364 + 966a6c2 commit a02039b

File tree

8 files changed

+58
-63
lines changed

8 files changed

+58
-63
lines changed

.circleci/config.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Node CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ${{ matrix.os }}
9+
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest]
13+
node-version: [12.x, 14.x, 16.x]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
- name: npm install, test
22+
run: |
23+
npm install
24+
npm test
25+
env:
26+
CI: true

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

jest.config.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ const ENABLE_COVERAGE = !!process.env.CI || !!process.env.COVERAGE;
55
module.exports = {
66
collectCoverage: ENABLE_COVERAGE,
77
coverageDirectory: "coverage/",
8+
coverageThreshold: {
9+
global: {
10+
statements: 95.6,
11+
branches: 89.6,
12+
functions: 99,
13+
lines: 96.1,
14+
},
15+
},
816
projects: [
917
{
1018
displayName: "test",
1119
testEnvironment: "node",
1220
},
13-
//{
14-
// runner: "jest-runner-eslint",
15-
// displayName: "lint",
16-
// testMatch: ["<rootDir>/**/*.js"],
17-
// testPathIgnorePatterns: [
18-
// "<rootDir>/node_modules/",
19-
// "<rootDir>/coverage/",
20-
// ],
21-
//},
21+
{
22+
runner: "jest-runner-eslint",
23+
displayName: "lint",
24+
testMatch: ["<rootDir>/**/*.js"],
25+
testPathIgnorePatterns: [
26+
"<rootDir>/node_modules/",
27+
"<rootDir>/coverage/",
28+
],
29+
},
2230
],
2331
};

src/ast.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ AST.prototype.prepare = function (kind, docs, parser) {
458458
AST.prototype.checkNodes = function () {
459459
const errors = [];
460460
for (const k in AST.stack) {
461-
if (AST.stack.hasOwnProperty(k)) {
461+
if (Object.prototype.hasOwnProperty.call(AST.stack, k)) {
462462
errors.push(AST.stack[k]);
463463
}
464464
}

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ Engine.tokenGetAll = function (buffer, options) {
199199
/**
200200
* Extract tokens from the specified buffer.
201201
* > Note that the output tokens are *STRICLY* similar to PHP function `token_get_all`
202-
* @param {String} buffer
203-
* @return {String[]} - Each item can be a string or an array with following informations [token_name, text, line_number]
202+
* @param {string} buffer
203+
* @return {Array<string|string[]>} - Each item can be a string or an array with following informations [token_name, text, line_number]
204204
*/
205205
Engine.prototype.tokenGetAll = function (buffer) {
206206
this.lexer.mode_eval = false;
@@ -213,7 +213,7 @@ Engine.prototype.tokenGetAll = function (buffer) {
213213
const result = [];
214214
while (token != EOF) {
215215
let entry = this.lexer.yytext;
216-
if (names.hasOwnProperty(token)) {
216+
if (Object.prototype.hasOwnProperty.call(names, token)) {
217217
entry = [names[token], entry, this.lexer.yylloc.first_line];
218218
}
219219
result.push(entry);

src/parser.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,12 @@ Parser.prototype.lex = function () {
632632
this.token = this.lexer.lex() || this.EOF;
633633
if (this.token === this.EOF) return this;
634634
let entry = this.lexer.yytext;
635-
if (this.lexer.engine.tokens.values.hasOwnProperty(this.token)) {
635+
if (
636+
Object.prototype.hasOwnProperty.call(
637+
this.lexer.engine.tokens.values,
638+
this.token
639+
)
640+
) {
636641
entry = [
637642
this.lexer.engine.tokens.values[this.token],
638643
entry,
@@ -703,7 +708,7 @@ Parser.prototype.is = function (type) {
703708
require("./parser/variable.js"),
704709
].forEach(function (ext) {
705710
for (const k in ext) {
706-
if (Parser.prototype.hasOwnProperty(k)) {
711+
if (Object.prototype.hasOwnProperty.call(Parser.prototype, k)) {
707712
// @see https://github.com/glayzzle/php-parser/issues/234
708713
throw new Error("Function " + k + " is already defined - collision");
709714
}

types.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ declare module "php-parser" {
129129
*/
130130
class Class extends Declaration {
131131
extends: Identifier | null;
132-
implements: Identifier[];
132+
implements: Identifier[] | null;
133133
body: Declaration[];
134134
isAnonymous: boolean;
135135
isAbstract: boolean;
@@ -700,6 +700,8 @@ declare module "php-parser" {
700700
*/
701701
parseFlags(flags: (number | null)[]): void;
702702
properties: Property[];
703+
visibility: string|null;
704+
isStatic: bool;
703705
}
704706
/**
705707
* Defines a reference node
@@ -990,7 +992,7 @@ declare module "php-parser" {
990992
* > Note that the output tokens are *STRICLY* similar to PHP function `token_get_all`
991993
* @returns - Each item can be a string or an array with following informations [token_name, text, line_number]
992994
*/
993-
tokenGetAll(buffer: string): String[];
995+
tokenGetAll(buffer: string): (string | string[])[];
994996
lexer: Lexer;
995997
parser: Parser;
996998
ast: AST;

0 commit comments

Comments
 (0)