mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-19 10:33:11 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19aa77ac49 | ||
|
|
25ec6bd1ea | ||
|
|
1b608fc446 | ||
|
|
09055582af | ||
|
|
4cfcabb63d | ||
|
|
cbfd53e0f9 | ||
|
|
fd11d89fa7 | ||
|
|
7f335274bf | ||
|
|
c01769aebd |
@@ -184,7 +184,6 @@ class Alias
|
|||||||
|
|
||||||
//If it doesn't exist, skip it
|
//If it doesn't exist, skip it
|
||||||
if (!class_exists($root) && !interface_exists($root)) {
|
if (!class_exists($root) && !interface_exists($root)) {
|
||||||
$this->error("Class $root is not found.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ class ModelsCommand extends Command
|
|||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->error("Exception: " . $e->getMessage() . "\nCould not analyze class $name.");
|
$this->error("Exception: " . $e->getMessage() . "\nCould not analyze class $name.");
|
||||||
}
|
}
|
||||||
|
} elseif (interface_exists($name) || (function_exists('trait_exists') && trait_exists($name))) {
|
||||||
|
$this->info("Skipping interface/trait $name");
|
||||||
} else {
|
} else {
|
||||||
$this->error("Class $name does not exist");
|
$this->error("Class $name does not exist");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ class Generator
|
|||||||
protected function detectDrivers()
|
protected function detectDrivers()
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
if (class_exists('Cache')) {
|
if (class_exists('Auth')) {
|
||||||
$class = get_class(\Auth::driver());
|
$class = get_class(\Auth::driver());
|
||||||
$this->extra['Auth'] = array($class);
|
$this->extra['Auth'] = array($class);
|
||||||
$this->interfaces['\Illuminate\Auth\UserProviderInterface'] = $class;
|
$this->interfaces['\Illuminate\Auth\UserProviderInterface'] = $class;
|
||||||
|
|||||||
+24
-13
@@ -52,9 +52,9 @@ class Method
|
|||||||
|
|
||||||
//Normalize the description and inherit the docs from parents/interfaces
|
//Normalize the description and inherit the docs from parents/interfaces
|
||||||
try {
|
try {
|
||||||
$this->normalizeDescription();
|
$this->normalizeParams($this->phpdoc);
|
||||||
$this->normalizeParams();
|
$this->normalizeReturn($this->phpdoc);
|
||||||
$this->normalizeReturn();
|
$this->normalizeDescription($this->phpdoc);
|
||||||
} catch (\Exception $e) {}
|
} catch (\Exception $e) {}
|
||||||
|
|
||||||
//Get the parameters, including formatted default values
|
//Get the parameters, including formatted default values
|
||||||
@@ -136,11 +136,12 @@ class Method
|
|||||||
/**
|
/**
|
||||||
* Get the description and get the inherited docs.
|
* Get the description and get the inherited docs.
|
||||||
*
|
*
|
||||||
|
* @param DocBlock $phpdoc
|
||||||
*/
|
*/
|
||||||
protected function normalizeDescription()
|
protected function normalizeDescription(DocBlock $phpdoc)
|
||||||
{
|
{
|
||||||
//Get the short + long description from the DocBlock
|
//Get the short + long description from the DocBlock
|
||||||
$description = $this->phpdoc->getText();
|
$description = $phpdoc->getText();
|
||||||
|
|
||||||
//Loop through parents/interfaces, to fill in {@inheritdoc}
|
//Loop through parents/interfaces, to fill in {@inheritdoc}
|
||||||
if (strpos($description, '{@inheritdoc}') !== false) {
|
if (strpos($description, '{@inheritdoc}') !== false) {
|
||||||
@@ -148,14 +149,18 @@ class Method
|
|||||||
$inheritDescription = $inheritdoc->getText();
|
$inheritDescription = $inheritdoc->getText();
|
||||||
|
|
||||||
$description = str_replace('{@inheritdoc}', $inheritDescription, $description);
|
$description = str_replace('{@inheritdoc}', $inheritDescription, $description);
|
||||||
$this->phpdoc->setText($description);
|
$phpdoc->setText($description);
|
||||||
|
|
||||||
|
$this->normalizeParams($inheritdoc);
|
||||||
|
$this->normalizeReturn($inheritdoc);
|
||||||
|
|
||||||
//Add the tags that are inherited
|
//Add the tags that are inherited
|
||||||
$inheritTags = $inheritdoc->getTags();
|
$inheritTags = $inheritdoc->getTags();
|
||||||
if ($inheritTags) {
|
if ($inheritTags) {
|
||||||
|
/** @var Tag $tag */
|
||||||
foreach ($inheritTags as $tag) {
|
foreach ($inheritTags as $tag) {
|
||||||
$tag->setDocBlock();
|
$tag->setDocBlock();
|
||||||
$this->phpdoc->appendTag($tag);
|
$phpdoc->appendTag($tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,11 +168,13 @@ class Method
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize the parameters
|
* Normalize the parameters
|
||||||
|
*
|
||||||
|
* @param DocBlock $phpdoc
|
||||||
*/
|
*/
|
||||||
protected function normalizeParams()
|
protected function normalizeParams(DocBlock $phpdoc)
|
||||||
{
|
{
|
||||||
//Get the return type and adjust them for beter autocomplete
|
//Get the return type and adjust them for beter autocomplete
|
||||||
$paramTags = $this->phpdoc->getTagsByName('param');
|
$paramTags = $phpdoc->getTagsByName('param');
|
||||||
if ($paramTags) {
|
if ($paramTags) {
|
||||||
/** @var ParamTag $tag */
|
/** @var ParamTag $tag */
|
||||||
foreach($paramTags as $tag){
|
foreach($paramTags as $tag){
|
||||||
@@ -184,11 +191,13 @@ class Method
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize the return tag (make full namespace, replace interfaces)
|
* Normalize the return tag (make full namespace, replace interfaces)
|
||||||
|
*
|
||||||
|
* @param DocBlock $phpdoc
|
||||||
*/
|
*/
|
||||||
protected function normalizeReturn()
|
protected function normalizeReturn(DocBlock $phpdoc)
|
||||||
{
|
{
|
||||||
//Get the return type and adjust them for beter autocomplete
|
//Get the return type and adjust them for beter autocomplete
|
||||||
$returnTags = $this->phpdoc->getTagsByName('return');
|
$returnTags = $phpdoc->getTagsByName('return');
|
||||||
if ($returnTags) {
|
if ($returnTags) {
|
||||||
/** @var ReturnTag $tag */
|
/** @var ReturnTag $tag */
|
||||||
$tag = reset($returnTags);
|
$tag = reset($returnTags);
|
||||||
@@ -275,7 +284,7 @@ class Method
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \ReflectionMethod $reflectionMethod
|
* @param \ReflectionMethod $reflectionMethod
|
||||||
* @return string
|
* @return DocBlock
|
||||||
*/
|
*/
|
||||||
protected function getInheritDoc($reflectionMethod)
|
protected function getInheritDoc($reflectionMethod)
|
||||||
{
|
{
|
||||||
@@ -288,7 +297,9 @@ class Method
|
|||||||
$method = $reflectionMethod->getPrototype();
|
$method = $reflectionMethod->getPrototype();
|
||||||
}
|
}
|
||||||
if ($method) {
|
if ($method) {
|
||||||
$phpdoc = new DocBlock($method);
|
$namespace = $method->getDeclaringClass()->getNamespaceName();
|
||||||
|
$phpdoc = new DocBlock($method, new Context($namespace));
|
||||||
|
|
||||||
if (strpos($phpdoc->getText(), '{@inheritdoc}') !== false) {
|
if (strpos($phpdoc->getText(), '{@inheritdoc}') !== false) {
|
||||||
//Not at the end yet, try another parent/interface..
|
//Not at the end yet, try another parent/interface..
|
||||||
return $this->getInheritDoc($method);
|
return $this->getInheritDoc($method);
|
||||||
|
|||||||
@@ -71,6 +71,17 @@ return array(
|
|||||||
'emergency' => 'Monolog\Logger::addEmergency',
|
'emergency' => 'Monolog\Logger::addEmergency',
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Interface implementations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These interfaces will be replaced with the implementing class. Some interfaces
|
||||||
|
| are detected by the helpers, others can be listed below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
'interfaces' => array(
|
'interfaces' => array(
|
||||||
'\Illuminate\Auth\UserInterface' => '\User',
|
'\Illuminate\Auth\UserInterface' => '\User',
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace <?= $namespace == '__root' ? '' : $namespace ?>{
|
|||||||
<?= $alias->getClassType() ?> <?= $alias->getAlias() ?> <?= $alias->getExtends() ? 'extends ' . $alias->getExtends() : '' ?>{
|
<?= $alias->getClassType() ?> <?= $alias->getAlias() ?> <?= $alias->getExtends() ? 'extends ' . $alias->getExtends() : '' ?>{
|
||||||
<?php foreach($alias->getMethods() as $method): ?>
|
<?php foreach($alias->getMethods() as $method): ?>
|
||||||
|
|
||||||
<?= trim($method->getDocComment()) ?>
|
<?= trim($method->getDocComment(' ')) ?>
|
||||||
|
|
||||||
public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>){<?php if($method->getDeclaringClass() !== $method->getRoot()): ?>
|
public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>){<?php if($method->getDeclaringClass() !== $method->getRoot()): ?>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user