@@ -6,9 +6,9 @@ |
||
| 6 | 6 | { |
| 7 | 7 | protected $xml; |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * @var \LibXMLError |
|
| 11 | - */ |
|
| 9 | + /** |
|
| 10 | + * @var \LibXMLError |
|
| 11 | + */ |
|
| 12 | 12 | protected $nativeError; |
| 13 | 13 | |
| 14 | 14 | public function __construct(XMLHelper_SimpleXML $xml, \LibXMLError $nativeError) |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | const ERROR_FAILED_CONVERTING_TO_JSON = 37901; |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var \SimpleXMLElement |
|
| 46 | - */ |
|
| 44 | + /** |
|
| 45 | + * @var \SimpleXMLElement |
|
| 46 | + */ |
|
| 47 | 47 | protected $xml; |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 49 | + /** |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | 52 | protected $json; |
| 53 | 53 | |
| 54 | 54 | protected function __construct(\SimpleXMLElement $element) |
@@ -56,24 +56,24 @@ discard block |
||
| 56 | 56 | $this->xml = $element; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Factory method: creates a converter from an XML file on disk. |
|
| 61 | - * |
|
| 62 | - * @param string $path |
|
| 63 | - * @return \AppUtils\XMLHelper_Converter |
|
| 64 | - */ |
|
| 59 | + /** |
|
| 60 | + * Factory method: creates a converter from an XML file on disk. |
|
| 61 | + * |
|
| 62 | + * @param string $path |
|
| 63 | + * @return \AppUtils\XMLHelper_Converter |
|
| 64 | + */ |
|
| 65 | 65 | public static function fromFile(string $path) |
| 66 | 66 | { |
| 67 | 67 | $xmlString = file_get_contents($path); |
| 68 | 68 | return self::fromString($xmlString); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Factory method: creates a converter from an XML string. |
|
| 73 | - * |
|
| 74 | - * @param string $xmlString |
|
| 75 | - * @return \AppUtils\XMLHelper_Converter |
|
| 76 | - */ |
|
| 71 | + /** |
|
| 72 | + * Factory method: creates a converter from an XML string. |
|
| 73 | + * |
|
| 74 | + * @param string $xmlString |
|
| 75 | + * @return \AppUtils\XMLHelper_Converter |
|
| 76 | + */ |
|
| 77 | 77 | public static function fromString(string $xmlString) |
| 78 | 78 | { |
| 79 | 79 | $element = new \SimpleXMLElement($xmlString); |
@@ -81,36 +81,36 @@ discard block |
||
| 81 | 81 | return self::fromElement($element); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
| 86 | - * |
|
| 87 | - * @param \SimpleXMLElement $element |
|
| 88 | - * @return \AppUtils\XMLHelper_Converter |
|
| 89 | - */ |
|
| 84 | + /** |
|
| 85 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
| 86 | + * |
|
| 87 | + * @param \SimpleXMLElement $element |
|
| 88 | + * @return \AppUtils\XMLHelper_Converter |
|
| 89 | + */ |
|
| 90 | 90 | public static function fromElement(\SimpleXMLElement $element) |
| 91 | 91 | { |
| 92 | 92 | $obj = new XMLHelper_Converter($element); |
| 93 | 93 | return $obj; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
| 98 | - * |
|
| 99 | - * @param \DOMElement $element |
|
| 100 | - * @return \AppUtils\XMLHelper_Converter |
|
| 101 | - */ |
|
| 96 | + /** |
|
| 97 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
| 98 | + * |
|
| 99 | + * @param \DOMElement $element |
|
| 100 | + * @return \AppUtils\XMLHelper_Converter |
|
| 101 | + */ |
|
| 102 | 102 | public static function fromDOMElement(\DOMElement $element) |
| 103 | 103 | { |
| 104 | 104 | $obj = new XMLHelper_Converter(simplexml_import_dom($element)); |
| 105 | 105 | return $obj; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Converts the XML to JSON. |
|
| 110 | - * |
|
| 111 | - * @throws XMLHelper_Exception |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 108 | + /** |
|
| 109 | + * Converts the XML to JSON. |
|
| 110 | + * |
|
| 111 | + * @throws XMLHelper_Exception |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | 114 | public function toJSON() : string |
| 115 | 115 | { |
| 116 | 116 | if(isset($this->json)) { |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | ); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Converts the XML to an associative array. |
|
| 143 | - * @return array |
|
| 144 | - * @throws XMLHelper_Exception |
|
| 145 | - */ |
|
| 141 | + /** |
|
| 142 | + * Converts the XML to an associative array. |
|
| 143 | + * @return array |
|
| 144 | + * @throws XMLHelper_Exception |
|
| 145 | + */ |
|
| 146 | 146 | public function toArray() : array |
| 147 | 147 | { |
| 148 | 148 | $json = $this->toJSON(); |
@@ -11,27 +11,27 @@ |
||
| 11 | 11 | |
| 12 | 12 | protected $errors = array(); |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Creates a simplexml instance from an XML string. |
|
| 16 | - * |
|
| 17 | - * NOTE: returns false in case of a fatal error. |
|
| 18 | - * |
|
| 19 | - * @param string $string |
|
| 20 | - * @return \SimpleXMLElement|bool |
|
| 21 | - */ |
|
| 14 | + /** |
|
| 15 | + * Creates a simplexml instance from an XML string. |
|
| 16 | + * |
|
| 17 | + * NOTE: returns false in case of a fatal error. |
|
| 18 | + * |
|
| 19 | + * @param string $string |
|
| 20 | + * @return \SimpleXMLElement|bool |
|
| 21 | + */ |
|
| 22 | 22 | public function loadString($string) |
| 23 | 23 | { |
| 24 | 24 | return $this->load('string', $string); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Creates a simplexml instance from an XML file. |
|
| 29 | - * |
|
| 30 | - * NOTE: returns false in case of a fatal error. |
|
| 31 | - * |
|
| 32 | - * @param string $file |
|
| 33 | - * @return \SimpleXMLElement|bool |
|
| 34 | - */ |
|
| 27 | + /** |
|
| 28 | + * Creates a simplexml instance from an XML file. |
|
| 29 | + * |
|
| 30 | + * NOTE: returns false in case of a fatal error. |
|
| 31 | + * |
|
| 32 | + * @param string $file |
|
| 33 | + * @return \SimpleXMLElement|bool |
|
| 34 | + */ |
|
| 35 | 35 | public function loadFile($file) |
| 36 | 36 | { |
| 37 | 37 | return $this->load('file', $file); |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | const REGEX_MD5 = '/^[a-f0-9]{32}$/i'; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string |
|
| 47 | - * @see https://en.wikipedia.org/wiki/Email_address#Local-part |
|
| 48 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var string |
|
| 47 | + * @see https://en.wikipedia.org/wiki/Email_address#Local-part |
|
| 48 | + */ |
|
| 49 | 49 | const REGEX_EMAIL = '/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i'; |
| 50 | 50 | |
| 51 | 51 | const REGEX_PHONE = '/\A[+0-9][0-9 +\-()]+\z/m'; |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | const REGEX_IS_HTML = '%<{0,1}[a-z\/][\s\S]*>|<[a-z\/][\s\S]*>{0,1}%i'; |
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Hexadecimal color codes. Allows the following formats: |
|
| 102 | - * |
|
| 103 | - * FFFFFF |
|
| 104 | - * FFF |
|
| 105 | - * |
|
| 106 | - * @var string |
|
| 107 | - */ |
|
| 100 | + /** |
|
| 101 | + * Hexadecimal color codes. Allows the following formats: |
|
| 102 | + * |
|
| 103 | + * FFFFFF |
|
| 104 | + * FFF |
|
| 105 | + * |
|
| 106 | + * @var string |
|
| 107 | + */ |
|
| 108 | 108 | const REGEX_HEX_COLOR_CODE = '/\A(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\z/iU'; |
| 109 | 109 | } |
@@ -38,38 +38,38 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | protected $text; |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | 44 | protected $trimmed; |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var int |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * @var int |
|
| 48 | + */ |
|
| 49 | 49 | protected $lineNumber; |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 51 | + /** |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | 54 | protected $type; |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 56 | + /** |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | 59 | protected $varName = ''; |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var string |
|
| 63 | - */ |
|
| 61 | + /** |
|
| 62 | + * @var string |
|
| 63 | + */ |
|
| 64 | 64 | protected $varValue = ''; |
| 65 | 65 | |
| 66 | 66 | protected $valueUnquoted = ''; |
| 67 | 67 | |
| 68 | 68 | protected $quoteStyle = ''; |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @var string |
|
| 72 | - */ |
|
| 70 | + /** |
|
| 71 | + * @var string |
|
| 72 | + */ |
|
| 73 | 73 | protected $sectionName = ''; |
| 74 | 74 | |
| 75 | 75 | public function __construct(string $text, int $lineNumber) |
@@ -21,19 +21,19 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class IniHelper_Section |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @var IniHelper |
|
| 26 | - */ |
|
| 24 | + /** |
|
| 25 | + * @var IniHelper |
|
| 26 | + */ |
|
| 27 | 27 | protected $ini; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | 32 | protected $name; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var IniHelper_Line[] |
|
| 36 | - */ |
|
| 34 | + /** |
|
| 35 | + * @var IniHelper_Line[] |
|
| 36 | + */ |
|
| 37 | 37 | protected $lines = array(); |
| 38 | 38 | |
| 39 | 39 | public function __construct(IniHelper $ini, string $name) |
@@ -42,33 +42,33 @@ discard block |
||
| 42 | 42 | $this->name = $name; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * The section's name. |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 45 | + /** |
|
| 46 | + * The section's name. |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | 49 | public function getName() : string |
| 50 | 50 | { |
| 51 | 51 | return $this->name; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Whether this is the default section: this |
|
| 56 | - * is used internally to store all variables that |
|
| 57 | - * are not in any specific section. |
|
| 58 | - * |
|
| 59 | - * @return bool |
|
| 60 | - */ |
|
| 54 | + /** |
|
| 55 | + * Whether this is the default section: this |
|
| 56 | + * is used internally to store all variables that |
|
| 57 | + * are not in any specific section. |
|
| 58 | + * |
|
| 59 | + * @return bool |
|
| 60 | + */ |
|
| 61 | 61 | public function isDefault() : bool |
| 62 | 62 | { |
| 63 | 63 | return $this->name === IniHelper::SECTION_DEFAULT; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Adds a line instance to the section. |
|
| 68 | - * |
|
| 69 | - * @param IniHelper_Line $line |
|
| 70 | - * @return IniHelper_Section |
|
| 71 | - */ |
|
| 66 | + /** |
|
| 67 | + * Adds a line instance to the section. |
|
| 68 | + * |
|
| 69 | + * @param IniHelper_Line $line |
|
| 70 | + * @return IniHelper_Section |
|
| 71 | + */ |
|
| 72 | 72 | public function addLine(IniHelper_Line $line) : IniHelper_Section |
| 73 | 73 | { |
| 74 | 74 | $this->lines[] = $line; |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | return $this; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Converts the values contained in the section into |
|
| 81 | - * an associative array. |
|
| 82 | - * |
|
| 83 | - * @return array |
|
| 84 | - */ |
|
| 79 | + /** |
|
| 80 | + * Converts the values contained in the section into |
|
| 81 | + * an associative array. |
|
| 82 | + * |
|
| 83 | + * @return array |
|
| 84 | + */ |
|
| 85 | 85 | public function toArray() : array |
| 86 | 86 | { |
| 87 | 87 | $result = array(); |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | return $result; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Converts the section's lines into an INI string. |
|
| 119 | - * |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 117 | + /** |
|
| 118 | + * Converts the section's lines into an INI string. |
|
| 119 | + * |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | 122 | public function toString() |
| 123 | 123 | { |
| 124 | 124 | $lines = array(); |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | return implode($this->ini->getEOLChar(), $lines); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Deletes a line from the section. |
|
| 145 | - * |
|
| 146 | - * @param IniHelper_Line $toDelete |
|
| 147 | - * @return IniHelper_Section |
|
| 148 | - */ |
|
| 143 | + /** |
|
| 144 | + * Deletes a line from the section. |
|
| 145 | + * |
|
| 146 | + * @param IniHelper_Line $toDelete |
|
| 147 | + * @return IniHelper_Section |
|
| 148 | + */ |
|
| 149 | 149 | public function deleteLine(IniHelper_Line $toDelete) : IniHelper_Section |
| 150 | 150 | { |
| 151 | 151 | $keep = array(); |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | return $this; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Sets the value of a variable, overwriting any existing value. |
|
| 167 | - * |
|
| 168 | - * @param string $name |
|
| 169 | - * @param mixed $value If an array is specified, it is treated as duplicate keys and will add a line for each value. |
|
| 170 | - * @return IniHelper_Section |
|
| 171 | - */ |
|
| 165 | + /** |
|
| 166 | + * Sets the value of a variable, overwriting any existing value. |
|
| 167 | + * |
|
| 168 | + * @param string $name |
|
| 169 | + * @param mixed $value If an array is specified, it is treated as duplicate keys and will add a line for each value. |
|
| 170 | + * @return IniHelper_Section |
|
| 171 | + */ |
|
| 172 | 172 | public function setValue(string $name, $value) : IniHelper_Section |
| 173 | 173 | { |
| 174 | 174 | $lines = $this->getLinesByVariable($name); |
@@ -229,15 +229,15 @@ discard block |
||
| 229 | 229 | return $this; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - /** |
|
| 233 | - * Adds a variable value to the section. Unlike setValue(), this |
|
| 234 | - * will not overwrite any existing value. If the name is an existing |
|
| 235 | - * variable name, it will be converted to duplicate keys. |
|
| 236 | - * |
|
| 237 | - * @param string $name |
|
| 238 | - * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
| 239 | - * @return IniHelper_Section |
|
| 240 | - */ |
|
| 232 | + /** |
|
| 233 | + * Adds a variable value to the section. Unlike setValue(), this |
|
| 234 | + * will not overwrite any existing value. If the name is an existing |
|
| 235 | + * variable name, it will be converted to duplicate keys. |
|
| 236 | + * |
|
| 237 | + * @param string $name |
|
| 238 | + * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
| 239 | + * @return IniHelper_Section |
|
| 240 | + */ |
|
| 241 | 241 | public function addValue(string $name, $value) : IniHelper_Section |
| 242 | 242 | { |
| 243 | 243 | // array value? Treat it as duplicate keys. |
@@ -295,12 +295,12 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | |
| 298 | - /** |
|
| 299 | - * Retrieves all lines for the specified variable name. |
|
| 300 | - * |
|
| 301 | - * @param string $name |
|
| 302 | - * @return \AppUtils\IniHelper_Line[] |
|
| 303 | - */ |
|
| 298 | + /** |
|
| 299 | + * Retrieves all lines for the specified variable name. |
|
| 300 | + * |
|
| 301 | + * @param string $name |
|
| 302 | + * @return \AppUtils\IniHelper_Line[] |
|
| 303 | + */ |
|
| 304 | 304 | public function getLinesByVariable(string $name) |
| 305 | 305 | { |
| 306 | 306 | $result = array(); |
@@ -36,17 +36,17 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | protected $classes = array(); |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * The namespace detected in the file, if any. |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 39 | + /** |
|
| 40 | + * The namespace detected in the file, if any. |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | 43 | protected $namespace = ''; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @param string $path The path to the PHP file to parse. |
|
| 47 | - * @throws FileHelper_Exception |
|
| 48 | - * @see FileHelper::findPHPClasses() |
|
| 49 | - */ |
|
| 45 | + /** |
|
| 46 | + * @param string $path The path to the PHP file to parse. |
|
| 47 | + * @throws FileHelper_Exception |
|
| 48 | + * @see FileHelper::findPHPClasses() |
|
| 49 | + */ |
|
| 50 | 50 | public function __construct(string $path) |
| 51 | 51 | { |
| 52 | 52 | $this->path = realpath($path); |
@@ -66,66 +66,66 @@ discard block |
||
| 66 | 66 | $this->parseFile(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * The name of the namespace of the classes in the file, if any. |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 69 | + /** |
|
| 70 | + * The name of the namespace of the classes in the file, if any. |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | 73 | public function getNamespace() : string |
| 74 | 74 | { |
| 75 | 75 | return $this->namespace; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Whether the file contains a namespace. |
|
| 80 | - * @return bool |
|
| 81 | - */ |
|
| 78 | + /** |
|
| 79 | + * Whether the file contains a namespace. |
|
| 80 | + * @return bool |
|
| 81 | + */ |
|
| 82 | 82 | public function hasNamespace() : bool |
| 83 | 83 | { |
| 84 | 84 | return !empty($this->namespace); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * The absolute path to the file. |
|
| 89 | - * @return string |
|
| 90 | - */ |
|
| 87 | + /** |
|
| 88 | + * The absolute path to the file. |
|
| 89 | + * @return string |
|
| 90 | + */ |
|
| 91 | 91 | public function getPath() : string |
| 92 | 92 | { |
| 93 | 93 | return $this->path; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Whether any classes were found in the file. |
|
| 98 | - * @return bool |
|
| 99 | - */ |
|
| 96 | + /** |
|
| 97 | + * Whether any classes were found in the file. |
|
| 98 | + * @return bool |
|
| 99 | + */ |
|
| 100 | 100 | public function hasClasses() : bool |
| 101 | 101 | { |
| 102 | 102 | return !empty($this->classes); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * The names of the classes that were found in the file (with namespace if any). |
|
| 107 | - * @return string[] |
|
| 108 | - */ |
|
| 105 | + /** |
|
| 106 | + * The names of the classes that were found in the file (with namespace if any). |
|
| 107 | + * @return string[] |
|
| 108 | + */ |
|
| 109 | 109 | public function getClassNames() : array |
| 110 | 110 | { |
| 111 | 111 | return array_keys($this->classes); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Retrieves all classes that were detected in the file, |
|
| 116 | - * which can be used to retrieve more information about |
|
| 117 | - * them. |
|
| 118 | - * |
|
| 119 | - * @return FileHelper_PHPClassInfo_Class[] |
|
| 120 | - */ |
|
| 114 | + /** |
|
| 115 | + * Retrieves all classes that were detected in the file, |
|
| 116 | + * which can be used to retrieve more information about |
|
| 117 | + * them. |
|
| 118 | + * |
|
| 119 | + * @return FileHelper_PHPClassInfo_Class[] |
|
| 120 | + */ |
|
| 121 | 121 | public function getClasses() |
| 122 | 122 | { |
| 123 | 123 | return $this->classes; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * @throws FileHelper_Exception |
|
| 128 | - */ |
|
| 126 | + /** |
|
| 127 | + * @throws FileHelper_Exception |
|
| 128 | + */ |
|
| 129 | 129 | protected function parseFile() |
| 130 | 130 | { |
| 131 | 131 | $code = file_get_contents($this->path); |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Strips all whitespace from the string, replacing it with |
|
| 185 | - * regular spaces (newlines, tabs, etc.). |
|
| 186 | - * |
|
| 187 | - * @param string $string |
|
| 188 | - * @return string |
|
| 189 | - */ |
|
| 183 | + /** |
|
| 184 | + * Strips all whitespace from the string, replacing it with |
|
| 185 | + * regular spaces (newlines, tabs, etc.). |
|
| 186 | + * |
|
| 187 | + * @param string $string |
|
| 188 | + * @return string |
|
| 189 | + */ |
|
| 190 | 190 | protected function stripWhitespace(string $string) : string |
| 191 | 191 | { |
| 192 | 192 | return preg_replace('/[\s]/', ' ', $string); |
@@ -22,51 +22,51 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class FileHelper_PHPClassInfo_Class |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var FileHelper_PHPClassInfo |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var FileHelper_PHPClassInfo |
|
| 27 | + */ |
|
| 28 | 28 | protected $info; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var bool |
|
| 32 | - */ |
|
| 30 | + /** |
|
| 31 | + * @var bool |
|
| 32 | + */ |
|
| 33 | 33 | protected $abstract = false; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var bool |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var bool |
|
| 37 | + */ |
|
| 38 | 38 | protected $final = false; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | 43 | protected $extends = ''; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string[] |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var string[] |
|
| 47 | + */ |
|
| 48 | 48 | protected $implements = array(); |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | 53 | protected $name; |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @var string |
|
| 57 | - */ |
|
| 55 | + /** |
|
| 56 | + * @var string |
|
| 57 | + */ |
|
| 58 | 58 | protected $declaration; |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 60 | + /** |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | 63 | protected $keyword; |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @param FileHelper_PHPClassInfo $info The class info instance. |
|
| 67 | - * @param string $declaration The full class declaration, e.g. "class SomeName extends SomeOtherClass". |
|
| 68 | - * @param string $keyword The class keyword, if any, i.e. "abstract" or "final". |
|
| 69 | - */ |
|
| 65 | + /** |
|
| 66 | + * @param FileHelper_PHPClassInfo $info The class info instance. |
|
| 67 | + * @param string $declaration The full class declaration, e.g. "class SomeName extends SomeOtherClass". |
|
| 68 | + * @param string $keyword The class keyword, if any, i.e. "abstract" or "final". |
|
| 69 | + */ |
|
| 70 | 70 | public function __construct(FileHelper_PHPClassInfo $info, string $declaration, string $keyword) |
| 71 | 71 | { |
| 72 | 72 | $this->info = $info; |
@@ -76,31 +76,31 @@ discard block |
||
| 76 | 76 | $this->analyzeCode(); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Check if this class is a subclass of the specified |
|
| 81 | - * class name. |
|
| 82 | - * |
|
| 83 | - * @param string $className |
|
| 84 | - * @return bool |
|
| 85 | - */ |
|
| 79 | + /** |
|
| 80 | + * Check if this class is a subclass of the specified |
|
| 81 | + * class name. |
|
| 82 | + * |
|
| 83 | + * @param string $className |
|
| 84 | + * @return bool |
|
| 85 | + */ |
|
| 86 | 86 | public function isSublassOf(string $className) : bool |
| 87 | 87 | { |
| 88 | 88 | return is_subclass_of($this->getNameNS(), $className); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * The class name without namespace. |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 91 | + /** |
|
| 92 | + * The class name without namespace. |
|
| 93 | + * @return string |
|
| 94 | + */ |
|
| 95 | 95 | public function getName() : string |
| 96 | 96 | { |
| 97 | 97 | return $this->name; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * The absolute class name with namespace (if any). |
|
| 102 | - * @return string |
|
| 103 | - */ |
|
| 100 | + /** |
|
| 101 | + * The absolute class name with namespace (if any). |
|
| 102 | + * @return string |
|
| 103 | + */ |
|
| 104 | 104 | public function getNameNS() : string |
| 105 | 105 | { |
| 106 | 106 | $name = $this->getName(); |
@@ -112,48 +112,48 @@ discard block |
||
| 112 | 112 | return $name; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Whether it is an abstract class. |
|
| 117 | - * @return bool |
|
| 118 | - */ |
|
| 115 | + /** |
|
| 116 | + * Whether it is an abstract class. |
|
| 117 | + * @return bool |
|
| 118 | + */ |
|
| 119 | 119 | public function isAbstract() : bool |
| 120 | 120 | { |
| 121 | 121 | return $this->abstract; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Whether it is a final class. |
|
| 126 | - * @return bool |
|
| 127 | - */ |
|
| 124 | + /** |
|
| 125 | + * Whether it is a final class. |
|
| 126 | + * @return bool |
|
| 127 | + */ |
|
| 128 | 128 | public function isFinal() : bool |
| 129 | 129 | { |
| 130 | 130 | return $this->final; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * The name of the class that this class extends (with namespace, if specified). |
|
| 135 | - * @return string |
|
| 136 | - */ |
|
| 133 | + /** |
|
| 134 | + * The name of the class that this class extends (with namespace, if specified). |
|
| 135 | + * @return string |
|
| 136 | + */ |
|
| 137 | 137 | public function getExtends() : string |
| 138 | 138 | { |
| 139 | 139 | return $this->extends; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * A list of interfaces the class implements, if any. |
|
| 144 | - * @return array |
|
| 145 | - */ |
|
| 142 | + /** |
|
| 143 | + * A list of interfaces the class implements, if any. |
|
| 144 | + * @return array |
|
| 145 | + */ |
|
| 146 | 146 | public function getImplements() : array |
| 147 | 147 | { |
| 148 | 148 | return $this->implements; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * The class declaration string, with normalized spaces and sorted interface names. |
|
| 153 | - * NOTE: does not include the keyword "abstract" or "final". |
|
| 154 | - * |
|
| 155 | - * @return string |
|
| 156 | - */ |
|
| 151 | + /** |
|
| 152 | + * The class declaration string, with normalized spaces and sorted interface names. |
|
| 153 | + * NOTE: does not include the keyword "abstract" or "final". |
|
| 154 | + * |
|
| 155 | + * @return string |
|
| 156 | + */ |
|
| 157 | 157 | public function getDeclaration() : string |
| 158 | 158 | { |
| 159 | 159 | $parts = array(); |
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | return implode(' ', $parts); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * The keyword before "class", e.g. "abstract". |
|
| 178 | - * @return string |
|
| 179 | - */ |
|
| 176 | + /** |
|
| 177 | + * The keyword before "class", e.g. "abstract". |
|
| 178 | + * @return string |
|
| 179 | + */ |
|
| 180 | 180 | public function getKeyword() : string |
| 181 | 181 | { |
| 182 | 182 | return $this->keyword; |
@@ -7,9 +7,9 @@ |
||
| 7 | 7 | * @author Sebastian Mordziol <[email protected]> |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * Examples environment config |
|
| 12 | - */ |
|
| 10 | + /** |
|
| 11 | + * Examples environment config |
|
| 12 | + */ |
|
| 13 | 13 | require_once '../prepend.php'; |
| 14 | 14 | |
| 15 | 15 | use function AppUtils\parseURL; |