Phtml.js

{
    "type": "file",
    "namespace": {
        "type": "namespace",
        "name": "Taeluf",
        "declaration": "namespace Taeluf;",
        "class": [
            {
                "type": "class",
                "namespace": "Taeluf",
                "fqn": "Taeluf\\Phtml",
                "name": "Phtml",
                "extends": "\\DOMDocument",
                "declaration": "class Phtml extends \\DOMDocument",
                "properties": [
                    {
                        "type": "property",
                        "modifiers": [
                            "protected",
                            "string"
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "The source HTML + PHP code\n",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "var",
                                    "description": "string"
                                }
                            ]
                        },
                        "name": "src",
                        "declaration": "protected string $src;"
                    },
                    {
                        "type": "property",
                        "modifiers": [
                            "protected",
                            "string"
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "The source code with all the PHP replaced by placeholders"
                        },
                        "name": "cleanSrc",
                        "declaration": "protected string $cleanSrc;"
                    },
                    {
                        "type": "property",
                        "modifiers": [
                            "protected",
                            "array"
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "[ 'phpplaceholder' => $phpCode, 'placeholder2' => $morePHP ]"
                        },
                        "name": "php",
                        "declaration": "protected array $php;"
                    },
                    {
                        "type": "property",
                        "modifiers": [
                            "protected"
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "A random string used when adding php code to a node's tag declaration. This string is later removed during output()"
                        },
                        "name": "phpAttrValue",
                        "declaration": "protected $phpAttrValue;"
                    }
                ],
                "comments": [
                    "\/**",
                    "* True if the source html had a '<html>' tag",
                    "* Except we're not implementing that???",
                    "* @var bool",
                    "*\/",
                    "protected bool $isHTMLDoc = false;"
                ],
                "methods": [
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "name": "html",
                                "declaration": "$html"
                            }
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "Create a DOMDocument, passing your HTML + PHP to __construct. \n\n",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "param",
                                    "description": "mixed $html a block of HTML + PHP code. It does not have to have PHP. PHP will be handled gracefully."
                                },
                                {
                                    "type": "attribute",
                                    "name": "return",
                                    "description": "void"
                                }
                            ]
                        },
                        "modifiers": [
                            "public"
                        ],
                        "name": "__construct",
                        "body": [],
                        "declaration": "public function __construct($html)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "arg_types": [
                                    "string"
                                ],
                                "name": "string",
                                "declaration": "string $string"
                            }
                        ],
                        "modifiers": [
                            "public"
                        ],
                        "name": "placeholder",
                        "return_types": [
                            "string"
                        ],
                        "body": {
                            "_source": null,
                            "_type": "array"
                        },
                        "declaration": "public function placeholder(string $string): string"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "arg_types": [
                                    "string"
                                ],
                                "name": "placeholder",
                                "declaration": "string $placeholder"
                            }
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "Get the code that's represented by the placeholder",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "return",
                                    "description": "the stored code or null"
                                }
                            ]
                        },
                        "modifiers": [
                            "public"
                        ],
                        "name": "codeFromPlaceholder",
                        "return_types": [
                            "string"
                        ],
                        "body": {
                            "_source": null,
                            "_type": "array"
                        },
                        "declaration": "public function codeFromPlaceholder(string $placeholder): string"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "arg_types": [
                                    "string"
                                ],
                                "name": "enclosedPHP",
                                "declaration": "string $enclosedPHP"
                            }
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "Get a placeholder for the given block of code\nIntention is to parse a single '<?php \/\/piece of php code ?>' and not '<?php \/\/stuff ?><?php \/\/more stuff?>'\nWhen used as intended, will return a single 'word' that is the placeholder for the given code\n",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "param",
                                    "description": "mixed $enclosedPHP an HTML + PHP string"
                                },
                                {
                                    "type": "attribute",
                                    "name": "return",
                                    "description": "string the parsed block of content where PHP code blocks are replaced by placeholders."
                                }
                            ]
                        },
                        "modifiers": [
                            "public"
                        ],
                        "name": "phpPlaceholder",
                        "return_types": [
                            "string"
                        ],
                        "body": [],
                        "declaration": "public function phpPlaceholder(string $enclosedPHP): string"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "arg_types": [
                                    "string"
                                ],
                                "name": "codeWithPlaceholders",
                                "declaration": "string $codeWithPlaceholders"
                            }
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "Decode the given code by replacing PHP placeholders with the PHP code itself\n",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "param",
                                    "description": "mixed $str"
                                },
                                {
                                    "type": "attribute",
                                    "name": "return",
                                    "description": "void"
                                }
                            ]
                        },
                        "modifiers": [
                            "public"
                        ],
                        "name": "fillWithPHP",
                        "return_types": [
                            "string"
                        ],
                        "body": [],
                        "declaration": "public function fillWithPHP(string $codeWithPlaceholders): string"
                    },
                    {
                        "type": "method",
                        "args": [],
                        "docblock": {
                            "type": "docblock",
                            "description": "See output()\n",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "return",
                                    "description": "string"
                                }
                            ]
                        },
                        "modifiers": [
                            "public"
                        ],
                        "name": "__toString",
                        "body": [],
                        "declaration": "public function __toString()"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "name": "withPHP",
                                "value": "true",
                                "declaration": "$withPHP=true"
                            }
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "Return the decoded document as as tring. All PHP will be back in its place\n",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "param",
                                    "description": "mixed $withPHP passing FALSE means placeholders will still be present & PHP code will not be"
                                },
                                {
                                    "type": "attribute",
                                    "name": "return",
                                    "description": "string the final document with PHP where it belongs"
                                }
                            ]
                        },
                        "modifiers": [
                            "public"
                        ],
                        "name": "output",
                        "body": {
                            "_source": null,
                            "_type": "array"
                        },
                        "declaration": "public function output($withPHP=true)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "name": "html",
                                "declaration": "$html"
                            },
                            {
                                "type": "arg",
                                "name": "withPHP",
                                "value": "true",
                                "declaration": "$withPHP=true"
                            }
                        ],
                        "modifiers": [
                            "public"
                        ],
                        "name": "fill_php",
                        "body": [],
                        "declaration": "public function fill_php($html, $withPHP=true)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "name": "xpath",
                                "declaration": "$xpath"
                            },
                            {
                                "type": "arg",
                                "name": "refNode",
                                "value": "null",
                                "declaration": "$refNode=null"
                            }
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "get the results of an xpath query\n",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "param",
                                    "description": "mixed $xpath the xpath query, such as: \/\/tagname[@attributename=\"value\"]\n                 If you use a refnode, prepend '.' at the beginning of your xpath query string"
                                },
                                {
                                    "type": "attribute",
                                    "name": "param",
                                    "description": "mixed $refNode a parent-node to search under"
                                },
                                {
                                    "type": "attribute",
                                    "name": "return",
                                    "description": "array the resulting DomNodeList is converted to an array & returned"
                                }
                            ]
                        },
                        "modifiers": [
                            "public"
                        ],
                        "name": "xpath",
                        "body": {
                            "_source": null,
                            "_type": "array"
                        },
                        "declaration": "public function xpath($xpath,$refNode=null)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "name": "node",
                                "declaration": "$node"
                            },
                            {
                                "type": "arg",
                                "name": "phpCode",
                                "declaration": "$phpCode"
                            }
                        ],
                        "docblock": {
                            "type": "docblock",
                            "description": "Set an attribute that will place PHP code inside the tag declartion of a node. \nBasically: `<node phpCodePlaceholder>`, which pHtml will later convert to `<node <?='some_stuff'?>>`. \nThis avoids problems caused by attributes requiring a `=\"\"`, which `DOMDocument` automatically places.\n",
                            "attribute": [
                                {
                                    "type": "attribute",
                                    "name": "param",
                                    "description": "$phpCode A block of php code with opening & closing tags like <?='some stuff'?>"
                                },
                                {
                                    "type": "attribute",
                                    "name": "return",
                                    "description": "\\Taeluf\\PHTML\\ValuelessAttribute"
                                }
                            ]
                        },
                        "modifiers": [
                            "public"
                        ],
                        "name": "addPhpToTag",
                        "body": [],
                        "declaration": "public function addPhpToTag($node, $phpCode)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "arg_types": [
                                    "\\DOMNode"
                                ],
                                "name": "node",
                                "declaration": "\\DOMNode $node"
                            },
                            {
                                "type": "arg",
                                "name": "phpCode",
                                "declaration": "$phpCode"
                            }
                        ],
                        "modifiers": [
                            "public"
                        ],
                        "name": "insertCodeBefore",
                        "body": [],
                        "declaration": "public function insertCodeBefore(\\DOMNode $node, $phpCode)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "arg_types": [
                                    "\\DOMNode"
                                ],
                                "name": "node",
                                "declaration": "\\DOMNode $node"
                            },
                            {
                                "type": "arg",
                                "name": "phpCode",
                                "declaration": "$phpCode"
                            }
                        ],
                        "modifiers": [
                            "public"
                        ],
                        "name": "insertCodeAfter",
                        "body": [],
                        "declaration": "public function insertCodeAfter(\\DOMNode $node, $phpCode)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "name": "html",
                                "declaration": "$html"
                            }
                        ],
                        "modifiers": [
                            "public"
                        ],
                        "name": "cleanHTML",
                        "body": [],
                        "declaration": "public function cleanHTML($html)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "name": "html",
                                "declaration": "$html"
                            }
                        ],
                        "modifiers": [
                            "public"
                        ],
                        "name": "restoreHtml",
                        "body": [],
                        "declaration": "public function restoreHtml($html)"
                    },
                    {
                        "type": "method",
                        "args": [
                            {
                                "type": "arg",
                                "name": "param",
                                "declaration": "$param"
                            }
                        ],
                        "modifiers": [
                            "public"
                        ],
                        "name": "__get",
                        "body": [],
                        "declaration": "public function __get($param)"
                    }
                ]
            }
        ]
    }
}