├── .gitignore ├── .idea ├── .name ├── deployment.xml ├── encodings.xml ├── modules.xml ├── scopes │ └── scope_settings.xml ├── vcs.xml └── wp_codex.iml ├── PhpParser ├── .ccignore ├── 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 ├── change_log.txt ├── codex_creator.php ├── css └── codex_creator.css ├── gpl.txt ├── js └── codex_creator.js ├── lib ├── add_meta_boxes.php ├── ajax_functions.php ├── bitbucket_functions.php ├── content_output_functions.php ├── cron_functions.php ├── file_functions.php ├── general_functions.php ├── helper_functions.php ├── setup_cpt.php └── setup_section.php ├── license.txt ├── phpDocumentor ├── .ccignore └── Reflection │ ├── DocBlock.php │ └── DocBlock │ ├── Context.php │ ├── Description.php │ ├── Location.php │ ├── Serializer.php │ ├── Tag.php │ ├── Tag │ ├── AuthorTag.php │ ├── CoversTag.php │ ├── DeprecatedTag.php │ ├── ExampleTag.php │ ├── LinkTag.php │ ├── MethodTag.php │ ├── ParamTag.php │ ├── PropertyReadTag.php │ ├── PropertyTag.php │ ├── PropertyWriteTag.php │ ├── ReturnTag.php │ ├── SeeTag.php │ ├── SinceTag.php │ ├── SourceTag.php │ ├── ThrowsTag.php │ ├── UsesTag.php │ ├── VarTag.php │ └── VersionTag.php │ └── Type │ └── Collection.php └── readme.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | wp_codex -------------------------------------------------------------------------------- /.idea/deployment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/wp_codex.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PhpParser/.ccignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stiofan/codex_creator/0189f6aa6e77ceb5ba63833ac42050c5c510e254/PhpParser/.ccignore -------------------------------------------------------------------------------- /PhpParser/Builder.php: -------------------------------------------------------------------------------- 1 | name = $name; 29 | } 30 | 31 | /** 32 | * Extends a class. 33 | * 34 | * @param Name|string $class Name of class to extend 35 | * 36 | * @return $this The builder instance (for fluid interface) 37 | */ 38 | public function extend($class) { 39 | $this->extends = $this->normalizeName($class); 40 | 41 | return $this; 42 | } 43 | 44 | /** 45 | * Implements one or more interfaces. 46 | * 47 | * @param Name|string $interface Name of interface to implement 48 | * @param Name|string $... More interfaces to implement 49 | * 50 | * @return $this The builder instance (for fluid interface) 51 | */ 52 | public function implement() { 53 | foreach (func_get_args() as $interface) { 54 | $this->implements[] = $this->normalizeName($interface); 55 | } 56 | 57 | return $this; 58 | } 59 | 60 | /** 61 | * Makes the class abstract. 62 | * 63 | * @return $this The builder instance (for fluid interface) 64 | */ 65 | public function makeAbstract() { 66 | $this->setModifier(Stmt\Class_::MODIFIER_ABSTRACT); 67 | 68 | return $this; 69 | } 70 | 71 | /** 72 | * Makes the class final. 73 | * 74 | * @return $this The builder instance (for fluid interface) 75 | */ 76 | public function makeFinal() { 77 | $this->setModifier(Stmt\Class_::MODIFIER_FINAL); 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * Adds a statement. 84 | * 85 | * @param Stmt|PhpParser\Builder $stmt The statement to add 86 | * 87 | * @return $this The builder instance (for fluid interface) 88 | */ 89 | public function addStmt($stmt) { 90 | $stmt = $this->normalizeNode($stmt); 91 | 92 | $targets = array( 93 | 'Stmt_TraitUse' => &$this->uses, 94 | 'Stmt_ClassConst' => &$this->constants, 95 | 'Stmt_Property' => &$this->properties, 96 | 'Stmt_ClassMethod' => &$this->methods, 97 | ); 98 | 99 | $type = $stmt->getType(); 100 | if (!isset($targets[$type])) { 101 | throw new \LogicException(sprintf('Unexpected node of type "%s"', $type)); 102 | } 103 | 104 | $targets[$type][] = $stmt; 105 | 106 | return $this; 107 | } 108 | 109 | /** 110 | * Returns the built class node. 111 | * 112 | * @return Stmt\Class_ The built class node 113 | */ 114 | public function getNode() { 115 | return new Stmt\Class_($this->name, array( 116 | 'type' => $this->type, 117 | 'extends' => $this->extends, 118 | 'implements' => $this->implements, 119 | 'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods), 120 | ), $this->attributes); 121 | } 122 | } -------------------------------------------------------------------------------- /PhpParser/Builder/Declaration.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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /PhpParser/Builder/Interface_.php: -------------------------------------------------------------------------------- 1 | name = $name; 23 | } 24 | 25 | /** 26 | * Extends one or more interfaces. 27 | * 28 | * @param Name|string $interface Name of interface to extend 29 | * @param Name|string $... More interfaces to extend 30 | * 31 | * @return $this The builder instance (for fluid interface) 32 | */ 33 | public function extend() { 34 | foreach (func_get_args() as $interface) { 35 | $this->extends[] = $this->normalizeName($interface); 36 | } 37 | 38 | return $this; 39 | } 40 | 41 | /** 42 | * Adds a statement. 43 | * 44 | * @param Stmt|PhpParser\Builder $stmt The statement to add 45 | * 46 | * @return $this The builder instance (for fluid interface) 47 | */ 48 | public function addStmt($stmt) { 49 | $stmt = $this->normalizeNode($stmt); 50 | 51 | $type = $stmt->getType(); 52 | switch ($type) { 53 | case 'Stmt_ClassConst': 54 | $this->constants[] = $stmt; 55 | break; 56 | 57 | case 'Stmt_ClassMethod': 58 | // we erase all statements in the body of an interface method 59 | $stmt->stmts = null; 60 | $this->methods[] = $stmt; 61 | break; 62 | 63 | default: 64 | throw new \LogicException(sprintf('Unexpected node of type "%s"', $type)); 65 | } 66 | 67 | return $this; 68 | } 69 | 70 | /** 71 | * Returns the built interface node. 72 | * 73 | * @return Stmt\Interface_ The built interface node 74 | */ 75 | public function getNode() { 76 | return new Stmt\Interface_($this->name, array( 77 | 'extends' => $this->extends, 78 | 'stmts' => array_merge($this->constants, $this->methods), 79 | ), $this->attributes); 80 | } 81 | } -------------------------------------------------------------------------------- /PhpParser/Builder/Method.php: -------------------------------------------------------------------------------- 1 | name = $name; 22 | } 23 | 24 | /** 25 | * Makes the method public. 26 | * 27 | * @return $this The builder instance (for fluid interface) 28 | */ 29 | public function makePublic() { 30 | $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC); 31 | 32 | return $this; 33 | } 34 | 35 | /** 36 | * Makes the method protected. 37 | * 38 | * @return $this The builder instance (for fluid interface) 39 | */ 40 | public function makeProtected() { 41 | $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED); 42 | 43 | return $this; 44 | } 45 | 46 | /** 47 | * Makes the method private. 48 | * 49 | * @return $this The builder instance (for fluid interface) 50 | */ 51 | public function makePrivate() { 52 | $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE); 53 | 54 | return $this; 55 | } 56 | 57 | /** 58 | * Makes the method static. 59 | * 60 | * @return $this The builder instance (for fluid interface) 61 | */ 62 | public function makeStatic() { 63 | $this->setModifier(Stmt\Class_::MODIFIER_STATIC); 64 | 65 | return $this; 66 | } 67 | 68 | /** 69 | * Makes the method abstract. 70 | * 71 | * @return $this The builder instance (for fluid interface) 72 | */ 73 | public function makeAbstract() { 74 | if (!empty($this->stmts)) { 75 | throw new \LogicException('Cannot make method with statements abstract'); 76 | } 77 | 78 | $this->setModifier(Stmt\Class_::MODIFIER_ABSTRACT); 79 | $this->stmts = null; // abstract methods don't have statements 80 | 81 | return $this; 82 | } 83 | 84 | /** 85 | * Makes the method final. 86 | * 87 | * @return $this The builder instance (for fluid interface) 88 | */ 89 | public function makeFinal() { 90 | $this->setModifier(Stmt\Class_::MODIFIER_FINAL); 91 | 92 | return $this; 93 | } 94 | 95 | /** 96 | * Adds a statement. 97 | * 98 | * @param Node|PhpParser\Builder $stmt The statement to add 99 | * 100 | * @return $this The builder instance (for fluid interface) 101 | */ 102 | public function addStmt($stmt) { 103 | if (null === $this->stmts) { 104 | throw new \LogicException('Cannot add statements to an abstract method'); 105 | } 106 | 107 | $this->stmts[] = $this->normalizeNode($stmt); 108 | 109 | return $this; 110 | } 111 | 112 | /** 113 | * Returns the built method node. 114 | * 115 | * @return Stmt\ClassMethod The built method node 116 | */ 117 | public function getNode() { 118 | return new Stmt\ClassMethod($this->name, array( 119 | 'type' => $this->type, 120 | 'byRef' => $this->returnByRef, 121 | 'params' => $this->params, 122 | 'stmts' => $this->stmts, 123 | ), $this->attributes); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Builder/Param.php: -------------------------------------------------------------------------------- 1 | name = $name; 23 | } 24 | 25 | /** 26 | * Sets default value for the parameter. 27 | * 28 | * @param mixed $value Default value to use 29 | * 30 | * @return $this The builder instance (for fluid interface) 31 | */ 32 | public function setDefault($value) { 33 | $this->default = $this->normalizeValue($value); 34 | 35 | return $this; 36 | } 37 | 38 | /** 39 | * Sets type hint for the parameter. 40 | * 41 | * @param string|Node\Name $type Type hint to use 42 | * 43 | * @return $this The builder instance (for fluid interface) 44 | */ 45 | public function setTypeHint($type) { 46 | if ($type === 'array' || $type === 'callable') { 47 | $this->type = $type; 48 | } else { 49 | $this->type = $this->normalizeName($type); 50 | } 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * Make the parameter accept the value by reference. 57 | * 58 | * @return $this The builder instance (for fluid interface) 59 | */ 60 | public function makeByRef() { 61 | $this->byRef = true; 62 | 63 | return $this; 64 | } 65 | 66 | /** 67 | * Returns the built parameter node. 68 | * 69 | * @return Node\Param The built parameter node 70 | */ 71 | public function getNode() { 72 | return new Node\Param( 73 | $this->name, $this->default, $this->type, $this->byRef 74 | ); 75 | } 76 | } -------------------------------------------------------------------------------- /PhpParser/Builder/Property.php: -------------------------------------------------------------------------------- 1 | name = $name; 23 | } 24 | 25 | /** 26 | * Makes the property public. 27 | * 28 | * @return $this The builder instance (for fluid interface) 29 | */ 30 | public function makePublic() { 31 | $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC); 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * Makes the property protected. 38 | * 39 | * @return $this The builder instance (for fluid interface) 40 | */ 41 | public function makeProtected() { 42 | $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED); 43 | 44 | return $this; 45 | } 46 | 47 | /** 48 | * Makes the property private. 49 | * 50 | * @return $this The builder instance (for fluid interface) 51 | */ 52 | public function makePrivate() { 53 | $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE); 54 | 55 | return $this; 56 | } 57 | 58 | /** 59 | * Makes the property static. 60 | * 61 | * @return $this The builder instance (for fluid interface) 62 | */ 63 | public function makeStatic() { 64 | $this->setModifier(Stmt\Class_::MODIFIER_STATIC); 65 | 66 | return $this; 67 | } 68 | 69 | /** 70 | * Sets default value for the property. 71 | * 72 | * @param mixed $value Default value to use 73 | * 74 | * @return $this The builder instance (for fluid interface) 75 | */ 76 | public function setDefault($value) { 77 | $this->default = $this->normalizeValue($value); 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * Sets doc comment for the property. 84 | * 85 | * @param PhpParser\Comment\Doc|string $docComment Doc comment to set 86 | * 87 | * @return $this The builder instance (for fluid interface) 88 | */ 89 | public function setDocComment($docComment) { 90 | $this->attributes = array( 91 | 'comments' => array($this->normalizeDocComment($docComment)) 92 | ); 93 | 94 | return $this; 95 | } 96 | 97 | /** 98 | * Returns the built class node. 99 | * 100 | * @return Stmt\Property The built property node 101 | */ 102 | public function getNode() { 103 | return new Stmt\Property( 104 | $this->type !== 0 ? $this->type : Stmt\Class_::MODIFIER_PUBLIC, 105 | array( 106 | new Stmt\PropertyProperty($this->name, $this->default) 107 | ), 108 | $this->attributes 109 | ); 110 | } 111 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/BuilderFactory.php: -------------------------------------------------------------------------------- 1 | text = $text; 18 | $this->line = $line; 19 | } 20 | 21 | /** 22 | * Gets the comment text. 23 | * 24 | * @return string The comment text (including comment delimiters like /*) 25 | */ 26 | public function getText() { 27 | return $this->text; 28 | } 29 | 30 | /** 31 | * Sets the comment text. 32 | * 33 | * @param string $text The comment text (including comment delimiters like /*) 34 | */ 35 | public function setText($text) { 36 | $this->text = $text; 37 | } 38 | 39 | /** 40 | * Gets the line number the comment started on. 41 | * 42 | * @return int Line number 43 | */ 44 | public function getLine() { 45 | return $this->line; 46 | } 47 | 48 | /** 49 | * Sets the line number the comment started on. 50 | * 51 | * @param int $line Line number 52 | */ 53 | public function setLine($line) { 54 | $this->line = $line; 55 | } 56 | 57 | /** 58 | * Gets the comment text. 59 | * 60 | * @return string The comment text (including comment delimiters like /*) 61 | */ 62 | public function __toString() { 63 | return $this->text; 64 | } 65 | 66 | /** 67 | * Gets the reformatted comment text. 68 | * 69 | * "Reformatted" here means that we try to clean up the whitespace at the 70 | * starts of the lines. This is necessary because we receive the comments 71 | * without trailing whitespace on the first line, but with trailing whitespace 72 | * on all subsequent lines. 73 | * 74 | * @return mixed|string 75 | */ 76 | public function getReformattedText() { 77 | $text = trim($this->text); 78 | if (false === strpos($text, "\n")) { 79 | // Single line comments don't need further processing 80 | return $text; 81 | } elseif (preg_match('((*BSR_ANYCRLF)(*ANYCRLF)^.*(?:\R\s+\*.*)+$)', $text)) { 82 | // Multi line comment of the type 83 | // 84 | // /* 85 | // * Some text. 86 | // * Some more text. 87 | // */ 88 | // 89 | // is handled by replacing the whitespace sequences before the * by a single space 90 | return preg_replace('(^\s+\*)m', ' *', $this->text); 91 | } elseif (preg_match('(^/\*\*?\s*[\r\n])', $text) && preg_match('(\n(\s*)\*/$)', $text, $matches)) { 92 | // Multi line comment of the type 93 | // 94 | // /* 95 | // Some text. 96 | // Some more text. 97 | // */ 98 | // 99 | // is handled by removing the whitespace sequence on the line before the closing 100 | // */ on all lines. So if the last line is " */", then " " is removed at the 101 | // start of all lines. 102 | return preg_replace('(^' . preg_quote($matches[1]) . ')m', '', $text); 103 | } elseif (preg_match('(^/\*\*?\s*(?!\s))', $text, $matches)) { 104 | // Multi line comment of the type 105 | // 106 | // /* Some text. 107 | // Some more text. 108 | // Even more text. */ 109 | // 110 | // is handled by taking the length of the "/* " segment and leaving only that 111 | // many space characters before the lines. Thus in the above example only three 112 | // space characters are left at the start of every line. 113 | return preg_replace('(^\s*(?= {' . strlen($matches[0]) . '}(?!\s)))m', '', $text); 114 | } 115 | 116 | // No idea how to format this comment, so simply return as is 117 | return $text; 118 | } 119 | } -------------------------------------------------------------------------------- /PhpParser/Comment/Doc.php: -------------------------------------------------------------------------------- 1 | rawMessage = (string) $message; 18 | $this->rawLine = (int) $line; 19 | $this->updateMessage(); 20 | } 21 | 22 | /** 23 | * Gets the error message 24 | * 25 | * @return string Error message 26 | */ 27 | public function getRawMessage() { 28 | return $this->rawMessage; 29 | } 30 | 31 | /** 32 | * Sets the line of the PHP file the error occurred in. 33 | * 34 | * @param string $message Error message 35 | */ 36 | public function setRawMessage($message) { 37 | $this->rawMessage = (string) $message; 38 | $this->updateMessage(); 39 | } 40 | 41 | /** 42 | * Gets the error line in the PHP file. 43 | * 44 | * @return int Error line in the PHP file 45 | */ 46 | public function getRawLine() { 47 | return $this->rawLine; 48 | } 49 | 50 | /** 51 | * Sets the line of the PHP file the error occurred in. 52 | * 53 | * @param int $line Error line in the PHP file 54 | */ 55 | public function setRawLine($line) { 56 | $this->rawLine = (int) $line; 57 | $this->updateMessage(); 58 | } 59 | 60 | /** 61 | * Updates the exception message after a change to rawMessage or rawLine. 62 | */ 63 | protected function updateMessage() { 64 | $this->message = $this->rawMessage; 65 | 66 | if (-1 === $this->rawLine) { 67 | $this->message .= ' on unknown line'; 68 | } else { 69 | $this->message .= ' on line ' . $this->rawLine; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /PhpParser/Node.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Array_.php: -------------------------------------------------------------------------------- 1 | items = $items; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('items'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/BooleanNot.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Cast.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Clone_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Closure.php: -------------------------------------------------------------------------------- 1 | false : Whether the closure is static 28 | * 'byRef' => false : Whether to return by reference 29 | * 'params' => array(): Parameters 30 | * 'uses' => array(): use()s 31 | * 'returnType' => null : Return type 32 | * 'stmts' => array(): Statements 33 | * @param array $attributes Additional attributes 34 | */ 35 | public function __construct(array $subNodes = array(), array $attributes = array()) { 36 | parent::__construct(null, $attributes); 37 | $this->static = isset($subNodes['static']) ? $subNodes['static'] : false; 38 | $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; 39 | $this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); 40 | $this->uses = isset($subNodes['uses']) ? $subNodes['uses'] : array(); 41 | $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; 42 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 43 | } 44 | 45 | public function getSubNodeNames() { 46 | return array('static', 'byRef', 'params', 'uses', 'returnType', 'stmts'); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/ConstFetch.php: -------------------------------------------------------------------------------- 1 | name = $name; 22 | } 23 | 24 | public function getSubNodeNames() { 25 | return array('name'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Empty_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/ErrorSuppress.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Eval_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Exit_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Isset_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/List_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/PostDec.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/PostInc.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/PreDec.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/PreInc.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Print_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/ShellExec.php: -------------------------------------------------------------------------------- 1 | parts = $parts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('parts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/UnaryMinus.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/UnaryPlus.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Expr/Variable.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Scalar.php: -------------------------------------------------------------------------------- 1 | value = $value; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('value'); 25 | } 26 | 27 | /** 28 | * @internal 29 | * 30 | * Parses a DNUMBER token like PHP would. 31 | * 32 | * @param string $str A string number 33 | * 34 | * @return float The parsed number 35 | */ 36 | public static function parse($str) { 37 | // if string contains any of .eE just cast it to float 38 | if (false !== strpbrk($str, '.eE')) { 39 | return (float) $str; 40 | } 41 | 42 | // otherwise it's an integer notation that overflowed into a float 43 | // if it starts with 0 it's one of the special integer notations 44 | if ('0' === $str[0]) { 45 | // hex 46 | if ('x' === $str[1] || 'X' === $str[1]) { 47 | return hexdec($str); 48 | } 49 | 50 | // bin 51 | if ('b' === $str[1] || 'B' === $str[1]) { 52 | return bindec($str); 53 | } 54 | 55 | // oct 56 | // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9) 57 | // so that only the digits before that are used 58 | return octdec(substr($str, 0, strcspn($str, '89'))); 59 | } 60 | 61 | // dec 62 | return (float) $str; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /PhpParser/Node/Scalar/Encapsed.php: -------------------------------------------------------------------------------- 1 | parts = $parts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('parts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Scalar/MagicConst.php: -------------------------------------------------------------------------------- 1 | '\\', 14 | '$' => '$', 15 | 'n' => "\n", 16 | 'r' => "\r", 17 | 't' => "\t", 18 | 'f' => "\f", 19 | 'v' => "\v", 20 | 'e' => "\x1B", 21 | ); 22 | 23 | /** 24 | * Constructs a string scalar node. 25 | * 26 | * @param string $value Value of the string 27 | * @param array $attributes Additional attributes 28 | */ 29 | public function __construct($value = '', array $attributes = array()) { 30 | parent::__construct(null, $attributes); 31 | $this->value = $value; 32 | } 33 | 34 | public function getSubNodeNames() { 35 | return array('value'); 36 | } 37 | 38 | /** 39 | * @internal 40 | * 41 | * Parses a string token. 42 | * 43 | * @param string $str String token content 44 | * 45 | * @return string The parsed string 46 | */ 47 | public static function parse($str) { 48 | $bLength = 0; 49 | if ('b' === $str[0]) { 50 | $bLength = 1; 51 | } 52 | 53 | if ('\'' === $str[$bLength]) { 54 | return str_replace( 55 | array('\\\\', '\\\''), 56 | array( '\\', '\''), 57 | substr($str, $bLength + 1, -1) 58 | ); 59 | } else { 60 | return self::parseEscapeSequences(substr($str, $bLength + 1, -1), '"'); 61 | } 62 | } 63 | 64 | /** 65 | * @internal 66 | * 67 | * Parses escape sequences in strings (all string types apart from single quoted). 68 | * 69 | * @param string $str String without quotes 70 | * @param null|string $quote Quote type 71 | * 72 | * @return string String with escape sequences parsed 73 | */ 74 | public static function parseEscapeSequences($str, $quote) { 75 | if (null !== $quote) { 76 | $str = str_replace('\\' . $quote, $quote, $str); 77 | } 78 | 79 | return preg_replace_callback( 80 | '~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~', 81 | array(__CLASS__, 'parseCallback'), 82 | $str 83 | ); 84 | } 85 | 86 | private static function parseCallback($matches) { 87 | $str = $matches[1]; 88 | 89 | if (isset(self::$replacements[$str])) { 90 | return self::$replacements[$str]; 91 | } elseif ('x' === $str[0] || 'X' === $str[0]) { 92 | return chr(hexdec($str)); 93 | } else { 94 | return chr(octdec($str)); 95 | } 96 | } 97 | 98 | /** 99 | * @internal 100 | * 101 | * Parses a constant doc string. 102 | * 103 | * @param string $startToken Doc string start token content (<<num = $num; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('num'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/ClassConst.php: -------------------------------------------------------------------------------- 1 | consts = $consts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('consts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/ClassMethod.php: -------------------------------------------------------------------------------- 1 | MODIFIER_PUBLIC: Type 29 | * 'byRef' => false : Whether to return by reference 30 | * 'params' => array() : Parameters 31 | * 'returnType' => null : Return type 32 | * 'stmts' => array() : Statements 33 | * @param array $attributes Additional attributes 34 | */ 35 | public function __construct($name, array $subNodes = array(), array $attributes = array()) { 36 | parent::__construct(null, $attributes); 37 | $this->type = isset($subNodes['type']) ? $subNodes['type'] : 0; 38 | $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; 39 | $this->name = $name; 40 | $this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); 41 | $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; 42 | $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array(); 43 | 44 | if ($this->type & Class_::MODIFIER_STATIC) { 45 | switch (strtolower($this->name)) { 46 | case '__construct': 47 | throw new Error(sprintf('Constructor %s() cannot be static', $this->name)); 48 | case '__destruct': 49 | throw new Error(sprintf('Destructor %s() cannot be static', $this->name)); 50 | case '__clone': 51 | throw new Error(sprintf('Clone method %s() cannot be static', $this->name)); 52 | } 53 | } 54 | } 55 | 56 | public function getSubNodeNames() { 57 | return array('type', 'byRef', 'name', 'params', 'returnType', 'stmts'); 58 | } 59 | 60 | public function isPublic() { 61 | return ($this->type & Class_::MODIFIER_PUBLIC) !== 0 || $this->type === 0; 62 | } 63 | 64 | public function isProtected() { 65 | return (bool) ($this->type & Class_::MODIFIER_PROTECTED); 66 | } 67 | 68 | public function isPrivate() { 69 | return (bool) ($this->type & Class_::MODIFIER_PRIVATE); 70 | } 71 | 72 | public function isAbstract() { 73 | return (bool) ($this->type & Class_::MODIFIER_ABSTRACT); 74 | } 75 | 76 | public function isFinal() { 77 | return (bool) ($this->type & Class_::MODIFIER_FINAL); 78 | } 79 | 80 | public function isStatic() { 81 | return (bool) ($this->type & Class_::MODIFIER_STATIC); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Class_.php: -------------------------------------------------------------------------------- 1 | true, 28 | 'parent' => true, 29 | 'static' => true, 30 | ); 31 | 32 | /** 33 | * Constructs a class node. 34 | * 35 | * @param string $name Name 36 | * @param array $subNodes Array of the following optional subnodes: 37 | * 'type' => 0 : Type 38 | * 'extends' => null : Name of extended class 39 | * 'implements' => array(): Names of implemented interfaces 40 | * 'stmts' => array(): Statements 41 | * @param array $attributes Additional attributes 42 | */ 43 | public function __construct($name, array $subNodes = array(), array $attributes = array()) { 44 | parent::__construct(null, $attributes); 45 | $this->type = isset($subNodes['type']) ? $subNodes['type'] : 0; 46 | $this->name = $name; 47 | $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : null; 48 | $this->implements = isset($subNodes['implements']) ? $subNodes['implements'] : array(); 49 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 50 | 51 | if (isset(self::$specialNames[(string) $this->name])) { 52 | throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->name)); 53 | } 54 | 55 | if (isset(self::$specialNames[(string) $this->extends])) { 56 | throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->extends)); 57 | } 58 | 59 | foreach ($this->implements as $interface) { 60 | if (isset(self::$specialNames[(string) $interface])) { 61 | throw new Error(sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface)); 62 | } 63 | } 64 | } 65 | 66 | public function getSubNodeNames() { 67 | return array('type', 'name', 'extends', 'implements', 'stmts'); 68 | } 69 | 70 | public function isAbstract() { 71 | return (bool) ($this->type & self::MODIFIER_ABSTRACT); 72 | } 73 | 74 | public function isFinal() { 75 | return (bool) ($this->type & self::MODIFIER_FINAL); 76 | } 77 | 78 | /** 79 | * @internal 80 | */ 81 | public static function verifyModifier($a, $b) { 82 | if ($a & self::VISIBILITY_MODIFER_MASK && $b & self::VISIBILITY_MODIFER_MASK) { 83 | throw new Error('Multiple access type modifiers are not allowed'); 84 | } 85 | 86 | if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) { 87 | throw new Error('Multiple abstract modifiers are not allowed'); 88 | } 89 | 90 | if ($a & self::MODIFIER_STATIC && $b & self::MODIFIER_STATIC) { 91 | throw new Error('Multiple static modifiers are not allowed'); 92 | } 93 | 94 | if ($a & self::MODIFIER_FINAL && $b & self::MODIFIER_FINAL) { 95 | throw new Error('Multiple final modifiers are not allowed'); 96 | } 97 | 98 | if ($a & 48 && $b & 48) { 99 | throw new Error('Cannot use the final modifier on an abstract class member'); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Const_.php: -------------------------------------------------------------------------------- 1 | consts = $consts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('consts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Continue_.php: -------------------------------------------------------------------------------- 1 | num = $num; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('num'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Echo_.php: -------------------------------------------------------------------------------- 1 | exprs = $exprs; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('exprs'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Else_.php: -------------------------------------------------------------------------------- 1 | stmts = $stmts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('stmts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Global_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Goto_.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/HaltCompiler.php: -------------------------------------------------------------------------------- 1 | remaining = $remaining; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('remaining'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/InlineHTML.php: -------------------------------------------------------------------------------- 1 | value = $value; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('value'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Label.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Return_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Static_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Throw_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/Node/Stmt/Unset_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PhpParser/NodeAbstract.php: -------------------------------------------------------------------------------- 1 | attributes = $attributes; 24 | 25 | if (null !== $subNodes) { 26 | foreach ($subNodes as $name => $value) { 27 | $this->$name = $value; 28 | } 29 | $this->subNodeNames = array_keys($subNodes); 30 | } 31 | } 32 | 33 | /** 34 | * Gets the type of the node. 35 | * 36 | * @return string Type of the node 37 | */ 38 | public function getType() { 39 | return strtr(substr(rtrim(get_class($this), '_'), 15), '\\', '_'); 40 | } 41 | 42 | /** 43 | * Gets the names of the sub nodes. 44 | * 45 | * @return array Names of sub nodes 46 | */ 47 | public function getSubNodeNames() { 48 | return $this->subNodeNames; 49 | } 50 | 51 | /** 52 | * Gets line the node started in. 53 | * 54 | * @return int Line 55 | */ 56 | public function getLine() { 57 | return $this->getAttribute('startLine', -1); 58 | } 59 | 60 | /** 61 | * Sets line the node started in. 62 | * 63 | * @param int $line Line 64 | */ 65 | public function setLine($line) { 66 | $this->setAttribute('startLine', (int) $line); 67 | } 68 | 69 | /** 70 | * Gets the doc comment of the node. 71 | * 72 | * The doc comment has to be the last comment associated with the node. 73 | * 74 | * @return null|Comment\Doc Doc comment object or null 75 | */ 76 | public function getDocComment() { 77 | $comments = $this->getAttribute('comments'); 78 | if (!$comments) { 79 | return null; 80 | } 81 | 82 | $lastComment = $comments[count($comments) - 1]; 83 | if (!$lastComment instanceof Comment\Doc) { 84 | return null; 85 | } 86 | 87 | return $lastComment; 88 | } 89 | 90 | /** 91 | * {@inheritDoc} 92 | */ 93 | public function setAttribute($key, $value) { 94 | $this->attributes[$key] = $value; 95 | } 96 | 97 | /** 98 | * {@inheritDoc} 99 | */ 100 | public function hasAttribute($key) { 101 | return array_key_exists($key, $this->attributes); 102 | } 103 | 104 | /** 105 | * {@inheritDoc} 106 | */ 107 | public function &getAttribute($key, $default = null) { 108 | if (!array_key_exists($key, $this->attributes)) { 109 | return $default; 110 | } else { 111 | return $this->attributes[$key]; 112 | } 113 | } 114 | 115 | /** 116 | * {@inheritDoc} 117 | */ 118 | public function getAttributes() { 119 | return $this->attributes; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /PhpParser/NodeDumper.php: -------------------------------------------------------------------------------- 1 | getType() . '('; 17 | 18 | foreach ($node->getSubNodeNames() as $key) { 19 | $r .= "\n " . $key . ': '; 20 | 21 | $value = $node->$key; 22 | if (null === $value) { 23 | $r .= 'null'; 24 | } elseif (false === $value) { 25 | $r .= 'false'; 26 | } elseif (true === $value) { 27 | $r .= 'true'; 28 | } elseif (is_scalar($value)) { 29 | $r .= $value; 30 | } else { 31 | $r .= str_replace("\n", "\n ", $this->dump($value)); 32 | } 33 | } 34 | } elseif (is_array($node)) { 35 | $r = 'array('; 36 | 37 | foreach ($node as $key => $value) { 38 | $r .= "\n " . $key . ': '; 39 | 40 | if (null === $value) { 41 | $r .= 'null'; 42 | } elseif (false === $value) { 43 | $r .= 'false'; 44 | } elseif (true === $value) { 45 | $r .= 'true'; 46 | } elseif (is_scalar($value)) { 47 | $r .= $value; 48 | } else { 49 | $r .= str_replace("\n", "\n ", $this->dump($value)); 50 | } 51 | } 52 | } else { 53 | throw new \InvalidArgumentException('Can only dump nodes and arrays.'); 54 | } 55 | 56 | return $r . "\n)"; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /PhpParser/NodeTraverserInterface.php: -------------------------------------------------------------------------------- 1 | writer = new XMLWriter; 19 | $this->writer->openMemory(); 20 | $this->writer->setIndent(true); 21 | } 22 | 23 | public function serialize(array $nodes) { 24 | $this->writer->flush(); 25 | $this->writer->startDocument('1.0', 'UTF-8'); 26 | 27 | $this->writer->startElement('AST'); 28 | $this->writer->writeAttribute('xmlns:node', 'http://nikic.github.com/PHPParser/XML/node'); 29 | $this->writer->writeAttribute('xmlns:subNode', 'http://nikic.github.com/PHPParser/XML/subNode'); 30 | $this->writer->writeAttribute('xmlns:attribute', 'http://nikic.github.com/PHPParser/XML/attribute'); 31 | $this->writer->writeAttribute('xmlns:scalar', 'http://nikic.github.com/PHPParser/XML/scalar'); 32 | 33 | $this->_serialize($nodes); 34 | 35 | $this->writer->endElement(); 36 | 37 | return $this->writer->outputMemory(); 38 | } 39 | 40 | protected function _serialize($node) { 41 | if ($node instanceof Node) { 42 | $this->writer->startElement('node:' . $node->getType()); 43 | 44 | foreach ($node->getAttributes() as $name => $value) { 45 | $this->writer->startElement('attribute:' . $name); 46 | $this->_serialize($value); 47 | $this->writer->endElement(); 48 | } 49 | 50 | foreach ($node as $name => $subNode) { 51 | $this->writer->startElement('subNode:' . $name); 52 | $this->_serialize($subNode); 53 | $this->writer->endElement(); 54 | } 55 | 56 | $this->writer->endElement(); 57 | } elseif ($node instanceof Comment) { 58 | $this->writer->startElement('comment'); 59 | $this->writer->writeAttribute('isDocComment', $node instanceof Comment\Doc ? 'true' : 'false'); 60 | $this->writer->writeAttribute('line', (string) $node->getLine()); 61 | $this->writer->text($node->getText()); 62 | $this->writer->endElement(); 63 | } elseif (is_array($node)) { 64 | $this->writer->startElement('scalar:array'); 65 | foreach ($node as $subNode) { 66 | $this->_serialize($subNode); 67 | } 68 | $this->writer->endElement(); 69 | } elseif (is_string($node)) { 70 | $this->writer->writeElement('scalar:string', $node); 71 | } elseif (is_int($node)) { 72 | $this->writer->writeElement('scalar:int', (string) $node); 73 | } elseif (is_float($node)) { 74 | // TODO Higher precision conversion? 75 | $this->writer->writeElement('scalar:float', (string) $node); 76 | } elseif (true === $node) { 77 | $this->writer->writeElement('scalar:true'); 78 | } elseif (false === $node) { 79 | $this->writer->writeElement('scalar:false'); 80 | } elseif (null === $node) { 81 | $this->writer->writeElement('scalar:null'); 82 | } else { 83 | throw new \InvalidArgumentException('Unexpected node type'); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /PhpParser/Unserializer.php: -------------------------------------------------------------------------------- 1 | "); 50 | if (!defined('CDXC_TITLE_END')) define('CDXC_TITLE_END', ""); 51 | if (!defined('CDXC_CONTENT_START')) define('CDXC_CONTENT_START', "

"); 52 | if (!defined('CDXC_CONTENT_END')) define('CDXC_CONTENT_END', "

"); 53 | 54 | if (!defined('CDXC_PHP_CODE_START')) define('CDXC_PHP_CODE_START', "
");
 55 |     if (!defined('CDXC_PHP_CODE_END')) define('CDXC_PHP_CODE_END', "
"); 56 | 57 | if (!defined('CDXC_SAMPLE_OPEN')) define('CDXC_SAMPLE_OPEN', "
");
 58 |     if (!defined('CDXC_SAMPLE_CLOSE')) define('CDXC_SAMPLE_CLOSE', "
"); 59 | } 60 | 61 | add_action('plugins_loaded', 'cdxc_define_constants'); 62 | 63 | 64 | /** 65 | * Autoloads the phpDocumentor and PhpParser class files. 66 | * 67 | * @since 1.0.0 68 | * @package Codex_Creator 69 | * @param string $className The class name as a file path. 70 | */ 71 | function cdxc_autoload($className) 72 | { 73 | 74 | if (strpos($className, 'phpDocumentor\\') === false && strpos($className, 'PhpParser\\') === false) { 75 | return; 76 | } 77 | 78 | $fileName = ''; 79 | $namespace = ''; 80 | if ($lastNsPos = strripos($className, '\\')) { 81 | $namespace = substr($className, 0, $lastNsPos); 82 | $className = substr($className, $lastNsPos + 1); 83 | $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; 84 | } 85 | 86 | if (substr($className, -1) == '_') { 87 | //if (strpos($className,'_.php') === false){ 88 | $fileName = $fileName . $className . '.php'; 89 | } else { 90 | $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; 91 | } 92 | 93 | 94 | require $fileName; 95 | } 96 | 97 | spl_autoload_register('cdxc_autoload'); 98 | 99 | 100 | /** 101 | * Include CPT files. 102 | */ 103 | include_once('lib/setup_cpt.php'); 104 | 105 | /** 106 | * Setup section in WordPress tools. 107 | */ 108 | include_once('lib/setup_section.php'); 109 | 110 | /** 111 | * Codex Creator content output functions. 112 | */ 113 | include_once('lib/content_output_functions.php'); 114 | 115 | /** 116 | * Codex Creator general functions. 117 | */ 118 | include_once('lib/general_functions.php'); 119 | 120 | /** 121 | * Codex Creator general functions. 122 | */ 123 | include_once('lib/helper_functions.php'); 124 | 125 | /** 126 | * Codex Creator file functions. 127 | */ 128 | include_once('lib/file_functions.php'); 129 | 130 | /** 131 | * Codex Creator file functions. 132 | */ 133 | include_once('lib/add_meta_boxes.php'); 134 | 135 | /** 136 | * Codex Creator cron functions. 137 | */ 138 | include_once('lib/cron_functions.php'); 139 | 140 | /** 141 | * Codex Creator Bitbucket functions. 142 | */ 143 | include_once('lib/bitbucket_functions.php'); -------------------------------------------------------------------------------- /css/codex_creator.css: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS for the backend 3 | * 4 | * @since 1.0.0 5 | * @package Codex_Creator 6 | */ 7 | 8 | .codex-creator-wrap { 9 | position: relative; 10 | overflow: auto; 11 | margin: 16px 0; 12 | padding: 0px 10px 0; 13 | border: 1px solid #e5e5e5; 14 | -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .04); 15 | box-shadow: 0 1px 1px rgba(0, 0, 0, .04); 16 | background: #fff; 17 | font-size: 13px; 18 | line-height: 2.1em; 19 | } 20 | 21 | .codex-creator-step-content { 22 | display: none; 23 | } 24 | 25 | .cc-active .codex-creator-step-content { 26 | display: block; 27 | } 28 | 29 | .cc-code-bits-tree, 30 | .cc-file-tree .cc-file-tree { 31 | padding-left: 15px; 32 | } 33 | 34 | .cc-file-tree .cc-file-tree-folder { 35 | 36 | } 37 | 38 | .cc-file-tree-action, 39 | .cc-file-tree-filter, 40 | .cc-file-tree-function, 41 | .cc-file-tree-file { 42 | border: 1px solid #ccc; 43 | padding: 0px 5px; 44 | } 45 | 46 | .cc-action-info-bloc, 47 | .cc-filter-info-bloc, 48 | .cc-file-info-bloc, 49 | .cc-function-info-bloc { 50 | float: right; 51 | } 52 | 53 | /* 54 | * Admin meta boxes 55 | */ 56 | 57 | #cdxc_meta_box textarea { 58 | width: 100%; 59 | height: 65px; 60 | } 61 | 62 | #cdxc_meta_box input { 63 | width: 100%; 64 | } 65 | 66 | #cdxc_meta_box label { 67 | font-weight: bold; 68 | } 69 | 70 | .codex-creator-step-2 .codex-creator-step-content .cc-plugin-theme-list { 71 | display: table-caption; 72 | margin-bottom: 3px; 73 | } 74 | 75 | .codex-creator-wrap .fa-exclamation-triangle { 76 | color: #ff0000 77 | } 78 | 79 | /* 80 | * Loading div styles 81 | */ 82 | 83 | .cc-loading-div { 84 | height: 20px; 85 | margin-bottom: 20px; 86 | overflow: hidden; 87 | background-color: #f5f5f5; 88 | border-radius: 4px; 89 | -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); 90 | box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); 91 | box-sizing: border-box; 92 | } 93 | 94 | .cc-loading-progress { 95 | float: left; 96 | width: 0; 97 | height: 100%; 98 | font-size: 12px; 99 | line-height: 20px; 100 | color: #fff; 101 | text-align: center; 102 | background-color: #337ab7; 103 | -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); 104 | box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); 105 | -webkit-transition: width .6s ease; 106 | -o-transition: width .6s ease; 107 | transition: width .6s ease; 108 | box-sizing: border-box; 109 | } 110 | 111 | .cc-loading-progress-striped { 112 | background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 113 | background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 114 | background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 115 | -webkit-background-size: 40px 40px; 116 | background-size: 40px 40px; 117 | } 118 | 119 | .cc-loading-progress.cc-active { 120 | -webkit-animation: cc-loading-progress-striped 2s linear infinite; 121 | -o-animation: cc-loading-progress-striped 2s linear infinite; 122 | animation: cc-loading-progress-striped 2s linear infinite 123 | } 124 | 125 | @-webkit-keyframes cc-loading-progress-striped { 126 | from { 127 | background-position: 40px 0 128 | } 129 | to { 130 | background-position: 0 0 131 | } 132 | } 133 | 134 | @-o-keyframes cc-loading-progress-striped { 135 | from { 136 | background-position: 40px 0 137 | } 138 | to { 139 | background-position: 0 0 140 | } 141 | } 142 | 143 | @keyframes cc-loading-progress-striped { 144 | from { 145 | background-position: 40px 0 146 | } 147 | to { 148 | background-position: 0 0 149 | } 150 | } -------------------------------------------------------------------------------- /lib/ajax_functions.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock; 14 | 15 | /** 16 | * The location a DocBlock occurs within a file. 17 | * 18 | * @author Vasil Rangelov 19 | * @license http://www.opensource.org/licenses/mit-license.php MIT 20 | * @link http://phpdoc.org 21 | */ 22 | class Location 23 | { 24 | /** @var int Line where the DocBlock text starts. */ 25 | protected $lineNumber = 0; 26 | 27 | /** @var int Column where the DocBlock text starts. */ 28 | protected $columnNumber = 0; 29 | 30 | public function __construct($lineNumber = 0, $columnNumber = 0) 31 | { 32 | $this->setLineNumber($lineNumber)->setColumnNumber($columnNumber); 33 | } 34 | 35 | /** 36 | * Returns the line number that is covered by this location. 37 | * 38 | * @return integer 39 | */ 40 | public function getLineNumber() 41 | { 42 | return $this->lineNumber; 43 | } 44 | 45 | /** 46 | * Registers which line number is covered by this location object. 47 | * 48 | * @param integer $lineNumber 49 | * 50 | * @return $this 51 | */ 52 | public function setLineNumber($lineNumber) 53 | { 54 | $this->lineNumber = (int)$lineNumber; 55 | 56 | return $this; 57 | } 58 | 59 | /** 60 | * Returns the column number (character position on a line) for this location object. 61 | * 62 | * @return integer 63 | */ 64 | public function getColumnNumber() 65 | { 66 | return $this->columnNumber; 67 | } 68 | 69 | /** 70 | * Registers the column number (character position on a line) for this location object. 71 | * 72 | * @param integer $columnNumber 73 | * 74 | * @return $this 75 | */ 76 | public function setColumnNumber($columnNumber) 77 | { 78 | $this->columnNumber = (int)$columnNumber; 79 | 80 | return $this; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/AuthorTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag; 16 | 17 | /** 18 | * Reflection class for an @author tag in a Docblock. 19 | * 20 | * @author Mike van Riel 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class AuthorTag extends Tag 25 | { 26 | /** 27 | * PCRE regular expression matching any valid value for the name component. 28 | */ 29 | const REGEX_AUTHOR_NAME = '[^\<]*'; 30 | 31 | /** 32 | * PCRE regular expression matching any valid value for the email component. 33 | */ 34 | const REGEX_AUTHOR_EMAIL = '[^\>]*'; 35 | 36 | /** @var string The name of the author */ 37 | protected $authorName = ''; 38 | 39 | /** @var string The email of the author */ 40 | protected $authorEmail = ''; 41 | 42 | public function getContent() 43 | { 44 | if (null === $this->content) { 45 | $this->content = $this->authorName; 46 | if ('' != $this->authorEmail) { 47 | $this->content .= "<{$this->authorEmail}>"; 48 | } 49 | } 50 | 51 | return $this->content; 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | public function setContent($content) 58 | { 59 | parent::setContent($content); 60 | if (preg_match( 61 | '/^(' . self::REGEX_AUTHOR_NAME . 62 | ')(\<(' . self::REGEX_AUTHOR_EMAIL . 63 | ')\>)?$/u', 64 | $this->description, 65 | $matches 66 | )) { 67 | $this->authorName = trim($matches[1]); 68 | if (isset($matches[3])) { 69 | $this->authorEmail = trim($matches[3]); 70 | } 71 | } 72 | 73 | return $this; 74 | } 75 | 76 | /** 77 | * Gets the author's name. 78 | * 79 | * @return string The author's name. 80 | */ 81 | public function getAuthorName() 82 | { 83 | return $this->authorName; 84 | } 85 | 86 | /** 87 | * Sets the author's name. 88 | * 89 | * @param string $authorName The new author name. 90 | * An invalid value will set an empty string. 91 | * 92 | * @return $this 93 | */ 94 | public function setAuthorName($authorName) 95 | { 96 | $this->content = null; 97 | $this->authorName 98 | = preg_match('/^' . self::REGEX_AUTHOR_NAME . '$/u', $authorName) 99 | ? $authorName : ''; 100 | 101 | return $this; 102 | } 103 | 104 | /** 105 | * Gets the author's email. 106 | * 107 | * @return string The author's email. 108 | */ 109 | public function getAuthorEmail() 110 | { 111 | return $this->authorEmail; 112 | } 113 | 114 | /** 115 | * Sets the author's email. 116 | * 117 | * @param string $authorEmail The new author email. 118 | * An invalid value will set an empty string. 119 | * 120 | * @return $this 121 | */ 122 | public function setAuthorEmail($authorEmail) 123 | { 124 | $this->authorEmail 125 | = preg_match('/^' . self::REGEX_AUTHOR_EMAIL . '$/u', $authorEmail) 126 | ? $authorEmail : ''; 127 | 128 | $this->content = null; 129 | return $this; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/CoversTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | /** 16 | * Reflection class for a @covers tag in a Docblock. 17 | * 18 | * @author Mike van Riel 19 | * @license http://www.opensource.org/licenses/mit-license.php MIT 20 | * @link http://phpdoc.org 21 | */ 22 | class CoversTag extends SeeTag 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/DeprecatedTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag\VersionTag; 16 | 17 | /** 18 | * Reflection class for a @deprecated tag in a Docblock. 19 | * 20 | * @author Vasil Rangelov 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class DeprecatedTag extends VersionTag 25 | { 26 | } 27 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/ExampleTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag; 16 | 17 | /** 18 | * Reflection class for a @example tag in a Docblock. 19 | * 20 | * @author Vasil Rangelov 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class ExampleTag extends SourceTag 25 | { 26 | /** 27 | * @var string Path to a file to use as an example. 28 | * May also be an absolute URI. 29 | */ 30 | protected $filePath = ''; 31 | 32 | /** 33 | * @var bool Whether the file path component represents an URI. 34 | * This determines how the file portion appears at {@link getContent()}. 35 | */ 36 | protected $isURI = false; 37 | 38 | /** 39 | * {@inheritdoc} 40 | */ 41 | public function getContent() 42 | { 43 | if (null === $this->content) { 44 | $filePath = '"' . $this->filePath . '"'; 45 | if ($this->isURI) { 46 | $filePath = $this->isUriRelative($this->filePath) 47 | ? str_replace('%2F', '/', rawurlencode($this->filePath)) 48 | : $this->filePath; 49 | } 50 | 51 | $this->content = $filePath . ' ' . parent::getContent(); 52 | } 53 | 54 | return $this->content; 55 | } 56 | 57 | /** 58 | * {@inheritdoc} 59 | */ 60 | public function setContent($content) 61 | { 62 | Tag::setContent($content); 63 | if (preg_match( 64 | '/^ 65 | # File component 66 | (?: 67 | # File path in quotes 68 | \"([^\"]+)\" 69 | | 70 | # File URI 71 | (\S+) 72 | ) 73 | # Remaining content (parsed by SourceTag) 74 | (?:\s+(.*))? 75 | $/sux', 76 | $this->description, 77 | $matches 78 | )) { 79 | if ('' !== $matches[1]) { 80 | $this->setFilePath($matches[1]); 81 | } else { 82 | $this->setFileURI($matches[2]); 83 | } 84 | 85 | if (isset($matches[3])) { 86 | parent::setContent($matches[3]); 87 | } else { 88 | $this->setDescription(''); 89 | } 90 | $this->content = $content; 91 | } 92 | 93 | return $this; 94 | } 95 | 96 | /** 97 | * Returns the file path. 98 | * 99 | * @return string Path to a file to use as an example. 100 | * May also be an absolute URI. 101 | */ 102 | public function getFilePath() 103 | { 104 | return $this->filePath; 105 | } 106 | 107 | /** 108 | * Sets the file path. 109 | * 110 | * @param string $filePath The new file path to use for the example. 111 | * 112 | * @return $this 113 | */ 114 | public function setFilePath($filePath) 115 | { 116 | $this->isURI = false; 117 | $this->filePath = trim($filePath); 118 | 119 | $this->content = null; 120 | return $this; 121 | } 122 | 123 | /** 124 | * Sets the file path as an URI. 125 | * 126 | * This function is equivalent to {@link setFilePath()}, except that it 127 | * converts an URI to a file path before that. 128 | * 129 | * There is no getFileURI(), as {@link getFilePath()} is compatible. 130 | * 131 | * @param string $uri The new file URI to use as an example. 132 | * 133 | * @return $this 134 | */ 135 | public function setFileURI($uri) 136 | { 137 | $this->isURI = true; 138 | $this->content = null; 139 | 140 | $this->filePath = $this->isUriRelative($uri) 141 | ? rawurldecode(str_replace(array('/', '\\'), '%2F', $uri)) 142 | : $this->filePath = $uri; 143 | 144 | return $this; 145 | } 146 | 147 | /** 148 | * Returns true if the provided URI is relative or contains a complete scheme (and thus is absolute). 149 | * 150 | * @param string $uri 151 | * 152 | * @return bool 153 | */ 154 | private function isUriRelative($uri) 155 | { 156 | return false === strpos($uri, ':'); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/LinkTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag; 16 | 17 | /** 18 | * Reflection class for a @link tag in a Docblock. 19 | * 20 | * @author Ben Selby 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class LinkTag extends Tag 25 | { 26 | /** @var string */ 27 | protected $link = ''; 28 | 29 | /** 30 | * {@inheritdoc} 31 | */ 32 | public function getContent() 33 | { 34 | if (null === $this->content) { 35 | $this->content = "{$this->link} {$this->description}"; 36 | } 37 | 38 | return $this->content; 39 | } 40 | 41 | /** 42 | * {@inheritdoc} 43 | */ 44 | public function setContent($content) 45 | { 46 | parent::setContent($content); 47 | $parts = preg_split('/\s+/Su', $this->description, 2); 48 | 49 | $this->link = $parts[0]; 50 | 51 | $this->setDescription(isset($parts[1]) ? $parts[1] : $parts[0]); 52 | 53 | $this->content = $content; 54 | return $this; 55 | } 56 | 57 | /** 58 | * Gets the link 59 | * 60 | * @return string 61 | */ 62 | public function getLink() 63 | { 64 | return $this->link; 65 | } 66 | 67 | /** 68 | * Sets the link 69 | * 70 | * @param string $link The link 71 | * 72 | * @return $this 73 | */ 74 | public function setLink($link) 75 | { 76 | $this->link = $link; 77 | 78 | $this->content = null; 79 | return $this; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag; 16 | 17 | /** 18 | * Reflection class for a @param tag in a Docblock. 19 | * 20 | * @author Mike van Riel 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class ParamTag extends ReturnTag 25 | { 26 | /** @var string */ 27 | protected $variableName = ''; 28 | 29 | /** @var bool determines whether this is a variadic argument */ 30 | protected $isVariadic = false; 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | public function getContent() 36 | { 37 | if (null === $this->content) { 38 | $this->content 39 | = "{$this->type} {$this->variableName} {$this->description}"; 40 | } 41 | return $this->content; 42 | } 43 | 44 | /** 45 | * {@inheritdoc} 46 | */ 47 | public function setContent($content) 48 | { 49 | Tag::setContent($content); 50 | $parts = preg_split( 51 | '/(\s+)/Su', 52 | $this->description, 53 | 3, 54 | PREG_SPLIT_DELIM_CAPTURE 55 | ); 56 | 57 | // if the first item that is encountered is not a variable; it is a type 58 | if (isset($parts[0]) 59 | && (strlen($parts[0]) > 0) 60 | && ($parts[0][0] !== '$') 61 | ) { 62 | $this->type = array_shift($parts); 63 | array_shift($parts); 64 | } 65 | 66 | // if the next item starts with a $ or ...$ it must be the variable name 67 | if (isset($parts[0]) 68 | && (strlen($parts[0]) > 0) 69 | && ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$') 70 | ) { 71 | $this->variableName = array_shift($parts); 72 | array_shift($parts); 73 | 74 | if (substr($this->variableName, 0, 3) === '...') { 75 | $this->isVariadic = true; 76 | $this->variableName = substr($this->variableName, 3); 77 | } 78 | } 79 | 80 | $this->setDescription(implode('', $parts)); 81 | 82 | $this->content = $content; 83 | return $this; 84 | } 85 | 86 | /** 87 | * Returns the variable's name. 88 | * 89 | * @return string 90 | */ 91 | public function getVariableName() 92 | { 93 | return $this->variableName; 94 | } 95 | 96 | /** 97 | * Sets the variable's name. 98 | * 99 | * @param string $name The new name for this variable. 100 | * 101 | * @return $this 102 | */ 103 | public function setVariableName($name) 104 | { 105 | $this->variableName = $name; 106 | 107 | $this->content = null; 108 | return $this; 109 | } 110 | 111 | /** 112 | * Returns whether this tag is variadic. 113 | * 114 | * @return boolean 115 | */ 116 | public function isVariadic() 117 | { 118 | return $this->isVariadic; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/PropertyReadTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | /** 16 | * Reflection class for a @property-read tag in a Docblock. 17 | * 18 | * @author Mike van Riel 19 | * @license http://www.opensource.org/licenses/mit-license.php MIT 20 | * @link http://phpdoc.org 21 | */ 22 | class PropertyReadTag extends PropertyTag 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/PropertyTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | /** 16 | * Reflection class for a @property tag in a Docblock. 17 | * 18 | * @author Mike van Riel 19 | * @license http://www.opensource.org/licenses/mit-license.php MIT 20 | * @link http://phpdoc.org 21 | */ 22 | class PropertyTag extends ParamTag 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/PropertyWriteTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | /** 16 | * Reflection class for a @property-write tag in a Docblock. 17 | * 18 | * @author Mike van Riel 19 | * @license http://www.opensource.org/licenses/mit-license.php MIT 20 | * @link http://phpdoc.org 21 | */ 22 | class PropertyWriteTag extends PropertyTag 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/ReturnTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag; 16 | use phpDocumentor\Reflection\DocBlock\Type\Collection; 17 | 18 | /** 19 | * Reflection class for a @return tag in a Docblock. 20 | * 21 | * @author Mike van Riel 22 | * @license http://www.opensource.org/licenses/mit-license.php MIT 23 | * @link http://phpdoc.org 24 | */ 25 | class ReturnTag extends Tag 26 | { 27 | /** @var string The raw type component. */ 28 | protected $type = ''; 29 | 30 | /** @var Collection The parsed type component. */ 31 | protected $types = null; 32 | 33 | /** 34 | * {@inheritdoc} 35 | */ 36 | public function getContent() 37 | { 38 | if (null === $this->content) { 39 | $this->content = "{$this->type} {$this->description}"; 40 | } 41 | 42 | return $this->content; 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | */ 48 | public function setContent($content) 49 | { 50 | parent::setContent($content); 51 | 52 | $parts = preg_split('/\s+/Su', $this->description, 2); 53 | 54 | // any output is considered a type 55 | $this->type = $parts[0]; 56 | $this->types = null; 57 | 58 | $this->setDescription(isset($parts[1]) ? $parts[1] : ''); 59 | 60 | $this->content = $content; 61 | return $this; 62 | } 63 | 64 | /** 65 | * Returns the unique types of the variable. 66 | * 67 | * @return string[] 68 | */ 69 | public function getTypes() 70 | { 71 | return $this->getTypesCollection()->getArrayCopy(); 72 | } 73 | 74 | /** 75 | * Returns the type section of the variable. 76 | * 77 | * @return string 78 | */ 79 | public function getType() 80 | { 81 | return (string)$this->getTypesCollection(); 82 | } 83 | 84 | /** 85 | * Returns the type collection. 86 | * 87 | * @return void 88 | */ 89 | protected function getTypesCollection() 90 | { 91 | if (null === $this->types) { 92 | $this->types = new Collection( 93 | array($this->type), 94 | $this->docblock ? $this->docblock->getContext() : null 95 | ); 96 | } 97 | return $this->types; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/SeeTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag; 16 | 17 | /** 18 | * Reflection class for a @see tag in a Docblock. 19 | * 20 | * @author Mike van Riel 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class SeeTag extends Tag 25 | { 26 | /** @var string */ 27 | protected $refers = null; 28 | 29 | /** 30 | * {@inheritdoc} 31 | */ 32 | public function getContent() 33 | { 34 | if (null === $this->content) { 35 | $this->content = "{$this->refers} {$this->description}"; 36 | } 37 | return $this->content; 38 | } 39 | 40 | /** 41 | * {@inheritdoc} 42 | */ 43 | public function setContent($content) 44 | { 45 | parent::setContent($content); 46 | $parts = preg_split('/\s+/Su', $this->description, 2); 47 | 48 | // any output is considered a type 49 | $this->refers = $parts[0]; 50 | 51 | $this->setDescription(isset($parts[1]) ? $parts[1] : ''); 52 | 53 | $this->content = $content; 54 | return $this; 55 | } 56 | 57 | /** 58 | * Gets the structural element this tag refers to. 59 | * 60 | * @return string 61 | */ 62 | public function getReference() 63 | { 64 | return $this->refers; 65 | } 66 | 67 | /** 68 | * Sets the structural element this tag refers to. 69 | * 70 | * @param string $refers The new type this tag refers to. 71 | * 72 | * @return $this 73 | */ 74 | public function setReference($refers) 75 | { 76 | $this->refers = $refers; 77 | 78 | $this->content = null; 79 | return $this; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/SinceTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag\VersionTag; 16 | 17 | /** 18 | * Reflection class for a @since tag in a Docblock. 19 | * 20 | * @author Vasil Rangelov 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class SinceTag extends VersionTag 25 | { 26 | } 27 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/SourceTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag; 16 | 17 | /** 18 | * Reflection class for a @source tag in a Docblock. 19 | * 20 | * @author Vasil Rangelov 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class SourceTag extends Tag 25 | { 26 | /** 27 | * @var int The starting line, relative to the structural element's 28 | * location. 29 | */ 30 | protected $startingLine = 1; 31 | 32 | /** 33 | * @var int|null The number of lines, relative to the starting line. NULL 34 | * means "to the end". 35 | */ 36 | protected $lineCount = null; 37 | 38 | /** 39 | * {@inheritdoc} 40 | */ 41 | public function getContent() 42 | { 43 | if (null === $this->content) { 44 | $this->content 45 | = "{$this->startingLine} {$this->lineCount} {$this->description}"; 46 | } 47 | 48 | return $this->content; 49 | } 50 | 51 | /** 52 | * {@inheritdoc} 53 | */ 54 | public function setContent($content) 55 | { 56 | parent::setContent($content); 57 | if (preg_match( 58 | '/^ 59 | # Starting line 60 | ([1-9]\d*) 61 | \s* 62 | # Number of lines 63 | (?: 64 | ((?1)) 65 | \s+ 66 | )? 67 | # Description 68 | (.*) 69 | $/sux', 70 | $this->description, 71 | $matches 72 | )) { 73 | $this->startingLine = (int)$matches[1]; 74 | if (isset($matches[2]) && '' !== $matches[2]) { 75 | $this->lineCount = (int)$matches[2]; 76 | } 77 | $this->setDescription($matches[3]); 78 | $this->content = $content; 79 | } 80 | 81 | return $this; 82 | } 83 | 84 | /** 85 | * Gets the starting line. 86 | * 87 | * @return int The starting line, relative to the structural element's 88 | * location. 89 | */ 90 | public function getStartingLine() 91 | { 92 | return $this->startingLine; 93 | } 94 | 95 | /** 96 | * Sets the starting line. 97 | * 98 | * @param int $startingLine The new starting line, relative to the 99 | * structural element's location. 100 | * 101 | * @return $this 102 | */ 103 | public function setStartingLine($startingLine) 104 | { 105 | $this->startingLine = $startingLine; 106 | 107 | $this->content = null; 108 | return $this; 109 | } 110 | 111 | /** 112 | * Returns the number of lines. 113 | * 114 | * @return int|null The number of lines, relative to the starting line. NULL 115 | * means "to the end". 116 | */ 117 | public function getLineCount() 118 | { 119 | return $this->lineCount; 120 | } 121 | 122 | /** 123 | * Sets the number of lines. 124 | * 125 | * @param int|null $lineCount The new number of lines, relative to the 126 | * starting line. NULL means "to the end". 127 | * 128 | * @return $this 129 | */ 130 | public function setLineCount($lineCount) 131 | { 132 | $this->lineCount = $lineCount; 133 | 134 | $this->content = null; 135 | return $this; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/ThrowsTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | /** 16 | * Reflection class for a @throws tag in a Docblock. 17 | * 18 | * @author Mike van Riel 19 | * @license http://www.opensource.org/licenses/mit-license.php MIT 20 | * @link http://phpdoc.org 21 | */ 22 | class ThrowsTag extends ReturnTag 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/UsesTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | /** 16 | * Reflection class for a @uses tag in a Docblock. 17 | * 18 | * @author Mike van Riel 19 | * @license http://www.opensource.org/licenses/mit-license.php MIT 20 | * @link http://phpdoc.org 21 | */ 22 | class UsesTag extends SeeTag 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/VarTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | /** 16 | * Reflection class for a @var tag in a Docblock. 17 | * 18 | * @author Mike van Riel 19 | * @license http://www.opensource.org/licenses/mit-license.php MIT 20 | * @link http://phpdoc.org 21 | */ 22 | class VarTag extends ParamTag 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /phpDocumentor/Reflection/DocBlock/Tag/VersionTag.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT 10 | * @link http://phpdoc.org 11 | */ 12 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tag; 14 | 15 | use phpDocumentor\Reflection\DocBlock\Tag; 16 | 17 | /** 18 | * Reflection class for a @version tag in a Docblock. 19 | * 20 | * @author Vasil Rangelov 21 | * @license http://www.opensource.org/licenses/mit-license.php MIT 22 | * @link http://phpdoc.org 23 | */ 24 | class VersionTag extends Tag 25 | { 26 | /** 27 | * PCRE regular expression matching a version vector. 28 | * Assumes the "x" modifier. 29 | */ 30 | const REGEX_VECTOR = '(?: 31 | # Normal release vectors. 32 | \d\S* 33 | | 34 | # VCS version vectors. Per PHPCS, they are expected to 35 | # follow the form of the VCS name, followed by ":", followed 36 | # by the version vector itself. 37 | # By convention, popular VCSes like CVS, SVN and GIT use "$" 38 | # around the actual version vector. 39 | [^\s\:]+\:\s*\$[^\$]+\$ 40 | )'; 41 | 42 | /** @var string The version vector. */ 43 | protected $version = ''; 44 | 45 | public function getContent() 46 | { 47 | if (null === $this->content) { 48 | $this->content = "{$this->version} {$this->description}"; 49 | } 50 | 51 | return $this->content; 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | public function setContent($content) 58 | { 59 | parent::setContent($content); 60 | 61 | if (preg_match( 62 | '/^ 63 | # The version vector 64 | (' . self::REGEX_VECTOR . ') 65 | \s* 66 | # The description 67 | (.+)? 68 | $/sux', 69 | $this->description, 70 | $matches 71 | )) { 72 | $this->version = $matches[1]; 73 | $this->setDescription(isset($matches[2]) ? $matches[2] : ''); 74 | $this->content = $content; 75 | } 76 | 77 | return $this; 78 | } 79 | 80 | /** 81 | * Gets the version section of the tag. 82 | * 83 | * @return string The version section of the tag. 84 | */ 85 | public function getVersion() 86 | { 87 | return $this->version; 88 | } 89 | 90 | /** 91 | * Sets the version section of the tag. 92 | * 93 | * @param string $version The new version section of the tag. 94 | * An invalid value will set an empty string. 95 | * 96 | * @return $this 97 | */ 98 | public function setVersion($version) 99 | { 100 | $this->version 101 | = preg_match('/^' . self::REGEX_VECTOR . '$/ux', $version) 102 | ? $version 103 | : ''; 104 | 105 | $this->content = null; 106 | return $this; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Codex Creator === 2 | Contributors: stiofansisland, paoltaia 3 | Tags: Codex, Codex Creator, Documentation, Documentation Generator 4 | License: GPLv3 5 | License URI: http://www.gnu.org/licenses/gpl-3.0.html 6 | 7 | 8 | Below is the DocBlock standards and cheat sheet that should be used. 9 | 10 | please see this page for WP standards: https://make.wordpress.org/core/handbook/inline-documentation-standards/php-documentation-standards/ 11 | 12 | @global type $varname Description. 13 | type can be any of the following: bool || float || int || array || object || wpdb 14 | $varname is the variable that is declared global. 15 | Description is the description text and should end with a period (.) 16 | 17 | global cheat sheet: 18 | @global wpdb $wpdb WordPress database abstraction object. 19 | @global object $current_user The current user object which holds the user data. 20 | @global WP_Post|null $post The current post, if available. 21 | @global bool $preview True if the current page is add listing preview page. False if not. 22 | 23 | 24 | ACTIONS/FILTERS 25 | when writing a DocBlock for an action or filter the package name is not required. 26 | when the action/filter is inside a functions please use the see tag like this: @see my_awesome_functions_name function. 27 | If there are other filter or actions also in the containing functions please list theme with the see tag also: @see my_awesome_action_name action. 28 | 29 | IGNORE 30 | CC will skip directories containing .ccignore or ccignore.txt --------------------------------------------------------------------------------