diff --git a/Utils/Parser/Php/FunctionParser.php b/Utils/Parser/Php/FunctionParser.php index e24eccd09..06c51bd39 100644 --- a/Utils/Parser/Php/FunctionParser.php +++ b/Utils/Parser/Php/FunctionParser.php @@ -46,13 +46,29 @@ class FunctionParser private $parameters = []; + private $body = ''; + public function setName(string $name) { $this->name = $name; } public function getName() : string { - return $this->string; + return $this->name; + } + + public function seBody(string $body) { + $this->body = $body; + } + + public function getBody() : string + { + return $this->body; + } + + public function removeBody() + { + $this->body = null; } public function setVisibility(string $visibility) @@ -87,6 +103,12 @@ class FunctionParser public function setAbstract(bool $abstract) { $this->isAbstract = $abstract; + + if($this->isAbstract) { + $this->body = null; + } elseif(!$this->isAbstract && !isset($this->body)) { + $this->body = ''; + } } public function isAbstract() : bool @@ -109,6 +131,20 @@ class FunctionParser return $this->return; } + public function addParameter(string $name, string $typehint, $default = null) + { + $this->parameters[$name]['name'] = $name; + $this->parameters[$name]['typehint'] = $typehint; + + if(isset($default)) { + if($default === 'null') { + $default = null; + } + + $this->parameters[$name]['default'] = $default; + } + } + public function parse() : string { $function = ''; @@ -137,7 +173,12 @@ class FunctionParser $member .= rtrim($parameters, ', ') . ') '; $member .= ($this->return ?? '') . PHP_EOL; - $member .= '{' . PHP_EOL . $this->body . PHP_EOL . '}'; + + if(isset($this->body)) { + $member .= '{' . PHP_EOL . $this->body . PHP_EOL . '}'; + } else { + $member .= ';'; + } return $member; } diff --git a/Utils/Parser/Php/MemberParser.php b/Utils/Parser/Php/MemberParser.php index b12ebd161..f7580a8be 100644 --- a/Utils/Parser/Php/MemberParser.php +++ b/Utils/Parser/Php/MemberParser.php @@ -48,7 +48,7 @@ class MemberParser public function getName() : string { - return $this->string; + return $this->name; } public function setVisibility(string $visibility)