mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-22 06:18:41 +00:00
Minor bug fixes and function body.
This commit is contained in:
parent
907c7b6f49
commit
0cb3c0b749
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class MemberParser
|
|||
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->string;
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setVisibility(string $visibility)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user