Compare commits

..
14 Commits
Author SHA1 Message Date
Barry vd. Heuvel 981ff45b43 Merge pull request #707 from crhg/fix_getAliases
Fix alias class existence determination #698
2018-10-06 11:35:51 +02:00
Barry vd. Heuvel 8174730714 Merge pull request #714 from pahan35/fix-missed-autocomplete-in-header-view
Fix missed autocomplete in helper view
2018-10-06 11:34:14 +02:00
Barry vd. Heuvel ae5b623cf2 Merge pull request #713 from pahan35/fix-missed-methods-with-same-name
Fix missed methods with same name
2018-10-06 11:33:25 +02:00
Pavlo Zhukov eff51d41b3 Add missed getRealName() call for $namespaces_by_alias group 2018-10-01 03:25:34 +03:00
Pavlo Zhukov b14d983f74 Change comments style to allow folding and make its clear 2018-10-01 00:50:28 +03:00
Pavlo Zhukov 1fdc866fb0 Fix missed autocomplete in helper view 2018-10-01 00:39:40 +03:00
Pavlo Zhukov d7359b86d4 Avoid code duplication in constructors 2018-10-01 00:20:54 +03:00
Pavlo Zhukov 5d8d93273f Fix missed helpers for abstract methods the same name but different classes 2018-10-01 00:02:03 +03:00
Manabu Matsui 30e5300e49 Fix alias class existence determination 2018-09-14 10:16:13 +09:00
Barry vd. Heuvel 593e0d4aa7 Merge pull request #701 from brendt/master
Add ::query support
2018-09-07 12:07:33 +02:00
Brent Roose e7d4cb322f Update ModelsCommand.php 2018-09-07 10:29:59 +02:00
Brent Roose 5318f485e2 Add ::query support 2018-09-07 10:27:20 +02:00
Barry vd. Heuvel 7db1843473 Remove Eloquent mixin thing 2018-09-06 20:41:09 +02:00
Barry vd. Heuvel 1989d0e794 Update .travis.yml 2018-09-04 16:19:48 +02:00
8 changed files with 76 additions and 39 deletions
+1 -2
View File
@@ -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:
+10 -2
View File
@@ -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
View File
@@ -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);
} }
-1
View File
@@ -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");
} }
+3
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
* *