mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
Re-format source code of Alias class
This commit is contained in:
+19
-16
@@ -54,7 +54,7 @@ class Alias
|
|||||||
$this->detectNamespace();
|
$this->detectNamespace();
|
||||||
$this->detectClassType();
|
$this->detectClassType();
|
||||||
|
|
||||||
if($facade === '\Illuminate\Database\Eloquent\Model'){
|
if ($facade === '\Illuminate\Database\Eloquent\Model') {
|
||||||
$this->usedMethods = array('decrement', 'increment');
|
$this->usedMethods = array('decrement', 'increment');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,8 +70,8 @@ class Alias
|
|||||||
foreach ($classes as $class) {
|
foreach ($classes as $class) {
|
||||||
if (class_exists($class) || interface_exists($class)) {
|
if (class_exists($class) || interface_exists($class)) {
|
||||||
$this->classes[] = $class;
|
$this->classes[] = $class;
|
||||||
}else{
|
} else {
|
||||||
echo "Class not exists: $class\r\n";
|
$this->error('Class not exists: ' . $class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,11 +86,11 @@ class Alias
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the classtype, 'interface' or 'class'
|
* Get the classType, 'interface' or 'class'
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getClasstype()
|
public function getClassType()
|
||||||
{
|
{
|
||||||
return $this->classType;
|
return $this->classType;
|
||||||
}
|
}
|
||||||
@@ -117,10 +117,14 @@ class Alias
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the short name (without namespace)
|
* Return the short name (without namespace)
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getShortName(){
|
public function getShortName()
|
||||||
|
{
|
||||||
return $this->short;
|
return $this->short;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the namespace from the alias
|
* Get the namespace from the alias
|
||||||
*
|
*
|
||||||
@@ -134,7 +138,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()
|
||||||
{
|
{
|
||||||
@@ -152,7 +156,7 @@ class Alias
|
|||||||
$nsParts = explode('\\', $this->alias);
|
$nsParts = explode('\\', $this->alias);
|
||||||
$this->short = array_pop($nsParts);
|
$this->short = array_pop($nsParts);
|
||||||
$this->namespace = implode('\\', $nsParts);
|
$this->namespace = implode('\\', $nsParts);
|
||||||
}else{
|
} else {
|
||||||
$this->short = $this->alias;
|
$this->short = $this->alias;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,10 +205,10 @@ class Alias
|
|||||||
//When the database connection is not set, some classes will be skipped
|
//When the database connection is not set, some classes will be skipped
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
$this->error(
|
$this->error(
|
||||||
"PDOException: " . $e->getMessage() . "\nPlease configure your database connection correctly, or use the sqlite memory driver (-M). Skipping $facade."
|
'PDOException: ' . $e->getMessage() . "\nPlease configure your database connection correctly, or use the sqlite memory driver (-M). Skipping $facade."
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->error("Exception: " . $e->getMessage() . "\nSkipping $facade.");
|
$this->error('Exception: ' . $e->getMessage() . "\nSkipping $facade.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,16 +231,16 @@ class Alias
|
|||||||
*/
|
*/
|
||||||
protected function addMagicMethods()
|
protected function addMagicMethods()
|
||||||
{
|
{
|
||||||
foreach($this->magicMethods as $magic => $real){
|
foreach ($this->magicMethods as $magic => $real) {
|
||||||
list($className, $name) = explode('::', $real);
|
list($className, $name) = explode('::', $real);
|
||||||
if(!class_exists($className) && !interface_exists($className)){
|
if (!class_exists($className) && !interface_exists($className)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$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($method->name, $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);
|
||||||
}
|
}
|
||||||
$this->usedMethods[] = $magic;
|
$this->usedMethods[] = $magic;
|
||||||
@@ -251,7 +255,6 @@ class Alias
|
|||||||
*/
|
*/
|
||||||
protected function detectMethods()
|
protected function detectMethods()
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach ($this->classes as $class) {
|
foreach ($this->classes as $class) {
|
||||||
$reflection = new \ReflectionClass($class);
|
$reflection = new \ReflectionClass($class);
|
||||||
|
|
||||||
@@ -274,7 +277,7 @@ class Alias
|
|||||||
/**
|
/**
|
||||||
* Output an error.
|
* Output an error.
|
||||||
*
|
*
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function error($string)
|
protected function error($string)
|
||||||
|
|||||||
Reference in New Issue
Block a user