@@ -14,38 +14,38 @@ |
||
| 14 | 14 | abstract class AbstractDocumentableObject extends AbstractObject |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * External documentation |
|
| 19 | - * @var ExternalDocumentation |
|
| 20 | - */ |
|
| 21 | - private $externalDocs; |
|
| 17 | + /** |
|
| 18 | + * External documentation |
|
| 19 | + * @var ExternalDocumentation |
|
| 20 | + */ |
|
| 21 | + private $externalDocs; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @param string $command |
|
| 25 | - * @param string $data |
|
| 26 | - * @return AbstractObject|boolean |
|
| 27 | - */ |
|
| 28 | - public function handleCommand($command, $data = null) |
|
| 29 | - { |
|
| 30 | - switch (strtolower($command)) { |
|
| 31 | - case 'doc': |
|
| 32 | - case 'docs': |
|
| 33 | - $url = self::wordShift($data); |
|
| 34 | - $this->externalDocs = new ExternalDocumentation($this, $url, $data); |
|
| 35 | - return $this->externalDocs; |
|
| 36 | - } |
|
| 23 | + /** |
|
| 24 | + * @param string $command |
|
| 25 | + * @param string $data |
|
| 26 | + * @return AbstractObject|boolean |
|
| 27 | + */ |
|
| 28 | + public function handleCommand($command, $data = null) |
|
| 29 | + { |
|
| 30 | + switch (strtolower($command)) { |
|
| 31 | + case 'doc': |
|
| 32 | + case 'docs': |
|
| 33 | + $url = self::wordShift($data); |
|
| 34 | + $this->externalDocs = new ExternalDocumentation($this, $url, $data); |
|
| 35 | + return $this->externalDocs; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - return parent::handleCommand($command, $data); |
|
| 39 | - } |
|
| 38 | + return parent::handleCommand($command, $data); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @return array |
|
| 43 | - */ |
|
| 44 | - public function toArray(): array |
|
| 45 | - { |
|
| 46 | - return self::arrayFilterNull(array_merge(array( |
|
| 47 | - 'externalDocs' => $this->externalDocs?->toArray(), |
|
| 48 | - ), parent::toArray())); |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * @return array |
|
| 43 | + */ |
|
| 44 | + public function toArray(): array |
|
| 45 | + { |
|
| 46 | + return self::arrayFilterNull(array_merge(array( |
|
| 47 | + 'externalDocs' => $this->externalDocs?->toArray(), |
|
| 48 | + ), parent::toArray())); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | } |
@@ -15,59 +15,59 @@ |
||
| 15 | 15 | class TypeRegistry |
| 16 | 16 | {
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Map of format-name => class-name |
|
| 20 | - * |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - private $formats = []; |
|
| 18 | + /** |
|
| 19 | + * Map of format-name => class-name |
|
| 20 | + * |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + private $formats = []; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Add a type name from classname |
|
| 27 | - * |
|
| 28 | - * @param string $classname |
|
| 29 | - */ |
|
| 30 | - public function add(string $classname): void |
|
| 31 | - {
|
|
| 32 | - if (is_subclass_of($classname, ICustomType::class)) {
|
|
| 33 | - foreach ($classname::getFormats() as $format) {
|
|
| 34 | - $this->formats[$format] = $classname; |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - } |
|
| 25 | + /** |
|
| 26 | + * Add a type name from classname |
|
| 27 | + * |
|
| 28 | + * @param string $classname |
|
| 29 | + */ |
|
| 30 | + public function add(string $classname): void |
|
| 31 | + {
|
|
| 32 | + if (is_subclass_of($classname, ICustomType::class)) {
|
|
| 33 | + foreach ($classname::getFormats() as $format) {
|
|
| 34 | + $this->formats[$format] = $classname; |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Remove type format by explicitly nulling it (disables it) |
|
| 41 | - * |
|
| 42 | - * @param string $name |
|
| 43 | - */ |
|
| 44 | - public function remove($name): void |
|
| 45 | - {
|
|
| 46 | - $this->formats[$name] = null; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Remove type format by explicitly nulling it (disables it) |
|
| 41 | + * |
|
| 42 | + * @param string $name |
|
| 43 | + */ |
|
| 44 | + public function remove($name): void |
|
| 45 | + {
|
|
| 46 | + $this->formats[$name] = null; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Is a type format known? |
|
| 51 | - * |
|
| 52 | - * @param $name |
|
| 53 | - * @return bool |
|
| 54 | - */ |
|
| 55 | - public function has($name): bool |
|
| 56 | - {
|
|
| 57 | - return !empty($this->formats[$name]); |
|
| 58 | - } |
|
| 49 | + /** |
|
| 50 | + * Is a type format known? |
|
| 51 | + * |
|
| 52 | + * @param $name |
|
| 53 | + * @return bool |
|
| 54 | + */ |
|
| 55 | + public function has($name): bool |
|
| 56 | + {
|
|
| 57 | + return !empty($this->formats[$name]); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Get the format class name |
|
| 62 | - * |
|
| 63 | - * @param $name |
|
| 64 | - * @return null|string |
|
| 65 | - */ |
|
| 66 | - public function get($name): ?string |
|
| 67 | - {
|
|
| 68 | - return !empty($this->formats[$name]) |
|
| 69 | - ? $this->formats[$name] |
|
| 70 | - : null; |
|
| 71 | - } |
|
| 60 | + /** |
|
| 61 | + * Get the format class name |
|
| 62 | + * |
|
| 63 | + * @param $name |
|
| 64 | + * @return null|string |
|
| 65 | + */ |
|
| 66 | + public function get($name): ?string |
|
| 67 | + {
|
|
| 68 | + return !empty($this->formats[$name]) |
|
| 69 | + ? $this->formats[$name] |
|
| 70 | + : null; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | * @copyright 2014-2025 Martijn van der Lee |
| 13 | 13 | * @license https://opensource.org/licenses/MIT MIT |
| 14 | 14 | */ |
| 15 | -class TypeRegistry |
|
| 16 | -{
|
|
| 15 | +class TypeRegistry |
|
| 16 | +{ |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Map of format-name => class-name |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function add(string $classname): void |
| 31 | 31 | {
|
| 32 | - if (is_subclass_of($classname, ICustomType::class)) {
|
|
| 33 | - foreach ($classname::getFormats() as $format) {
|
|
| 32 | + if (is_subclass_of($classname, ICustomType::class)) { |
|
| 33 | + foreach ($classname::getFormats() as $format) { |
|
| 34 | 34 | $this->formats[$format] = $classname; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -14,61 +14,61 @@ |
||
| 14 | 14 | class Statement |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - private $command; |
|
| 18 | - private $data; |
|
| 19 | - private $file; |
|
| 20 | - private $line; |
|
| 17 | + private $command; |
|
| 18 | + private $data; |
|
| 19 | + private $file; |
|
| 20 | + private $line; |
|
| 21 | 21 | |
| 22 | - public function __construct($command, $data = null, $file = null, $line = null) |
|
| 23 | - { |
|
| 24 | - $this->command = $command; |
|
| 25 | - $this->data = $data; |
|
| 26 | - $this->file = $file; |
|
| 27 | - $this->line = $line; |
|
| 28 | - } |
|
| 22 | + public function __construct($command, $data = null, $file = null, $line = null) |
|
| 23 | + { |
|
| 24 | + $this->command = $command; |
|
| 25 | + $this->data = $data; |
|
| 26 | + $this->file = $file; |
|
| 27 | + $this->line = $line; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function __toString() |
|
| 31 | - { |
|
| 32 | - $message = "Command '{$this->command}'"; |
|
| 33 | - $message .= $this->data ? " with data '{$this->data}'" : ' without data'; |
|
| 34 | - $message .= $this->file ? " from static text" : " in file '{$this->file}' on line {$this->line}"; |
|
| 35 | - return $message; |
|
| 36 | - } |
|
| 30 | + public function __toString() |
|
| 31 | + { |
|
| 32 | + $message = "Command '{$this->command}'"; |
|
| 33 | + $message .= $this->data ? " with data '{$this->data}'" : ' without data'; |
|
| 34 | + $message .= $this->file ? " from static text" : " in file '{$this->file}' on line {$this->line}"; |
|
| 35 | + return $message; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Get the command part of this statement |
|
| 40 | - * @return string single word, without spaces |
|
| 41 | - */ |
|
| 42 | - public function getCommand(): string |
|
| 43 | - { |
|
| 44 | - return $this->command; |
|
| 45 | - } |
|
| 38 | + /** |
|
| 39 | + * Get the command part of this statement |
|
| 40 | + * @return string single word, without spaces |
|
| 41 | + */ |
|
| 42 | + public function getCommand(): string |
|
| 43 | + { |
|
| 44 | + return $this->command; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Get the data of this statement |
|
| 49 | - * @return string|null may contain spaces |
|
| 50 | - */ |
|
| 51 | - public function getData(): ?string |
|
| 52 | - { |
|
| 53 | - return $this->data; |
|
| 54 | - } |
|
| 47 | + /** |
|
| 48 | + * Get the data of this statement |
|
| 49 | + * @return string|null may contain spaces |
|
| 50 | + */ |
|
| 51 | + public function getData(): ?string |
|
| 52 | + { |
|
| 53 | + return $this->data; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Get the file (if available) where this statement was parsed from |
|
| 58 | - * @return string|null the full filename or null of from static text |
|
| 59 | - */ |
|
| 60 | - public function getFile(): ?string |
|
| 61 | - { |
|
| 62 | - return $this->file; |
|
| 63 | - } |
|
| 56 | + /** |
|
| 57 | + * Get the file (if available) where this statement was parsed from |
|
| 58 | + * @return string|null the full filename or null of from static text |
|
| 59 | + */ |
|
| 60 | + public function getFile(): ?string |
|
| 61 | + { |
|
| 62 | + return $this->file; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Get the line number where this statement was found |
|
| 67 | - * @return int|null the line number |
|
| 68 | - */ |
|
| 69 | - public function getLine(): ?int |
|
| 70 | - { |
|
| 71 | - return $this->line; |
|
| 72 | - } |
|
| 65 | + /** |
|
| 66 | + * Get the line number where this statement was found |
|
| 67 | + * @return int|null the line number |
|
| 68 | + */ |
|
| 69 | + public function getLine(): ?int |
|
| 70 | + { |
|
| 71 | + return $this->line; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | } |