How to use the php-parser function in php-parser

To help you get started, we’ve selected a few php-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sheabunge / code-snippets / js / php-lint.js View on Github external
lint() {
		const parser = new Parser({
			parser: {
				suppressErrors: true
			},
			ast: {
				withPositions: true
			}
		});

		try {
			let ast = parser.parseEval(this.code);

			if (ast.errors && ast.errors.length > 0) {
				for (let i = 0; i < ast.errors.length; i++) {
					this.annotate(ast.errors[i].message, ast.errors[i].loc);
				}
			}

php-parser

Parse PHP code from JS and returns its AST

BSD-3-Clause
Latest version published 11 months ago

Package Health Score

75 / 100
Full package analysis