├── CFG ├── CFG.php ├── CFGNode.php ├── CFGNodeCond.php ├── CFGNodeLoopHeader.php ├── CFGNodeStmt.php ├── FileCFGInfo.php ├── FunctionSignature.php ├── FunctionSignatureMap.php ├── FunctionSignatureMap.php~ └── StmtProcessing.php ├── CallGraph ├── CallGraph.php └── CallGraphNode.php ├── PHP-Parser-master ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── UPGRADE-1.0.md ├── bin │ └── php-parse.php ├── composer.json ├── doc │ ├── 0_Introduction.markdown │ ├── 1_Installation.markdown │ ├── 2_Usage_of_basic_components.markdown │ ├── 3_Other_node_tree_representations.markdown │ ├── 4_Code_generation.markdown │ └── component │ │ └── Lexer.markdown ├── grammar │ ├── README.md │ ├── analyze.php │ ├── kmyacc.php.parser │ ├── rebuildParser.php │ └── zend_language_parser.phpy ├── lib │ ├── PhpParser │ │ ├── Autoloader.php │ │ ├── Builder.php │ │ ├── Builder │ │ │ ├── Class_.php │ │ │ ├── Declaration.php │ │ │ ├── FunctionLike.php │ │ │ ├── Function_.php │ │ │ ├── Interface_.php │ │ │ ├── Method.php │ │ │ ├── Namespace_.php │ │ │ ├── Param.php │ │ │ ├── Property.php │ │ │ ├── Trait_.php │ │ │ └── Use_.php │ │ ├── BuilderAbstract.php │ │ ├── BuilderFactory.php │ │ ├── Comment.php │ │ ├── Comment │ │ │ └── Doc.php │ │ ├── Error.php │ │ ├── Lexer.php │ │ ├── Lexer │ │ │ └── Emulative.php │ │ ├── Node.php │ │ ├── Node │ │ │ ├── Arg.php │ │ │ ├── Const_.php │ │ │ ├── Expr.php │ │ │ ├── Expr │ │ │ │ ├── ArrayDimFetch.php │ │ │ │ ├── ArrayItem.php │ │ │ │ ├── Array_.php │ │ │ │ ├── Assign.php │ │ │ │ ├── AssignOp.php │ │ │ │ ├── AssignOp │ │ │ │ │ ├── BitwiseAnd.php │ │ │ │ │ ├── BitwiseOr.php │ │ │ │ │ ├── BitwiseXor.php │ │ │ │ │ ├── Concat.php │ │ │ │ │ ├── Div.php │ │ │ │ │ ├── Minus.php │ │ │ │ │ ├── Mod.php │ │ │ │ │ ├── Mul.php │ │ │ │ │ ├── Plus.php │ │ │ │ │ ├── Pow.php │ │ │ │ │ ├── ShiftLeft.php │ │ │ │ │ └── ShiftRight.php │ │ │ │ ├── AssignRef.php │ │ │ │ ├── BinaryOp.php │ │ │ │ ├── BinaryOp │ │ │ │ │ ├── BitwiseAnd.php │ │ │ │ │ ├── BitwiseOr.php │ │ │ │ │ ├── BitwiseXor.php │ │ │ │ │ ├── BooleanAnd.php │ │ │ │ │ ├── BooleanOr.php │ │ │ │ │ ├── Coalesce.php │ │ │ │ │ ├── Concat.php │ │ │ │ │ ├── Div.php │ │ │ │ │ ├── Equal.php │ │ │ │ │ ├── Greater.php │ │ │ │ │ ├── GreaterOrEqual.php │ │ │ │ │ ├── Identical.php │ │ │ │ │ ├── LogicalAnd.php │ │ │ │ │ ├── LogicalOr.php │ │ │ │ │ ├── LogicalXor.php │ │ │ │ │ ├── Minus.php │ │ │ │ │ ├── Mod.php │ │ │ │ │ ├── Mul.php │ │ │ │ │ ├── NotEqual.php │ │ │ │ │ ├── NotIdentical.php │ │ │ │ │ ├── Plus.php │ │ │ │ │ ├── Pow.php │ │ │ │ │ ├── ShiftLeft.php │ │ │ │ │ ├── ShiftRight.php │ │ │ │ │ ├── Smaller.php │ │ │ │ │ ├── SmallerOrEqual.php │ │ │ │ │ └── Spaceship.php │ │ │ │ ├── BitwiseNot.php │ │ │ │ ├── BooleanNot.php │ │ │ │ ├── Cast.php │ │ │ │ ├── Cast │ │ │ │ │ ├── Array_.php │ │ │ │ │ ├── Bool_.php │ │ │ │ │ ├── Double.php │ │ │ │ │ ├── Int_.php │ │ │ │ │ ├── Object_.php │ │ │ │ │ ├── String_.php │ │ │ │ │ └── Unset_.php │ │ │ │ ├── ClassConstFetch.php │ │ │ │ ├── Clone_.php │ │ │ │ ├── Closure.php │ │ │ │ ├── ClosureUse.php │ │ │ │ ├── ConstFetch.php │ │ │ │ ├── Empty_.php │ │ │ │ ├── ErrorSuppress.php │ │ │ │ ├── Eval_.php │ │ │ │ ├── Exit_.php │ │ │ │ ├── FuncCall.php │ │ │ │ ├── Include_.php │ │ │ │ ├── Instanceof_.php │ │ │ │ ├── Isset_.php │ │ │ │ ├── List_.php │ │ │ │ ├── MethodCall.php │ │ │ │ ├── New_.php │ │ │ │ ├── PostDec.php │ │ │ │ ├── PostInc.php │ │ │ │ ├── PreDec.php │ │ │ │ ├── PreInc.php │ │ │ │ ├── Print_.php │ │ │ │ ├── PropertyFetch.php │ │ │ │ ├── ShellExec.php │ │ │ │ ├── StaticCall.php │ │ │ │ ├── StaticPropertyFetch.php │ │ │ │ ├── Ternary.php │ │ │ │ ├── UnaryMinus.php │ │ │ │ ├── UnaryPlus.php │ │ │ │ ├── Variable.php │ │ │ │ └── Yield_.php │ │ │ ├── Name.php │ │ │ ├── Name │ │ │ │ ├── FullyQualified.php │ │ │ │ └── Relative.php │ │ │ ├── Param.php │ │ │ ├── Scalar.php │ │ │ ├── Scalar │ │ │ │ ├── DNumber.php │ │ │ │ ├── Encapsed.php │ │ │ │ ├── LNumber.php │ │ │ │ ├── MagicConst.php │ │ │ │ ├── MagicConst │ │ │ │ │ ├── Class_.php │ │ │ │ │ ├── Dir.php │ │ │ │ │ ├── File.php │ │ │ │ │ ├── Function_.php │ │ │ │ │ ├── Line.php │ │ │ │ │ ├── Method.php │ │ │ │ │ ├── Namespace_.php │ │ │ │ │ └── Trait_.php │ │ │ │ └── String_.php │ │ │ ├── Stmt.php │ │ │ └── Stmt │ │ │ │ ├── Break_.php │ │ │ │ ├── Case_.php │ │ │ │ ├── Catch_.php │ │ │ │ ├── ClassConst.php │ │ │ │ ├── ClassLike.php │ │ │ │ ├── ClassMethod.php │ │ │ │ ├── Class_.php │ │ │ │ ├── Const_.php │ │ │ │ ├── Continue_.php │ │ │ │ ├── DeclareDeclare.php │ │ │ │ ├── Declare_.php │ │ │ │ ├── Do_.php │ │ │ │ ├── Echo_.php │ │ │ │ ├── ElseIf_.php │ │ │ │ ├── Else_.php │ │ │ │ ├── For_.php │ │ │ │ ├── Foreach_.php │ │ │ │ ├── Function_.php │ │ │ │ ├── Global_.php │ │ │ │ ├── Goto_.php │ │ │ │ ├── HaltCompiler.php │ │ │ │ ├── If_.php │ │ │ │ ├── InlineHTML.php │ │ │ │ ├── Interface_.php │ │ │ │ ├── Label.php │ │ │ │ ├── Namespace_.php │ │ │ │ ├── Property.php │ │ │ │ ├── PropertyProperty.php │ │ │ │ ├── Return_.php │ │ │ │ ├── StaticVar.php │ │ │ │ ├── Static_.php │ │ │ │ ├── Switch_.php │ │ │ │ ├── Throw_.php │ │ │ │ ├── TraitUse.php │ │ │ │ ├── TraitUseAdaptation.php │ │ │ │ ├── TraitUseAdaptation │ │ │ │ ├── Alias.php │ │ │ │ └── Precedence.php │ │ │ │ ├── Trait_.php │ │ │ │ ├── TryCatch.php │ │ │ │ ├── Unset_.php │ │ │ │ ├── UseUse.php │ │ │ │ ├── Use_.php │ │ │ │ └── While_.php │ │ ├── NodeAbstract.php │ │ ├── NodeDumper.php │ │ ├── NodeTraverser.php │ │ ├── NodeTraverserInterface.php │ │ ├── NodeVisitor.php │ │ ├── NodeVisitor │ │ │ └── NameResolver.php │ │ ├── NodeVisitorAbstract.php │ │ ├── Parser.php │ │ ├── ParserAbstract.php │ │ ├── PrettyPrinter │ │ │ └── Standard.php │ │ ├── PrettyPrinterAbstract.php │ │ ├── Serializer.php │ │ ├── Serializer │ │ │ └── XML.php │ │ ├── Unserializer.php │ │ └── Unserializer │ │ │ └── XML.php │ └── bootstrap.php ├── phpunit.xml.dist ├── test │ ├── PhpParser │ │ ├── AutoloaderTest.php │ │ ├── Builder │ │ │ ├── ClassTest.php │ │ │ ├── FunctionTest.php │ │ │ ├── InterfaceTest.php │ │ │ ├── MethodTest.php │ │ │ ├── NamespaceTest.php │ │ │ ├── ParamTest.php │ │ │ ├── PropertyTest.php │ │ │ ├── TraitTest.php │ │ │ └── UseTest.php │ │ ├── BuilderFactoryTest.php │ │ ├── CodeTestAbstract.php │ │ ├── CommentTest.php │ │ ├── ErrorTest.php │ │ ├── Lexer │ │ │ └── EmulativeTest.php │ │ ├── LexerTest.php │ │ ├── Node │ │ │ ├── NameTest.php │ │ │ ├── Scalar │ │ │ │ ├── MagicConstTest.php │ │ │ │ └── StringTest.php │ │ │ └── Stmt │ │ │ │ ├── ClassMethodTest.php │ │ │ │ ├── ClassTest.php │ │ │ │ ├── InterfaceTest.php │ │ │ │ └── PropertyTest.php │ │ ├── NodeAbstractTest.php │ │ ├── NodeDumperTest.php │ │ ├── NodeTraverserTest.php │ │ ├── NodeVisitor │ │ │ └── NameResolverTest.php │ │ ├── ParserTest.php │ │ ├── PrettyPrinterTest.php │ │ ├── Serializer │ │ │ └── XMLTest.php │ │ └── Unserializer │ │ │ └── XMLTest.php │ └── code │ │ ├── parser │ │ ├── expr │ │ │ ├── arrayDef.test │ │ │ ├── assign.test │ │ │ ├── cast.test │ │ │ ├── clone.test │ │ │ ├── closure.test │ │ │ ├── comparison.test │ │ │ ├── constant_expr.test │ │ │ ├── errorSuppress.test │ │ │ ├── exit.test │ │ │ ├── fetchAndCall │ │ │ │ ├── args.test │ │ │ │ ├── constFetch.test │ │ │ │ ├── constantDeref.test │ │ │ │ ├── funcCall.test │ │ │ │ ├── newDeref.test │ │ │ │ ├── objectAccess.test │ │ │ │ ├── simpleArrayAccess.test │ │ │ │ ├── staticCall.test │ │ │ │ └── staticPropertyFetch.test │ │ │ ├── includeAndEval.test │ │ │ ├── issetAndEmpty.test │ │ │ ├── logic.test │ │ │ ├── math.test │ │ │ ├── new.test │ │ │ ├── newWithoutClass.test-fail │ │ │ ├── print.test │ │ │ ├── shellExec.test │ │ │ ├── ternaryAndCoalesce.test │ │ │ └── variable.test │ │ ├── scalar │ │ │ ├── constantString.test │ │ │ ├── docString.test │ │ │ ├── encapsedString.test │ │ │ ├── float.test │ │ │ ├── int.test │ │ │ └── magicConst.test │ │ └── stmt │ │ │ ├── blocklessStatement.test │ │ │ ├── class │ │ │ ├── abstract.test │ │ │ ├── conditional.test │ │ │ ├── final.test │ │ │ ├── implicitPublic.test │ │ │ ├── interface.test │ │ │ ├── modifier.test-fail │ │ │ ├── name.test-fail │ │ │ ├── php4Style.test │ │ │ ├── simple.test │ │ │ ├── staticMethod.test-fail │ │ │ └── trait.test │ │ │ ├── const.test │ │ │ ├── controlFlow.test │ │ │ ├── declare.test │ │ │ ├── echo.test │ │ │ ├── function │ │ │ ├── byRef.test │ │ │ ├── conditional.test │ │ │ ├── defaultValues.test │ │ │ ├── generator.test │ │ │ ├── returnTypes.test │ │ │ ├── specialVars.test │ │ │ ├── typeHints.test │ │ │ ├── variadic.test │ │ │ └── variadic.test-fail │ │ │ ├── haltCompiler.test │ │ │ ├── haltCompilerInvalidSyntax.test-fail │ │ │ ├── haltCompilerOutermostScope.test-fail │ │ │ ├── hashbang.test │ │ │ ├── if.test │ │ │ ├── inlineHTML.test │ │ │ ├── loop │ │ │ ├── do.test │ │ │ ├── for.test │ │ │ ├── foreach.test │ │ │ └── while.test │ │ │ ├── namespace │ │ │ ├── alias.test │ │ │ ├── braced.test │ │ │ ├── mix.test-fail │ │ │ ├── name.test │ │ │ ├── name.test-fail │ │ │ ├── nested.test-fail │ │ │ ├── notBraced.test │ │ │ ├── outsideStmt.test │ │ │ └── outsideStmt.test-fail │ │ │ ├── switch.test │ │ │ ├── tryCatch.test │ │ │ ├── tryCatch.test-fail │ │ │ └── unset.test │ │ └── prettyPrinter │ │ ├── alias.test │ │ ├── call.test │ │ ├── class.test │ │ ├── closure.test │ │ ├── comments.test │ │ ├── function_signatures.test │ │ ├── include.test │ │ ├── inlineHTMLandPHPtest.file-test │ │ ├── list.test │ │ ├── literals.test │ │ ├── namespaces.test │ │ ├── numbers.test │ │ ├── onlyInlineHTML.file-test │ │ ├── onlyPHP.file-test │ │ ├── operators.test │ │ ├── parentheses.test │ │ ├── switch.test │ │ ├── traitUse.test │ │ └── variables.test └── test_old │ └── run.php ├── README.md ├── TaintAnalysis ├── CFGTaintMap.php ├── FileTaintMap.php ├── TaintAnalysis.php ├── TaintMap.php ├── TaintSource.php └── TaintedVariables.php ├── run.script └── taint_analysis_main.php /CFG/CFGNode.php: -------------------------------------------------------------------------------- 1 | successors = array(); 16 | $this->parents = array(); 17 | } 18 | 19 | public function isCFGNodeStmt($cfg_node) { 20 | 21 | return ($cfg_node instanceof CFGNodeStmt); 22 | } 23 | 24 | public function isCFGNodeCond($cfg_node) { 25 | 26 | return ($cfg_node instanceof CFGNodeCond); 27 | } 28 | 29 | public function isCFGNodeLoopHeader($cfg_node) { 30 | 31 | return ($cfg_node instanceof CFGNodeLoopHeader); 32 | } 33 | 34 | public function getSuccessors() { 35 | return $this->successors; 36 | } 37 | 38 | public function getParents() { 39 | return $this->parents; 40 | } 41 | 42 | // Printing function for the node. 43 | public function printCFGNode() { 44 | 45 | print "Generic CFG Node.\n"; 46 | } 47 | 48 | } 49 | ?> -------------------------------------------------------------------------------- /CFG/CFGNodeCond.php: -------------------------------------------------------------------------------- 1 | successors[0]; 22 | } 23 | 24 | // The false successor of a conditional node is the second successor. 25 | public function getFalseSuccessor() { 26 | 27 | return $this->successors[1]; 28 | } 29 | 30 | // Printout function. 31 | public function printCFGNode() { 32 | 33 | if ($this->expr) { 34 | 35 | print "[Conditional Node] : "; 36 | printExpr($this->expr); 37 | } 38 | else { 39 | 40 | print "[Conditional Dummy Node]\n"; 41 | } 42 | } 43 | 44 | } 45 | ?> -------------------------------------------------------------------------------- /CFG/CFGNodeStmt.php: -------------------------------------------------------------------------------- 1 | stmt = NULL; 20 | 21 | $this->back_edge = FALSE; 22 | } 23 | 24 | public function getStmt() { 25 | return $this->stmt; 26 | } 27 | 28 | // Printout function. 29 | public function printCFGNode() { 30 | 31 | if ($this->stmt) { 32 | 33 | print "[Stmt Node] : "; 34 | printStmts(array($this->stmt)); 35 | } 36 | else { 37 | 38 | print "[Dummy Node]\n"; 39 | } 40 | } 41 | 42 | } 43 | ?> -------------------------------------------------------------------------------- /CFG/FileCFGInfo.php: -------------------------------------------------------------------------------- 1 | mainCFG = $mainCFG; 16 | $this->functionCFGs = $functionCFGs; 17 | $this->functionRepresentations = $functionRepresentations; 18 | $this->className = $className; 19 | $this->fileName = $fileName; 20 | } 21 | 22 | public function getMainCFG() { 23 | return $this->mainCFG; 24 | } 25 | 26 | public function getFunctionCFGs() { 27 | return $this->functionCFGs; 28 | } 29 | 30 | public function getFunctionRepresentations() { 31 | return $this->functionRepresentations; 32 | } 33 | 34 | public function getClassName() { 35 | return $this->className; 36 | } 37 | 38 | public function getFileName() { 39 | return $this->fileName; 40 | } 41 | 42 | public function getCFG($functionSignature) { 43 | 44 | if($functionSignature->isMain()) { 45 | return $this->mainCFG; 46 | } else { 47 | return $this->functionCFGs[$functionSignature->getFunctionName()]; 48 | } 49 | } 50 | } 51 | 52 | ?> -------------------------------------------------------------------------------- /CFG/FunctionSignature.php: -------------------------------------------------------------------------------- 1 | FileName = $fileName; 19 | $this->ClassName = $className; 20 | $this->FunctionName = $functionName; 21 | } 22 | 23 | public function getFileName() { 24 | return $this->FileName; 25 | } 26 | 27 | public function getClassName() { 28 | return $this->ClassName; 29 | } 30 | 31 | public function getFunctionName() { 32 | return $this->FunctionName; 33 | } 34 | 35 | public function isMain() { 36 | return strcmp($this->FunctionName, "") == 0; 37 | } 38 | 39 | public function toString() { 40 | return $this->FileName . "," . $this->ClassName . "," . $this->FunctionName; 41 | } 42 | 43 | public function printFunctionSignature() { 44 | print "(" . $this->getFileName() . ", " . $this->getClassName() . ", " . $this->getFunctionName() . ")" . "\n"; 45 | } 46 | } 47 | ?> -------------------------------------------------------------------------------- /CFG/FunctionSignatureMap.php: -------------------------------------------------------------------------------- 1 | map[(string)$functionName]; 13 | } 14 | 15 | public function getFunctionNames() { 16 | return array_keys($this->map); 17 | } 18 | 19 | public function contains($functionName) { 20 | return isset($this->map[(string)$functionName]); 21 | } 22 | 23 | public function add($functionSignature) { 24 | if(!$this->map->contains($functionSignature->getFunctionName())) { 25 | $this->map[$functionSignature->getFunctionName()] = array(); 26 | } 27 | $this->map[$functionSignature->getFunctionName()][] = $functionSignature; 28 | } 29 | 30 | public function addAll($functionSignatures) { 31 | foreach($functionSignatures as $name => $signature) { 32 | $this->add($signature); 33 | } 34 | } 35 | 36 | 37 | public function printFunctionSignatureMap() { 38 | foreach($this->map as $functionName => $functionSignatures) { 39 | print "[" . $functionName . "]" . "\n"; 40 | foreach($functionSignatures as $functionSignature) { 41 | $functionSignature->printFunctionSignature(); 42 | } 43 | } 44 | } 45 | } 46 | ?> -------------------------------------------------------------------------------- /CFG/FunctionSignatureMap.php~: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CFG/StmtProcessing.php: -------------------------------------------------------------------------------- 1 | var; 12 | return $var->name; 13 | } 14 | 15 | // Prints a sequence of statements with a pretty printer. 16 | 17 | function printStmts($stmts) { 18 | $prettyPrinter = new PhpParser\PrettyPrinter\Standard; 19 | $code = $prettyPrinter->prettyPrint($stmts); 20 | print $code."\n"; 21 | } 22 | 23 | // Prints an expression with a pretty printer. 24 | 25 | function printExpr($expr) { 26 | $prettyPrinter = new PhpParser\PrettyPrinter\Standard; 27 | $code = $prettyPrinter->prettyPrintExpr($expr); 28 | print $code."\n"; 29 | } 30 | 31 | 32 | 33 | 34 | 35 | ?> -------------------------------------------------------------------------------- /PHP-Parser-master/.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.3 5 | - 5.4 6 | - 5.5 7 | - 5.6 8 | - 7.0 9 | - hhvm 10 | 11 | matrix: 12 | allow_failures: 13 | - php: 7.0 14 | fast_finish: true 15 | -------------------------------------------------------------------------------- /PHP-Parser-master/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 by Nikita Popov. 2 | 3 | Some rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | * The names of the contributors may not be used to endorse or 18 | promote products derived from this software without specific 19 | prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /PHP-Parser-master/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nikic/php-parser", 3 | "description": "A PHP parser written in PHP", 4 | "keywords": ["php", "parser"], 5 | "type": "library", 6 | "license": "BSD-3-Clause", 7 | "authors": [ 8 | { 9 | "name": "Nikita Popov" 10 | } 11 | ], 12 | "require": { 13 | "php": ">=5.3", 14 | "ext-tokenizer": "*" 15 | }, 16 | "autoload": { 17 | "files": ["lib/bootstrap.php"] 18 | }, 19 | "extra": { 20 | "branch-alias": { 21 | "dev-master": "1.2-dev" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /PHP-Parser-master/doc/1_Installation.markdown: -------------------------------------------------------------------------------- 1 | Installation 2 | ============ 3 | 4 | There are multiple ways to include the PHP parser into your project: 5 | 6 | Installing via Composer 7 | ----------------------- 8 | 9 | Run the following command inside your project: 10 | 11 | php composer.phar require nikic/php-parser 12 | 13 | If you haven't installed [Composer][1] yet, you can do so using: 14 | 15 | curl -s http://getcomposer.org/installer | php 16 | 17 | Installing as a Git Submodule 18 | ----------------------------- 19 | 20 | Run the following command to install the parser into the `vendor/PHP-Parser` folder: 21 | 22 | git submodule add git://github.com/nikic/PHP-Parser.git vendor/PHP-Parser 23 | 24 | Installing from the Zip- or Tarball 25 | ----------------------------------- 26 | 27 | Download the latest version from [the download page][2], unpack it and move the files somewhere into your project. 28 | 29 | 30 | [1]: https://getcomposer.org/ 31 | [2]: https://github.com/nikic/PHP-Parser/tags 32 | -------------------------------------------------------------------------------- /PHP-Parser-master/grammar/README.md: -------------------------------------------------------------------------------- 1 | What do all those files mean? 2 | ============================= 3 | 4 | * `zend_language_parser.phpy`: PHP grammer written in a pseudo language 5 | * `analyze.php`: Analyzes the `.phpy`-grammer and outputs some info about it 6 | * `rebuildParser.php`: Preprocesses the `.phpy`-grammar and builds the parser using `kmyacc` 7 | * `kmyacc.php.parser`: A `kmyacc` parser prototype file for PHP 8 | 9 | .phpy pseudo language 10 | ===================== 11 | 12 | The `.phpy` file is a normal grammer in `kmyacc` (`yacc`) style, with some transformations 13 | applied to it: 14 | 15 | * Nodes are created using the syntax `Name[..., ...]`. This is transformed into 16 | `new Node\Name(..., ..., $attributes)` 17 | * `Name::abc` is transformed to `Node\Name::abc` 18 | * Some function-like constructs are resolved (see `rebuildParser.php` for a list) 19 | * Associative arrays are written as `[key: value, ...]`, which is transformed to 20 | `array('key' => value, ...)` 21 | 22 | Building the parser 23 | =================== 24 | 25 | In order to rebuild the parser, you need [moriyoshi's fork of kmyacc](https://github.com/moriyoshi/kmyacc-forked). 26 | After you compiled/installed it, run the `rebuildParser.php` script. 27 | 28 | By default only the `Parser.php` is built. If you want to additionally build `Parser/Debug.php` and `y.output` run the 29 | script with `--debug`. If you want to retain the preprocessed grammar pass `--keep-tmp-grammar`. -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Builder.php: -------------------------------------------------------------------------------- 1 | addStmt($stmt); 25 | } 26 | 27 | return $this; 28 | } 29 | 30 | /** 31 | * Sets doc comment for the declaration. 32 | * 33 | * @param PhpParser\Comment\Doc|string $docComment Doc comment to set 34 | * 35 | * @return $this The builder instance (for fluid interface) 36 | */ 37 | public function setDocComment($docComment) { 38 | $this->attributes['comments'] = array( 39 | $this->normalizeDocComment($docComment) 40 | ); 41 | 42 | return $this; 43 | } 44 | } -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Builder/FunctionLike.php: -------------------------------------------------------------------------------- 1 | returnByRef = true; 21 | 22 | return $this; 23 | } 24 | 25 | /** 26 | * Adds a parameter. 27 | * 28 | * @param Node\Param|Param $param The parameter to add 29 | * 30 | * @return $this The builder instance (for fluid interface) 31 | */ 32 | public function addParam($param) { 33 | $param = $this->normalizeNode($param); 34 | 35 | if (!$param instanceof Node\Param) { 36 | throw new \LogicException(sprintf('Expected parameter node, got "%s"', $param->getType())); 37 | } 38 | 39 | $this->params[] = $param; 40 | 41 | return $this; 42 | } 43 | 44 | /** 45 | * Adds multiple parameters. 46 | * 47 | * @param array $params The parameters to add 48 | * 49 | * @return $this The builder instance (for fluid interface) 50 | */ 51 | public function addParams(array $params) { 52 | foreach ($params as $param) { 53 | $this->addParam($param); 54 | } 55 | 56 | return $this; 57 | } 58 | } -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Builder/Function_.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | /** 24 | * Adds a statement. 25 | * 26 | * @param Node|PhpParser\Builder $stmt The statement to add 27 | * 28 | * @return $this The builder instance (for fluid interface) 29 | */ 30 | public function addStmt($stmt) { 31 | $this->stmts[] = $this->normalizeNode($stmt); 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * Returns the built function node. 38 | * 39 | * @return Stmt\Function_ The built function node 40 | */ 41 | public function getNode() { 42 | return new Stmt\Function_($this->name, array( 43 | 'byRef' => $this->returnByRef, 44 | 'params' => $this->params, 45 | 'stmts' => $this->stmts, 46 | ), $this->attributes); 47 | } 48 | } -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Builder/Namespace_.php: -------------------------------------------------------------------------------- 1 | name = null !== $name ? $this->normalizeName($name) : null; 21 | } 22 | 23 | /** 24 | * Adds a statement. 25 | * 26 | * @param Node|PhpParser\Builder $stmt The statement to add 27 | * 28 | * @return $this The builder instance (for fluid interface) 29 | */ 30 | public function addStmt($stmt) { 31 | $this->stmts[] = $this->normalizeNode($stmt); 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * Adds multiple statements. 38 | * 39 | * @param array $stmts The statements to add 40 | * 41 | * @return $this The builder instance (for fluid interface) 42 | */ 43 | public function addStmts(array $stmts) { 44 | foreach ($stmts as $stmt) { 45 | $this->addStmt($stmt); 46 | } 47 | 48 | return $this; 49 | } 50 | 51 | /** 52 | * Returns the built node. 53 | * 54 | * @return Node The built node 55 | */ 56 | public function getNode() { 57 | return new Stmt\Namespace_($this->name, $this->stmts); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Builder/Trait_.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | /** 24 | * Adds a statement. 25 | * 26 | * @param Stmt|PhpParser\Builder $stmt The statement to add 27 | * 28 | * @return $this The builder instance (for fluid interface) 29 | */ 30 | public function addStmt($stmt) { 31 | $stmt = $this->normalizeNode($stmt); 32 | if (!$stmt instanceof Stmt\ClassMethod) { 33 | throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); 34 | } 35 | 36 | $this->methods[] = $stmt; 37 | 38 | return $this; 39 | } 40 | 41 | /** 42 | * Returns the built trait node. 43 | * 44 | * @return Stmt\Trait_ The built interface node 45 | */ 46 | public function getNode() { 47 | return new Stmt\Trait_($this->name, $this->methods, $this->attributes); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Builder/Use_.php: -------------------------------------------------------------------------------- 1 | name = $this->normalizeName($name); 25 | $this->type = $type; 26 | } 27 | 28 | /** 29 | * Sets alias for used name. 30 | * 31 | * @param string $alias Alias to use (last component of full name by default) 32 | * 33 | * @return $this The builder instance (for fluid interface) 34 | */ 35 | protected function as_($alias) { 36 | $this->alias = $alias; 37 | return $this; 38 | } 39 | public function __call($method, $args) { 40 | return call_user_func_array(array($this, $method . '_'), $args); 41 | } 42 | 43 | /** 44 | * Returns the built node. 45 | * 46 | * @return Node The built node 47 | */ 48 | public function getNode() { 49 | $alias = null !== $this->alias ? $this->alias : $this->name->getLast(); 50 | return new Stmt\Use_(array( 51 | new Stmt\UseUse($this->name, $alias) 52 | ), $this->type); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Comment/Doc.php: -------------------------------------------------------------------------------- 1 | value = $value; 27 | $this->byRef = $byRef; 28 | $this->unpack = $unpack; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('value', 'byRef', 'unpack'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Const_.php: -------------------------------------------------------------------------------- 1 | name = $name; 24 | $this->value = $value; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('name', 'value'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->dim = $dim; 25 | } 26 | 27 | public function getSubnodeNames() { 28 | return array('var', 'dim'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/ArrayItem.php: -------------------------------------------------------------------------------- 1 | key = $key; 27 | $this->value = $value; 28 | $this->byRef = $byRef; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('key', 'value', 'byRef'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Array_.php: -------------------------------------------------------------------------------- 1 | items = $items; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('items'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Assign.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->expr = $expr; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'expr'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/AssignOp.php: -------------------------------------------------------------------------------- 1 | var = $var; 28 | $this->expr = $expr; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('var', 'expr'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php: -------------------------------------------------------------------------------- 1 | var = $var; 28 | $this->expr = $expr; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('var', 'expr'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/BinaryOp.php: -------------------------------------------------------------------------------- 1 | left = $left; 24 | $this->right = $right; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('left', 'right'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/BooleanNot.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Cast.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Cast/Array_.php: -------------------------------------------------------------------------------- 1 | class = $class; 25 | $this->name = $name; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('class', 'name'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Clone_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/ClosureUse.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->byRef = $byRef; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'byRef'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/ConstFetch.php: -------------------------------------------------------------------------------- 1 | name = $name; 22 | } 23 | 24 | public function getSubNodeNames() { 25 | return array('name'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Empty_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/ErrorSuppress.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Eval_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Exit_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/FuncCall.php: -------------------------------------------------------------------------------- 1 | name = $name; 25 | $this->args = $args; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('name', 'args'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Include_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 29 | $this->type = $type; 30 | } 31 | 32 | public function getSubNodeNames() { 33 | return array('expr', 'type'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Instanceof_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 25 | $this->class = $class; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('expr', 'class'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Isset_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/List_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/MethodCall.php: -------------------------------------------------------------------------------- 1 | var = $var; 28 | $this->name = $name; 29 | $this->args = $args; 30 | } 31 | 32 | public function getSubNodeNames() { 33 | return array('var', 'name', 'args'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/New_.php: -------------------------------------------------------------------------------- 1 | class = $class; 25 | $this->args = $args; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('class', 'args'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/PostDec.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/PostInc.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/PreDec.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/PreInc.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Print_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/PropertyFetch.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->name = $name; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'name'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/ShellExec.php: -------------------------------------------------------------------------------- 1 | parts = $parts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('parts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/StaticCall.php: -------------------------------------------------------------------------------- 1 | class = $class; 28 | $this->name = $name; 29 | $this->args = $args; 30 | } 31 | 32 | public function getSubNodeNames() { 33 | return array('class', 'name', 'args'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/StaticPropertyFetch.php: -------------------------------------------------------------------------------- 1 | class = $class; 25 | $this->name = $name; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('class', 'name'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Ternary.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 27 | $this->if = $if; 28 | $this->else = $else; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('cond', 'if', 'else'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/UnaryMinus.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/UnaryPlus.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Variable.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Expr/Yield_.php: -------------------------------------------------------------------------------- 1 | key = $key; 24 | $this->value = $value; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('key', 'value'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Name/FullyQualified.php: -------------------------------------------------------------------------------- 1 | type = $type; 34 | $this->byRef = $byRef; 35 | $this->variadic = $variadic; 36 | $this->name = $name; 37 | $this->default = $default; 38 | 39 | if ($variadic && null !== $default) { 40 | throw new Error('Variadic parameter cannot have a default value'); 41 | } 42 | } 43 | 44 | public function getSubNodeNames() { 45 | return array('type', 'byRef', 'variadic', 'name', 'default'); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Scalar.php: -------------------------------------------------------------------------------- 1 | parts = $parts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('parts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Scalar/LNumber.php: -------------------------------------------------------------------------------- 1 | value = $value; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('value'); 25 | } 26 | 27 | /** 28 | * @internal 29 | * 30 | * Parses an LNUMBER token (dec, hex, oct and bin notations) like PHP would. 31 | * 32 | * @param string $str A string number 33 | * 34 | * @return int The parsed number 35 | */ 36 | public static function parse($str) { 37 | // handle plain 0 specially 38 | if ('0' === $str) { 39 | return 0; 40 | } 41 | 42 | // if first char is 0 (and number isn't 0) it's a special syntax 43 | if ('0' === $str[0]) { 44 | // hex 45 | if ('x' === $str[1] || 'X' === $str[1]) { 46 | return hexdec($str); 47 | } 48 | 49 | // bin 50 | if ('b' === $str[1] || 'B' === $str[1]) { 51 | return bindec($str); 52 | } 53 | 54 | // oct (intval instead of octdec to get proper cutting behavior with malformed numbers) 55 | return intval($str, 8); 56 | } 57 | 58 | // dec 59 | return (int) $str; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Scalar/MagicConst.php: -------------------------------------------------------------------------------- 1 | num = $num; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('num'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Case_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Catch_.php: -------------------------------------------------------------------------------- 1 | type = $type; 27 | $this->var = $var; 28 | $this->stmts = $stmts; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('type', 'var', 'stmts'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/ClassConst.php: -------------------------------------------------------------------------------- 1 | consts = $consts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('consts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/ClassLike.php: -------------------------------------------------------------------------------- 1 | stmts as $stmt) { 16 | if ($stmt instanceof ClassMethod) { 17 | $methods[] = $stmt; 18 | } 19 | } 20 | return $methods; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Const_.php: -------------------------------------------------------------------------------- 1 | consts = $consts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('consts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Continue_.php: -------------------------------------------------------------------------------- 1 | num = $num; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('num'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/DeclareDeclare.php: -------------------------------------------------------------------------------- 1 | value pair node. 16 | * 17 | * @param string $key Key 18 | * @param Node\Expr $value Value 19 | * @param array $attributes Additional attributes 20 | */ 21 | public function __construct($key, Node\Expr $value, array $attributes = array()) { 22 | parent::__construct(null, $attributes); 23 | $this->key = $key; 24 | $this->value = $value; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('key', 'value'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Declare_.php: -------------------------------------------------------------------------------- 1 | declares = $declares; 23 | $this->stmts = $stmts; 24 | } 25 | 26 | public function getSubNodeNames() { 27 | return array('declares', 'stmts'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Do_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Echo_.php: -------------------------------------------------------------------------------- 1 | exprs = $exprs; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('exprs'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/ElseIf_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Else_.php: -------------------------------------------------------------------------------- 1 | stmts = $stmts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('stmts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/For_.php: -------------------------------------------------------------------------------- 1 | array(): Init expressions 23 | * 'cond' => array(): Loop conditions 24 | * 'loop' => array(): Loop expressions 25 | * 'stmts' => array(): Statements 26 | * @param array $attributes Additional attributes 27 | */ 28 | public function __construct(array $subNodes = array(), array $attributes = array()) { 29 | parent::__construct(null, $attributes); 30 | $this->init = isset($subNodes['init']) ? $subNodes['init'] : array(); 31 | $this->cond = isset($subNodes['cond']) ? $subNodes['cond'] : array(); 32 | $this->loop = isset($subNodes['loop']) ? $subNodes['loop'] : array(); 33 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 34 | } 35 | 36 | public function getSubNodeNames() { 37 | return array('init', 'cond', 'loop', 'stmts'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Foreach_.php: -------------------------------------------------------------------------------- 1 | null : Variable to assign key to 27 | * 'byRef' => false : Whether to assign value by reference 28 | * 'stmts' => array(): Statements 29 | * @param array $attributes Additional attributes 30 | */ 31 | public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = array(), array $attributes = array()) { 32 | parent::__construct(null, $attributes); 33 | $this->expr = $expr; 34 | $this->keyVar = isset($subNodes['keyVar']) ? $subNodes['keyVar'] : null; 35 | $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; 36 | $this->valueVar = $valueVar; 37 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 38 | } 39 | 40 | public function getSubNodeNames() { 41 | return array('expr', 'keyVar', 'byRef', 'valueVar', 'stmts'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Function_.php: -------------------------------------------------------------------------------- 1 | false : Whether to return by reference 26 | * 'params' => array(): Parameters 27 | * 'returnType' => null : Return type 28 | * 'stmts' => array(): Statements 29 | * @param array $attributes Additional attributes 30 | */ 31 | public function __construct($name, array $subNodes = array(), array $attributes = array()) { 32 | parent::__construct(null, $attributes); 33 | $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; 34 | $this->name = $name; 35 | $this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); 36 | $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; 37 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 38 | } 39 | 40 | public function getSubNodeNames() { 41 | return array('byRef', 'name', 'params', 'returnType', 'stmts'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Global_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Goto_.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/HaltCompiler.php: -------------------------------------------------------------------------------- 1 | remaining = $remaining; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('remaining'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/If_.php: -------------------------------------------------------------------------------- 1 | array(): Statements 24 | * 'elseifs' => array(): Elseif clauses 25 | * 'else' => null : Else clause 26 | * @param array $attributes Additional attributes 27 | */ 28 | public function __construct(Node\Expr $cond, array $subNodes = array(), array $attributes = array()) { 29 | parent::__construct(null, $attributes); 30 | $this->cond = $cond; 31 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 32 | $this->elseifs = isset($subNodes['elseifs']) ? $subNodes['elseifs'] : array(); 33 | $this->else = isset($subNodes['else']) ? $subNodes['else'] : null; 34 | } 35 | 36 | public function getSubNodeNames() { 37 | return array('cond', 'stmts', 'elseifs', 'else'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/InlineHTML.php: -------------------------------------------------------------------------------- 1 | value = $value; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('value'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Interface_.php: -------------------------------------------------------------------------------- 1 | true, 15 | 'parent' => true, 16 | 'static' => true, 17 | ); 18 | 19 | /** 20 | * Constructs a class node. 21 | * 22 | * @param string $name Name 23 | * @param array $subNodes Array of the following optional subnodes: 24 | * 'extends' => array(): Name of extended interfaces 25 | * 'stmts' => array(): Statements 26 | * @param array $attributes Additional attributes 27 | */ 28 | public function __construct($name, array $subNodes = array(), array $attributes = array()) { 29 | parent::__construct(null, $attributes); 30 | $this->name = $name; 31 | $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : array(); 32 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 33 | 34 | if (isset(self::$specialNames[(string) $this->name])) { 35 | throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->name)); 36 | } 37 | 38 | foreach ($this->extends as $interface) { 39 | if (isset(self::$specialNames[(string) $interface])) { 40 | throw new Error(sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface)); 41 | } 42 | } 43 | } 44 | 45 | public function getSubNodeNames() { 46 | return array('name', 'extends', 'stmts'); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Label.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Namespace_.php: -------------------------------------------------------------------------------- 1 | true, 17 | 'parent' => true, 18 | 'static' => true, 19 | ); 20 | 21 | /** 22 | * Constructs a namespace node. 23 | * 24 | * @param null|Node\Name $name Name 25 | * @param null|Node[] $stmts Statements 26 | * @param array $attributes Additional attributes 27 | */ 28 | public function __construct(Node\Name $name = null, $stmts = array(), array $attributes = array()) { 29 | parent::__construct(null, $attributes); 30 | $this->name = $name; 31 | $this->stmts = $stmts; 32 | 33 | if (isset(self::$specialNames[(string) $this->name])) { 34 | throw new Error(sprintf('Cannot use \'%s\' as namespace name', $this->name)); 35 | } 36 | 37 | if (null !== $this->stmts) { 38 | foreach ($this->stmts as $stmt) { 39 | if ($stmt instanceof self) { 40 | throw new Error('Namespace declarations cannot be nested', $stmt->getLine()); 41 | } 42 | } 43 | } 44 | } 45 | 46 | public function getSubNodeNames() { 47 | return array('name', 'stmts'); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Property.php: -------------------------------------------------------------------------------- 1 | type = $type; 33 | $this->props = $props; 34 | } 35 | 36 | public function getSubNodeNames() { 37 | return array('type', 'props'); 38 | } 39 | 40 | public function isPublic() { 41 | return ($this->type & Class_::MODIFIER_PUBLIC) !== 0 || $this->type === 0; 42 | } 43 | 44 | public function isProtected() { 45 | return (bool) ($this->type & Class_::MODIFIER_PROTECTED); 46 | } 47 | 48 | public function isPrivate() { 49 | return (bool) ($this->type & Class_::MODIFIER_PRIVATE); 50 | } 51 | 52 | public function isStatic() { 53 | return (bool) ($this->type & Class_::MODIFIER_STATIC); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/PropertyProperty.php: -------------------------------------------------------------------------------- 1 | name = $name; 24 | $this->default = $default; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('name', 'default'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Return_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/StaticVar.php: -------------------------------------------------------------------------------- 1 | name = $name; 24 | $this->default = $default; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('name', 'default'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Static_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Switch_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->cases = $cases; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'cases'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Throw_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/TraitUse.php: -------------------------------------------------------------------------------- 1 | traits = $traits; 25 | $this->adaptations = $adaptations; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('traits', 'adaptations'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php: -------------------------------------------------------------------------------- 1 | trait = $trait; 26 | $this->method = $method; 27 | $this->newModifier = $newModifier; 28 | $this->newName = $newName; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('trait', 'method', 'newModifier', 'newName'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php: -------------------------------------------------------------------------------- 1 | trait = $trait; 23 | $this->method = $method; 24 | $this->insteadof = $insteadof; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('trait', 'method', 'insteadof'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Trait_.php: -------------------------------------------------------------------------------- 1 | name = $name; 19 | $this->stmts = $stmts; 20 | } 21 | 22 | public function getSubNodeNames() { 23 | return array('name', 'stmts'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/TryCatch.php: -------------------------------------------------------------------------------- 1 | stmts = $stmts; 32 | $this->catches = $catches; 33 | $this->finallyStmts = $finallyStmts; 34 | } 35 | 36 | public function getSubNodeNames() { 37 | return array('stmts', 'catches', 'finallyStmts'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Unset_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/UseUse.php: -------------------------------------------------------------------------------- 1 | getLast(); 25 | } 26 | 27 | if ('self' == $alias || 'parent' == $alias) { 28 | throw new Error(sprintf( 29 | 'Cannot use %s as %s because \'%2$s\' is a special class name', 30 | $name, $alias 31 | )); 32 | } 33 | 34 | parent::__construct(null, $attributes); 35 | $this->name = $name; 36 | $this->alias = $alias; 37 | } 38 | 39 | public function getSubNodeNames() { 40 | return array('name', 'alias'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/Use_.php: -------------------------------------------------------------------------------- 1 | type = $type; 28 | $this->uses = $uses; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('type', 'uses'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/Node/Stmt/While_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PHP-Parser-master/lib/PhpParser/NodeTraverserInterface.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 15 | ./test/ 16 | 17 | 18 | 19 | 20 | 21 | ./lib/PhpParser/ 22 | 23 | 24 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/AutoloaderTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceof('PhpParser\Lexer', $lexer); 17 | $this->assertInstanceof('PhpParser\Parser', $parser); 18 | $this->assertInstanceof('PhpParser\PrettyPrinter\Standard', $prettyPrinter); 19 | } 20 | 21 | public function testPhp7ReservedNames() { 22 | if (version_compare(PHP_VERSION, '7.0-dev', '>=')) { 23 | $this->markTestSkipped('Cannot create aliases to reserved names on PHP 7'); 24 | } 25 | 26 | $this->assertTrue(new Expr\Cast\Bool_(new Expr\Variable('foo')) instanceof Expr\Cast\Bool); 27 | $this->assertTrue(new Expr\Cast\Int_(new Expr\Variable('foo')) instanceof Expr\Cast\Int); 28 | 29 | $this->assertInstanceof('PhpParser\Node\Expr\Cast\Object_', new Expr\Cast\Object(new Expr\Variable('foo'))); 30 | $this->assertInstanceof('PhpParser\Node\Expr\Cast\String_', new Expr\Cast\String(new Expr\Variable('foo'))); 31 | $this->assertInstanceof('PhpParser\Node\Scalar\String_', new Scalar\String('foobar')); 32 | } 33 | 34 | public function testClassExists() { 35 | $this->assertTrue(class_exists('PhpParser\NodeVisitorAbstract')); 36 | $this->assertTrue(class_exists('PHPParser_NodeVisitor_NameResolver')); 37 | 38 | $this->assertFalse(class_exists('PhpParser\FooBar')); 39 | $this->assertFalse(class_exists('PHPParser_FooBar')); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/Builder/NamespaceTest.php: -------------------------------------------------------------------------------- 1 | createNamespaceBuilder('Name\Space') 24 | ->addStmt($stmt1) 25 | ->addStmts(array($stmt2, $stmt3)) 26 | ->getNode() 27 | ; 28 | $this->assertEquals($expected, $node); 29 | 30 | $node = $this->createNamespaceBuilder(new Node\Name(array('Name', 'Space'))) 31 | ->addStmts(array($stmt1, $stmt2)) 32 | ->addStmt($stmt3) 33 | ->getNode() 34 | ; 35 | $this->assertEquals($expected, $node); 36 | 37 | $node = $this->createNamespaceBuilder(null)->getNode(); 38 | $this->assertNull($node->name); 39 | $this->assertEmpty($node->stmts); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/Builder/TraitTest.php: -------------------------------------------------------------------------------- 1 | createTraitBuilder('TestTrait') 21 | ->setDocComment('/** Nice trait */') 22 | ->addStmt($method1) 23 | ->addStmts(array($method2, $method3)) 24 | ->getNode(); 25 | $this->assertEquals(new Stmt\Trait_('TestTrait', array( 26 | $method1, $method2, $method3 27 | ), array( 28 | 'comments' => array( 29 | new Comment\Doc('/** Nice trait */') 30 | ) 31 | )), $trait); 32 | } 33 | 34 | /** 35 | * @expectedException \LogicException 36 | * @expectedExceptionMessage Unexpected node of type "Stmt_Echo" 37 | */ 38 | public function testInvalidStmtError() { 39 | $this->createTraitBuilder('Test') 40 | ->addStmt(new Stmt\Echo_(array())) 41 | ; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/Builder/UseTest.php: -------------------------------------------------------------------------------- 1 | createUseBuilder('Foo\Bar')->getNode(); 15 | $this->assertEquals(new Stmt\Use_(array( 16 | new Stmt\UseUse(new Name('Foo\Bar'), 'Bar') 17 | )), $node); 18 | 19 | $node = $this->createUseBuilder(new Name('Foo\Bar'))->as('XYZ')->getNode(); 20 | $this->assertEquals(new Stmt\Use_(array( 21 | new Stmt\UseUse(new Name('Foo\Bar'), 'XYZ') 22 | )), $node); 23 | 24 | $node = $this->createUseBuilder('foo\bar', Stmt\Use_::TYPE_FUNCTION)->as('foo')->getNode(); 25 | $this->assertEquals(new Stmt\Use_(array( 26 | new Stmt\UseUse(new Name('foo\bar'), 'foo') 27 | ), Stmt\Use_::TYPE_FUNCTION), $node); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/ErrorTest.php: -------------------------------------------------------------------------------- 1 | assertSame('Some error', $error->getRawMessage()); 11 | $this->assertSame(10, $error->getRawLine()); 12 | $this->assertSame('Some error on line 10', $error->getMessage()); 13 | 14 | return $error; 15 | } 16 | 17 | /** 18 | * @depends testConstruct 19 | */ 20 | public function testSetMessageAndLine(Error $error) { 21 | $error->setRawMessage('Some other error'); 22 | $error->setRawLine(15); 23 | 24 | $this->assertSame('Some other error', $error->getRawMessage()); 25 | $this->assertSame(15, $error->getRawLine()); 26 | $this->assertSame('Some other error on line 15', $error->getMessage()); 27 | } 28 | 29 | public function testUnknownLine() { 30 | $error = new Error('Some error'); 31 | 32 | $this->assertSame(-1, $error->getRawLine()); 33 | $this->assertSame('Some error on unknown line', $error->getMessage()); 34 | } 35 | } -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/Node/Scalar/MagicConstTest.php: -------------------------------------------------------------------------------- 1 | assertSame($name, $magicConst->getName()); 11 | } 12 | 13 | public function provideTestGetName() { 14 | return array( 15 | array(new MagicConst\Class_, '__CLASS__'), 16 | array(new MagicConst\Dir, '__DIR__'), 17 | array(new MagicConst\File, '__FILE__'), 18 | array(new MagicConst\Function_, '__FUNCTION__'), 19 | array(new MagicConst\Line, '__LINE__'), 20 | array(new MagicConst\Method, '__METHOD__'), 21 | array(new MagicConst\Namespace_, '__NAMESPACE__'), 22 | array(new MagicConst\Trait_, '__TRAIT__'), 23 | ); 24 | } 25 | } -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/Node/Stmt/ClassMethodTest.php: -------------------------------------------------------------------------------- 1 | constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier)) 13 | )); 14 | 15 | $this->assertTrue($node->{'is' . $modifier}()); 16 | } 17 | 18 | public function testNoModifiers() { 19 | $node = new ClassMethod('foo', array('type' => 0)); 20 | 21 | $this->assertTrue($node->isPublic()); 22 | $this->assertFalse($node->isProtected()); 23 | $this->assertFalse($node->isPrivate()); 24 | $this->assertFalse($node->isAbstract()); 25 | $this->assertFalse($node->isFinal()); 26 | $this->assertFalse($node->isStatic()); 27 | } 28 | 29 | public function provideModifiers() { 30 | return array( 31 | array('public'), 32 | array('protected'), 33 | array('private'), 34 | array('abstract'), 35 | array('final'), 36 | array('static'), 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/Node/Stmt/ClassTest.php: -------------------------------------------------------------------------------- 1 | Class_::MODIFIER_ABSTRACT)); 9 | $this->assertTrue($class->isAbstract()); 10 | 11 | $class = new Class_('Foo'); 12 | $this->assertFalse($class->isAbstract()); 13 | } 14 | 15 | public function testIsFinal() { 16 | $class = new Class_('Foo', array('type' => Class_::MODIFIER_FINAL)); 17 | $this->assertTrue($class->isFinal()); 18 | 19 | $class = new Class_('Foo'); 20 | $this->assertFalse($class->isFinal()); 21 | } 22 | 23 | public function testGetMethods() { 24 | $methods = array( 25 | new ClassMethod('foo'), 26 | new ClassMethod('bar'), 27 | new ClassMethod('fooBar'), 28 | ); 29 | $class = new Class_('Foo', array( 30 | 'stmts' => array( 31 | new TraitUse(array()), 32 | $methods[0], 33 | new ClassConst(array()), 34 | $methods[1], 35 | new Property(0, array()), 36 | $methods[2], 37 | ) 38 | )); 39 | 40 | $this->assertSame($methods, $class->getMethods()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/Node/Stmt/InterfaceTest.php: -------------------------------------------------------------------------------- 1 | array( 16 | new Node\Stmt\ClassConst(array(new Node\Const_('C1', new Node\Scalar\String_('C1')))), 17 | $methods[0], 18 | new Node\Stmt\ClassConst(array(new Node\Const_('C2', new Node\Scalar\String_('C2')))), 19 | $methods[1], 20 | new Node\Stmt\ClassConst(array(new Node\Const_('C3', new Node\Scalar\String_('C3')))), 21 | ) 22 | )); 23 | 24 | $this->assertSame($methods, $interface->getMethods()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/PhpParser/Node/Stmt/PropertyTest.php: -------------------------------------------------------------------------------- 1 | assertTrue($node->{'is' . $modifier}()); 17 | } 18 | 19 | public function testNoModifiers() { 20 | $node = new Property(0, array()); 21 | 22 | $this->assertTrue($node->isPublic()); 23 | $this->assertFalse($node->isProtected()); 24 | $this->assertFalse($node->isPrivate()); 25 | $this->assertFalse($node->isStatic()); 26 | } 27 | 28 | public function provideModifiers() { 29 | return array( 30 | array('public'), 31 | array('protected'), 32 | array('private'), 33 | array('static'), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/code/parser/expr/cast.test: -------------------------------------------------------------------------------- 1 | Casts 2 | ----- 3 | b; 6 | (new A)->b(); 7 | (new A)['b']; 8 | (new A)['b']['c']; 9 | ----- 10 | array( 11 | 0: Expr_PropertyFetch( 12 | var: Expr_New( 13 | class: Name( 14 | parts: array( 15 | 0: A 16 | ) 17 | ) 18 | args: array( 19 | ) 20 | ) 21 | name: b 22 | ) 23 | 1: Expr_MethodCall( 24 | var: Expr_New( 25 | class: Name( 26 | parts: array( 27 | 0: A 28 | ) 29 | ) 30 | args: array( 31 | ) 32 | ) 33 | name: b 34 | args: array( 35 | ) 36 | ) 37 | 2: Expr_ArrayDimFetch( 38 | var: Expr_New( 39 | class: Name( 40 | parts: array( 41 | 0: A 42 | ) 43 | ) 44 | args: array( 45 | ) 46 | ) 47 | dim: Scalar_String( 48 | value: b 49 | ) 50 | ) 51 | 3: Expr_ArrayDimFetch( 52 | var: Expr_ArrayDimFetch( 53 | var: Expr_New( 54 | class: Name( 55 | parts: array( 56 | 0: A 57 | ) 58 | ) 59 | args: array( 60 | ) 61 | ) 62 | dim: Scalar_String( 63 | value: b 64 | ) 65 | ) 66 | dim: Scalar_String( 67 | value: c 68 | ) 69 | ) 70 | ) -------------------------------------------------------------------------------- /PHP-Parser-master/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test: -------------------------------------------------------------------------------- 1 | Simple array access 2 | ----- 3 | c test 25 | EOS; 26 | 27 | // comment to force line break before EOF 28 | ----- 29 | array( 30 | 0: Scalar_String( 31 | value: 32 | ) 33 | 1: Scalar_String( 34 | value: 35 | ) 36 | 2: Scalar_String( 37 | value: Test '" $a \n 38 | ) 39 | 3: Scalar_String( 40 | value: Test '" $a 41 | 42 | ) 43 | 4: Scalar_Encapsed( 44 | parts: array( 45 | 0: Test 46 | 1: Expr_Variable( 47 | name: a 48 | ) 49 | ) 50 | ) 51 | 5: Scalar_Encapsed( 52 | parts: array( 53 | 0: Test 54 | 1: Expr_Variable( 55 | name: a 56 | ) 57 | 2: and 58 | 3: Expr_PropertyFetch( 59 | var: Expr_Variable( 60 | name: b 61 | ) 62 | name: c 63 | ) 64 | 4: test 65 | ) 66 | ) 67 | ) -------------------------------------------------------------------------------- /PHP-Parser-master/test/code/parser/scalar/float.test: -------------------------------------------------------------------------------- 1 | Different float syntaxes 2 | ----- 3 | float overflows 17 | // (all are actually the same number, just in different representations) 18 | 18446744073709551615; 19 | 0xFFFFFFFFFFFFFFFF; 20 | 01777777777777777777777; 21 | 0b1111111111111111111111111111111111111111111111111111111111111111; 22 | ----- 23 | array( 24 | 0: Scalar_DNumber( 25 | value: 0 26 | ) 27 | 1: Scalar_DNumber( 28 | value: 0 29 | ) 30 | 2: Scalar_DNumber( 31 | value: 0 32 | ) 33 | 3: Scalar_DNumber( 34 | value: 0 35 | ) 36 | 4: Scalar_DNumber( 37 | value: 0 38 | ) 39 | 5: Scalar_DNumber( 40 | value: 0 41 | ) 42 | 6: Scalar_DNumber( 43 | value: 0 44 | ) 45 | 7: Scalar_DNumber( 46 | value: 302000000000 47 | ) 48 | 8: Scalar_DNumber( 49 | value: 3.002E+102 50 | ) 51 | 9: Scalar_DNumber( 52 | value: INF 53 | ) 54 | 10: Scalar_DNumber( 55 | value: @@{ 0xFFFFFFFFFFFFFFFF }@@ 56 | ) 57 | 11: Scalar_DNumber( 58 | value: @@{ 0xFFFFFFFFFFFFFFFF }@@ 59 | ) 60 | 12: Scalar_DNumber( 61 | value: @@{ 0xFFFFFFFFFFFFFFFF }@@ 62 | ) 63 | 13: Scalar_DNumber( 64 | value: @@{ 0xFFFFFFFFFFFFFFFF }@@ 65 | ) 66 | ) 67 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/code/parser/scalar/int.test: -------------------------------------------------------------------------------- 1 | Different integer syntaxes 2 | ----- 3 | 8 | Hallo World! 9 | ----- 10 | array( 11 | 0: Expr_Variable( 12 | name: a 13 | ) 14 | 1: Stmt_HaltCompiler( 15 | remaining: Hallo World! 16 | ) 17 | ) 18 | ----- 19 | 9 | #!/usr/bin/env php 10 | ----- 11 | array( 12 | 0: Stmt_InlineHTML( 13 | value: #!/usr/bin/env php 14 | 15 | ) 16 | 1: Stmt_Echo( 17 | exprs: array( 18 | 0: Scalar_String( 19 | value: foobar 20 | ) 21 | ) 22 | ) 23 | 2: Stmt_InlineHTML( 24 | value: #!/usr/bin/env php 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /PHP-Parser-master/test/code/parser/stmt/inlineHTML.test: -------------------------------------------------------------------------------- 1 | Inline HTML 2 | ----- 3 | 6 | B 7 | 10 | 10 | Hi! 11 | ----- 12 | array( 13 | 0: Stmt_Declare( 14 | declares: array( 15 | 0: Stmt_DeclareDeclare( 16 | key: A 17 | value: Scalar_String( 18 | value: B 19 | ) 20 | ) 21 | ) 22 | stmts: array( 23 | ) 24 | ) 25 | 1: Stmt_Namespace( 26 | name: Name( 27 | parts: array( 28 | 0: B 29 | ) 30 | ) 31 | stmts: array( 32 | ) 33 | ) 34 | 2: Stmt_HaltCompiler( 35 | remaining: Hi! 36 | ) 37 | ) -------------------------------------------------------------------------------- /PHP-Parser-master/test/code/parser/stmt/namespace/outsideStmt.test-fail: -------------------------------------------------------------------------------- 1 | There (mostly) can't be statements outside of namespaces 2 | ----- 3 | a = 'bar'; 13 | echo 'test'; 14 | } 15 | 16 | protected function baz() {} 17 | public function foo() {} 18 | abstract static function bar() {} 19 | } 20 | ----- 21 | class Foo 22 | { 23 | var $a = 'foo'; 24 | private $b = 'bar'; 25 | static $c = 'baz'; 26 | function test() 27 | { 28 | $this->a = 'bar'; 29 | echo 'test'; 30 | } 31 | protected function baz() 32 | { 33 | } 34 | public function foo() 35 | { 36 | } 37 | static abstract function bar() 38 | { 39 | } 40 | } -------------------------------------------------------------------------------- /PHP-Parser-master/test/code/prettyPrinter/closure.test: -------------------------------------------------------------------------------- 1 | Closures 2 | ----- 3 | 14 | HTML 15 | ----- 16 | 20 | HTML 21 | ----- 22 | HTML 23 | 26 | HTML 27 | ----- 28 | HTML 29 | 32 | HTML 33 | ----- 34 | HTML 35 | 38 | HTML 39 | 42 | HTML 43 | ----- 44 | HTML 45 | 48 | HTML 49 | 52 | HTML -------------------------------------------------------------------------------- /PHP-Parser-master/test/code/prettyPrinter/list.test: -------------------------------------------------------------------------------- 1 | list() 2 | ----- 3 | b; 9 | $a->b(); 10 | $a->b($c); 11 | $a->$b(); 12 | $a->{$b}(); 13 | $a->$b[$c](); 14 | $$a->b; 15 | $a[$b]; 16 | $a[$b](); 17 | $$a[$b]; 18 | $a::B; 19 | $a::$b; 20 | $a::b(); 21 | $a::b($c); 22 | $a::$b(); 23 | $a::$b[$c]; 24 | $a::$b[$c]($d); 25 | $a::{$b[$c]}($d); 26 | $a::{$b->c}(); 27 | a(); 28 | $a(); 29 | $a()[$b]; 30 | $a->b()[$c]; 31 | $a::$b()[$c]; 32 | (new A)->b; 33 | (new A())->b(); 34 | (new $$a)[$b]; 35 | (new $a->b)->c; 36 | 37 | global $a, $$a, $$a[$b], $$a->b; 38 | ----- 39 | $a; 40 | ${$a}; 41 | ${$a}; 42 | $a->b; 43 | $a->b(); 44 | $a->b($c); 45 | $a->{$b}(); 46 | $a->{$b}(); 47 | $a->{$b[$c]}(); 48 | ${$a}->b; 49 | $a[$b]; 50 | $a[$b](); 51 | ${$a[$b]}; 52 | $a::B; 53 | $a::$b; 54 | $a::b(); 55 | $a::b($c); 56 | $a::$b(); 57 | $a::$b[$c]; 58 | $a::$b[$c]($d); 59 | $a::$b[$c]($d); 60 | $a::{$b->c}(); 61 | a(); 62 | $a(); 63 | $a()[$b]; 64 | $a->b()[$c]; 65 | $a::$b()[$c]; 66 | (new A())->b; 67 | (new A())->b(); 68 | (new ${$a}())[$b]; 69 | (new $a->b())->c; 70 | global $a, ${$a}, ${$a[$b]}, ${$a->b}; 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TaintPHP 2 | Static Taint Analysis for PHP web applications. Useful for detecting 3 | Cross-Site Scripting (XSS), SQL injections (SQLi), and confidentiality 4 | vulnerabilities. 5 | 6 | # Execution 7 | The execution script is 'run.script'. Modify the 'APPLICATION_FILE' 8 | bash variable in 'run.script', and execute the script to start the analysis. 9 | 10 | -------------------------------------------------------------------------------- /TaintAnalysis/CFGTaintMap.php: -------------------------------------------------------------------------------- 1 | UserTaintMap = $userTaintMap; 15 | $this->SecretTaintMap = $secretTaintMap; 16 | $this->ReturnsSecretTaint = False; 17 | $this->ReturnsUserTaint = False; 18 | } 19 | 20 | public function setUserTaintMap($userTaintMap) { 21 | 22 | $this->UserTaintMap = $userTaintMap; 23 | } 24 | 25 | public function setSecretTaintMap($secretTaintMap) { 26 | 27 | $this->SecretTaintMap = $secretTaintMap; 28 | } 29 | 30 | public function getUserTaintMap() { 31 | 32 | return $this->UserTaintMap; 33 | } 34 | 35 | public function getSecretTaintMap() { 36 | 37 | return $this->SecretTaintMap; 38 | } 39 | 40 | public function getReturnsSecretTaint() { 41 | return $this->ReturnsSecretTaint; 42 | } 43 | 44 | public function setReturnsSecretTaint($returnsSecretTaint) { 45 | $this->ReturnsSecretTaint = $returnsSecretTaint; 46 | } 47 | 48 | public function getReturnsUserTaint() { 49 | return $this->ReturnsUserTaint; 50 | } 51 | 52 | public function setReturnsUserTaint($returnsUserTaint) { 53 | $this->ReturnsUserTaint = $returnsUserTaint; 54 | } 55 | } 56 | ?> -------------------------------------------------------------------------------- /TaintAnalysis/FileTaintMap.php: -------------------------------------------------------------------------------- 1 | MainTaintMap = $mainTaintMap; 14 | $this->FunctionTaintMaps = $functionTaintMaps; 15 | } 16 | 17 | public function getMainTaintMap() { 18 | 19 | return $this->MainTaintMap; 20 | } 21 | 22 | public function getFunctionTaintMaps() { 23 | 24 | return $this->FunctionTaintMaps; 25 | } 26 | 27 | public function setMainTaintMap($mainTaintMap) { 28 | 29 | $this->MainTaintMap = $mainTaintMap; 30 | } 31 | 32 | public function setFunctionTaintMaps($functionTaintMaps) { 33 | 34 | $this->FunctionTaintMaps = $functionTaintMaps; 35 | } 36 | 37 | public function addFunctionTaintMap($functionName, $taintMap) { 38 | 39 | $this->FunctionTaintMaps[$functionName] = $taintMap; 40 | } 41 | } 42 | ?> -------------------------------------------------------------------------------- /TaintAnalysis/TaintMap.php: -------------------------------------------------------------------------------- 1 | Map = array(); 12 | } 13 | 14 | public function put($functionSignatureString, $cfgTaintMap){ 15 | $this->Map[$functionSignatureString] = $cfgTaintMap; 16 | } 17 | 18 | public function get($functionSignatureString){ 19 | return $this->Map[$functionSignatureString]; 20 | } 21 | 22 | public function contains($functionSignatureString){ 23 | return isset($this->Map[$functionSignatureString]); 24 | } 25 | } 26 | ?> -------------------------------------------------------------------------------- /TaintAnalysis/TaintedVariables.php: -------------------------------------------------------------------------------- 1 | set = array(); 12 | } 13 | 14 | public function contains($var) { 15 | 16 | return array_key_exists($var, $this->set); 17 | } 18 | 19 | public function attach($var) { 20 | 21 | print "Attaching " . $var . "\n"; 22 | $this->set[$var] = true; 23 | $this->printTaintedVariables(); 24 | } 25 | 26 | public function addAll($tainted_variable_set) { 27 | 28 | foreach ($tainted_variable_set->set as $var => $val) { 29 | print "Adding " . $var . " " . $val . "\n"; 30 | $this->set[$var] = $val; 31 | } 32 | } 33 | 34 | public function count() { 35 | 36 | return count(array_keys($this->set)); 37 | } 38 | 39 | public function printTaintedVariables() { 40 | 41 | print "The size is " . $this->count() . "\n"; 42 | print "["; 43 | foreach ($this->set as $var => $val) { 44 | 45 | print " " . $var; 46 | } 47 | print "]\n"; 48 | } 49 | } 50 | ?> -------------------------------------------------------------------------------- /run.script: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | APPLICATION_FILE='/var/www/html/openclinic/medical/patient_search.php' 3 | php taint_analysis_main.php $APPLICATION_FILE -------------------------------------------------------------------------------- /taint_analysis_main.php: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------