Skip to content

Commit

Permalink
fix: Add logic for adding inherited method info
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Sep 18, 2024
1 parent 74b3b1e commit 1b03a01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Compiler/ClassReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function compile()

foreach ($this->class->getMethods() as $method) {
$method = new Method($method);
$method->setCurrentClass($this->class);
$contents .= $method->compile();
}

Expand Down
13 changes: 13 additions & 0 deletions lib/Compiler/Method/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class Method implements CompilerInterface
*/
public $method;

protected $class;

/**
* ClassMethodListCompiler constructor.
*
Expand All @@ -37,6 +39,11 @@ public function __construct($method)
$this->method = new MethodReflection($method);
}

public function setCurrentClass($class)
{
$this->class = $class;
}

/**
* Compile.
*
Expand Down Expand Up @@ -82,6 +89,12 @@ public function compile()
// Return Tag
$contents .= (new Return_($this->method))->compile();

if (!empty($this->class->getParentMethods())
&& in_array($this->method->reflection->getFqsen()->__toString(), array_keys($this->class->getParentMethods()))
) {
// @todo: Add info about inherited method and possibly a link to the parent class.
}

if ($this->method->hasParameters()) {
$paramsTable = new Table($this->method->getParameters());
$contents .= $paramsTable->compile();
Expand Down
10 changes: 10 additions & 0 deletions lib/Reflection/ClassReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ public function getInterfaces()
{
return $this->reflection->getInterfaces();
}

public function getParentMethods() : array
{
return $this->parentMethods;
}

public function getParentProperties() : array
{
return $this->parentProperties;
}
}

0 comments on commit 1b03a01

Please sign in to comment.