mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Merge pull request #713 from pahan35/fix-missed-methods-with-same-name
Fix missed methods with same name
This commit is contained in:
@@ -28,7 +28,7 @@ namespace <?= $namespace == '__root' ? '' : trim($namespace, '\\') ?> {
|
|||||||
//Method inherited from <?= $method->getDeclaringClass() ?>
|
//Method inherited from <?= $method->getDeclaringClass() ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?= $method->shouldReturn() ? 'return ': '' ?><?= $method->getRoot() ?>::<?= $method->getName() ?>(<?= $method->getParams() ?>);
|
<?= $method->shouldReturn() ? 'return ': '' ?><?= $method->getRoot() ?>::<?= $method->getRealName() ?>(<?= $method->getParams() ?>);
|
||||||
}
|
}
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ namespace <?= $namespace == '__root' ? '' : trim($namespace, '\\') ?> {
|
|||||||
//Method inherited from <?= $method->getDeclaringClass() ?>
|
//Method inherited from <?= $method->getDeclaringClass() ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?= $method->shouldReturn() ? 'return ': '' ?><?= $method->getRoot() ?>::<?= $method->getName() ?>(<?= $method->getParams() ?>);
|
<?= $method->shouldReturn() ? 'return ': '' ?><?= $method->getRoot() ?>::<?= $method->getRealName() ?>(<?= $method->getParams() ?>);
|
||||||
}
|
}
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endif; ?>}
|
<?php endif; ?>}
|
||||||
|
|||||||
+1
-1
@@ -310,7 +310,7 @@ class Alias
|
|||||||
$method = new \ReflectionMethod($className, $name);
|
$method = new \ReflectionMethod($className, $name);
|
||||||
$class = new \ReflectionClass($className);
|
$class = new \ReflectionClass($className);
|
||||||
|
|
||||||
if (!in_array($method->name, $this->usedMethods)) {
|
if (!in_array($magic, $this->usedMethods)) {
|
||||||
if ($class !== $this->root) {
|
if ($class !== $this->root) {
|
||||||
$this->methods[] = new Method($method, $this->alias, $class, $magic, $this->interfaces);
|
$this->methods[] = new Method($method, $this->alias, $class, $magic, $this->interfaces);
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-22
@@ -17,36 +17,30 @@ class Macro extends Method
|
|||||||
* @param array $interfaces
|
* @param array $interfaces
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\ReflectionFunctionAbstract $method,
|
$method,
|
||||||
$alias,
|
$alias,
|
||||||
$class,
|
$class,
|
||||||
$methodName = null,
|
$methodName = null,
|
||||||
$interfaces = array()
|
$interfaces = array()
|
||||||
) {
|
) {
|
||||||
$this->method = $method;
|
parent::__construct($method, $alias, $class, $methodName, $interfaces);
|
||||||
$this->interfaces = $interfaces;
|
}
|
||||||
$this->name = $methodName ?: $method->name;
|
|
||||||
$this->namespace = $class->getNamespaceName();
|
|
||||||
|
|
||||||
//Create a DocBlock and serializer instance
|
/**
|
||||||
|
* @param \ReflectionFunctionAbstract $method
|
||||||
|
*/
|
||||||
|
protected function initPhpDoc($method)
|
||||||
|
{
|
||||||
$this->phpdoc = new DocBlock($method);
|
$this->phpdoc = new DocBlock($method);
|
||||||
|
}
|
||||||
|
|
||||||
//Normalize the description and inherit the docs from parents/interfaces
|
/**
|
||||||
try {
|
* @param \ReflectionFunctionAbstract $method
|
||||||
$this->normalizeParams($this->phpdoc);
|
* @param \ReflectionClass $class
|
||||||
$this->normalizeReturn($this->phpdoc);
|
*/
|
||||||
$this->normalizeDescription($this->phpdoc);
|
protected function initClassDefinedProperties($method, \ReflectionClass $class)
|
||||||
} catch (\Exception $e) {
|
{
|
||||||
}
|
$this->namespace = $class->getNamespaceName();
|
||||||
|
|
||||||
//Get the parameters, including formatted default values
|
|
||||||
$this->getParameters($method);
|
|
||||||
|
|
||||||
//Make the method static
|
|
||||||
$this->phpdoc->appendTag(Tag::createInstance('@static', $this->phpdoc));
|
|
||||||
|
|
||||||
//Reference the 'real' function in the declaringclass
|
|
||||||
$this->declaringClassName = '\\' . ltrim($class->name, '\\');
|
$this->declaringClassName = '\\' . ltrim($class->name, '\\');
|
||||||
$this->root = '\\' . ltrim($class->getName(), '\\');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-7
@@ -26,29 +26,32 @@ class Method
|
|||||||
protected $method;
|
protected $method;
|
||||||
|
|
||||||
protected $output = '';
|
protected $output = '';
|
||||||
|
protected $declaringClassName;
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $namespace;
|
protected $namespace;
|
||||||
protected $params = array();
|
protected $params = array();
|
||||||
protected $params_with_default = array();
|
protected $params_with_default = array();
|
||||||
protected $interfaces = array();
|
protected $interfaces = array();
|
||||||
|
protected $real_name;
|
||||||
protected $return = null;
|
protected $return = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \ReflectionMethod $method
|
* @param \ReflectionMethod|\ReflectionFunctionAbstract $method
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @param \ReflectionClass $class
|
* @param \ReflectionClass $class
|
||||||
* @param string|null $methodName
|
* @param string|null $methodName
|
||||||
* @param array $interfaces
|
* @param array $interfaces
|
||||||
*/
|
*/
|
||||||
public function __construct(\ReflectionMethod $method, $alias, $class, $methodName = null, $interfaces = array())
|
public function __construct($method, $alias, $class, $methodName = null, $interfaces = array())
|
||||||
{
|
{
|
||||||
$this->method = $method;
|
$this->method = $method;
|
||||||
$this->interfaces = $interfaces;
|
$this->interfaces = $interfaces;
|
||||||
$this->name = $methodName ?: $method->name;
|
$this->name = $methodName ?: $method->name;
|
||||||
$this->namespace = $method->getDeclaringClass()->getNamespaceName();
|
$this->real_name = $method->name;
|
||||||
|
$this->initClassDefinedProperties($method, $class);
|
||||||
|
|
||||||
//Create a DocBlock and serializer instance
|
//Create a DocBlock and serializer instance
|
||||||
$this->phpdoc = new DocBlock($method, new Context($this->namespace));
|
$this->initPhpDoc($method);
|
||||||
|
|
||||||
//Normalize the description and inherit the docs from parents/interfaces
|
//Normalize the description and inherit the docs from parents/interfaces
|
||||||
try {
|
try {
|
||||||
@@ -64,12 +67,29 @@ class Method
|
|||||||
//Make the method static
|
//Make the method static
|
||||||
$this->phpdoc->appendTag(Tag::createInstance('@static', $this->phpdoc));
|
$this->phpdoc->appendTag(Tag::createInstance('@static', $this->phpdoc));
|
||||||
|
|
||||||
//Reference the 'real' function in the declaringclass
|
//Reference the 'real' function in the declaring class
|
||||||
$declaringClass = $method->getDeclaringClass();
|
|
||||||
$this->declaringClassName = '\\' . ltrim($declaringClass->name, '\\');
|
|
||||||
$this->root = '\\' . ltrim($class->getName(), '\\');
|
$this->root = '\\' . ltrim($class->getName(), '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \ReflectionMethod $method
|
||||||
|
*/
|
||||||
|
protected function initPhpDoc($method)
|
||||||
|
{
|
||||||
|
$this->phpdoc = new DocBlock($method, new Context($this->namespace));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \ReflectionMethod $method
|
||||||
|
* @param \ReflectionClass $class
|
||||||
|
*/
|
||||||
|
protected function initClassDefinedProperties($method, \ReflectionClass $class)
|
||||||
|
{
|
||||||
|
$declaringClass = $method->getDeclaringClass();
|
||||||
|
$this->namespace = $declaringClass->getNamespaceName();
|
||||||
|
$this->declaringClassName = '\\' . ltrim($declaringClass->name, '\\');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the class wherein the function resides
|
* Get the class wherein the function resides
|
||||||
*
|
*
|
||||||
@@ -112,6 +132,16 @@ class Method
|
|||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the real method name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRealName()
|
||||||
|
{
|
||||||
|
return $this->real_name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parameters for this method
|
* Get the parameters for this method
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user