mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
981ff45b43 | ||
|
|
8174730714 | ||
|
|
ae5b623cf2 | ||
|
|
eff51d41b3 | ||
|
|
b14d983f74 | ||
|
|
1fdc866fb0 | ||
|
|
d7359b86d4 | ||
|
|
5d8d93273f | ||
|
|
30e5300e49 | ||
|
|
593e0d4aa7 | ||
|
|
e7d4cb322f | ||
|
|
5318f485e2 | ||
|
|
7db1843473 | ||
|
|
1989d0e794 |
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.6
|
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
- 7.2
|
- 7.2
|
||||||
@@ -17,7 +16,7 @@ cache:
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.6
|
- php: 7.0
|
||||||
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
|
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
<?= '<?php' ?>
|
<?= '<?php' ?>
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var \Barryvdh\LaravelIdeHelper\Alias[][] $namespaces_by_alias_ns
|
||||||
|
* @var \Barryvdh\LaravelIdeHelper\Alias[][] $namespaces_by_extends_ns
|
||||||
|
* @var bool $include_fluent
|
||||||
|
* @var string $helpers
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
|
||||||
@@ -28,7 +36,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 +58,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; ?>}
|
||||||
|
|||||||
+2
-2
@@ -171,7 +171,7 @@ class Alias
|
|||||||
/**
|
/**
|
||||||
* Get the methods found by this Alias
|
* Get the methods found by this Alias
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array|Method[]
|
||||||
*/
|
*/
|
||||||
public function getMethods()
|
public function getMethods()
|
||||||
{
|
{
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ class GeneratorCommand extends Command
|
|||||||
|
|
||||||
if ($written !== false) {
|
if ($written !== false) {
|
||||||
$this->info("A new helper file was written to $filename");
|
$this->info("A new helper file was written to $filename");
|
||||||
Eloquent::writeEloquentModelHelper($this, $this->files);
|
|
||||||
} else {
|
} else {
|
||||||
$this->error("The helper file could not be created at $filename");
|
$this->error("The helper file could not be created at $filename");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -444,6 +444,9 @@ class ModelsCommand extends Command
|
|||||||
array_shift($args);
|
array_shift($args);
|
||||||
$this->setMethod($name, '\Illuminate\Database\Eloquent\Builder|\\' . $reflection->class, $args);
|
$this->setMethod($name, '\Illuminate\Database\Eloquent\Builder|\\' . $reflection->class, $args);
|
||||||
}
|
}
|
||||||
|
} elseif (in_array($method, ['query', 'newQuery', 'newModelQuery'])) {
|
||||||
|
$reflection = new \ReflectionClass($model);
|
||||||
|
$this->setMethod($method, '\Illuminate\Database\Eloquent\Builder|\\' . $reflection->getName());
|
||||||
} elseif (!method_exists('Illuminate\Database\Eloquent\Model', $method)
|
} elseif (!method_exists('Illuminate\Database\Eloquent\Model', $method)
|
||||||
&& !Str::startsWith($method, 'get')
|
&& !Str::startsWith($method, 'get')
|
||||||
) {
|
) {
|
||||||
|
|||||||
+7
-3
@@ -272,9 +272,13 @@ class Generator
|
|||||||
$facades = array_merge($facades, $this->config->get('app.aliases', []));
|
$facades = array_merge($facades, $this->config->get('app.aliases', []));
|
||||||
|
|
||||||
// Only return the ones that actually exist
|
// Only return the ones that actually exist
|
||||||
return array_filter($facades, function ($alias) {
|
return array_filter(
|
||||||
return class_exists($alias);
|
$facades,
|
||||||
});
|
function ($alias) {
|
||||||
|
return class_exists($alias);
|
||||||
|
},
|
||||||
|
ARRAY_FILTER_USE_KEY
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+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