From 1b03a01f4b573858a05c516b6e0af7c923f83d2a Mon Sep 17 00:00:00 2001 From: Lukas Gaechter Date: Tue, 2 Jul 2024 23:26:22 +0200 Subject: [PATCH] fix: Add logic for adding inherited method info --- lib/Compiler/ClassReference.php | 1 + lib/Compiler/Method/Method.php | 13 +++++++++++++ lib/Reflection/ClassReflection.php | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/lib/Compiler/ClassReference.php b/lib/Compiler/ClassReference.php index e37161d..8659b01 100644 --- a/lib/Compiler/ClassReference.php +++ b/lib/Compiler/ClassReference.php @@ -74,6 +74,7 @@ public function compile() foreach ($this->class->getMethods() as $method) { $method = new Method($method); + $method->setCurrentClass($this->class); $contents .= $method->compile(); } diff --git a/lib/Compiler/Method/Method.php b/lib/Compiler/Method/Method.php index d92b4b7..07ae695 100644 --- a/lib/Compiler/Method/Method.php +++ b/lib/Compiler/Method/Method.php @@ -27,6 +27,8 @@ class Method implements CompilerInterface */ public $method; + protected $class; + /** * ClassMethodListCompiler constructor. * @@ -37,6 +39,11 @@ public function __construct($method) $this->method = new MethodReflection($method); } + public function setCurrentClass($class) + { + $this->class = $class; + } + /** * Compile. * @@ -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(); diff --git a/lib/Reflection/ClassReflection.php b/lib/Reflection/ClassReflection.php index 583877d..7df9aa5 100644 --- a/lib/Reflection/ClassReflection.php +++ b/lib/Reflection/ClassReflection.php @@ -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; + } }