Skip to content

Instantly share code, notes, and snippets.

@ichiriac
Created January 29, 2017 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ichiriac/9b622420f3af9da370b2cb0706b19d34 to your computer and use it in GitHub Desktop.
Save ichiriac/9b622420f3af9da370b2cb0706b19d34 to your computer and use it in GitHub Desktop.
Scan a path with PHP files
var fs = require('fs');
// https://www.npmjs.com/package/php-parser
var parser = require('php-parser');
// https://www.npmjs.com/package/glob
var glob = require('glob');
glob("**/*.php", options, function (er, files) {
for(var i = 0; i < files.length; i++) {
var file = files[i];
try {
var AST = parser.parseCode(
fs.readFileSync(file, { encoding: 'utf8' }), file
);
scanNode(AST, file);
} catch(e) {
console.error(e.stack);
}
}
});
function scanNode(node, file) {
// here do the magic stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment