mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f677edc14 | ||
|
|
1b611d7f80 | ||
|
|
a233d5bd5a | ||
|
|
cfa9a81d65 | ||
|
|
dcf76c1a81 | ||
|
|
bef8158d02 | ||
|
|
8381a2ebdd | ||
|
|
6bab45b8c2 | ||
|
|
2617352869 | ||
|
|
ce275a9bf2 | ||
|
|
b7b835bf09 | ||
|
|
b0481aef33 | ||
|
|
f80887914b | ||
|
|
f4ae4c4b45 | ||
|
|
6a27c5df68 | ||
|
|
7be6afbe5f | ||
|
|
b72689755b | ||
|
|
3cc7d7ccf6 | ||
|
|
18588eacf3 | ||
|
|
da59650fb2 | ||
|
|
fe2890925e | ||
|
|
1d1484025c | ||
|
|
0692626c41 | ||
|
|
90437012b8 | ||
|
|
e743f44011 |
@@ -47,6 +47,8 @@ matrix:
|
|||||||
env: LARAVEL='^6.0' COMPOSER_FLAGS='--prefer-lowest'
|
env: LARAVEL='^6.0' COMPOSER_FLAGS='--prefer-lowest'
|
||||||
- php: '7.4'
|
- php: '7.4'
|
||||||
env: LARAVEL='^6.0' COMPOSER_FLAGS='--prefer-stable' RUN_PHPCS=1
|
env: LARAVEL='^6.0' COMPOSER_FLAGS='--prefer-stable' RUN_PHPCS=1
|
||||||
|
- php: '7.4'
|
||||||
|
env: LARAVEL='^7.0' COMPOSER_FLAGS='--prefer-stable' RUN_PHPCS=1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- phpenv config-rm xdebug.ini || true
|
- phpenv config-rm xdebug.ini || true
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
"illuminate/view": "^5.5|^6|^7",
|
"illuminate/view": "^5.5|^6|^7",
|
||||||
"phpro/grumphp": "^0.17.1",
|
"phpro/grumphp": "^0.17.1",
|
||||||
"squizlabs/php_codesniffer": "^3",
|
"squizlabs/php_codesniffer": "^3",
|
||||||
"orchestra/testbench": "^3|^4",
|
"orchestra/testbench": "^3|^4|^5",
|
||||||
"mockery/mockery": "^1.3"
|
"mockery/mockery": "^1.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
@@ -95,6 +95,18 @@ return array(
|
|||||||
'app',
|
'app',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Models to ignore
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define which models should be ignored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'ignored_models' => array(
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -149,6 +149,14 @@ Models can be ignored using the `--ignore (-I)` option
|
|||||||
php artisan ide-helper:models --ignore="Post,User"
|
php artisan ide-helper:models --ignore="Post,User"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or can be ignored by setting the `ignored_models` config
|
||||||
|
```php
|
||||||
|
'ignored_models' => array(
|
||||||
|
Post::class,
|
||||||
|
Api\User::class
|
||||||
|
),
|
||||||
|
```
|
||||||
|
|
||||||
Note: With namespaces, wrap your model name in double-quotes (`"`): `php artisan ide-helper:models "API\User"`, or escape the slashes (`Api\\User`)
|
Note: With namespaces, wrap your model name in double-quotes (`"`): `php artisan ide-helper:models "API\User"`, or escape the slashes (`Api\\User`)
|
||||||
|
|
||||||
For properly recognition of `Model` methods (i.e. `paginate`, `findOrFail`) you should extend `\Eloquent` or add
|
For properly recognition of `Model` methods (i.e. `paginate`, `findOrFail`) you should extend `\Eloquent` or add
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper file for Laravel 5, to provide autocomplete information to your IDE
|
* A helper file for Laravel, to provide autocomplete information to your IDE
|
||||||
* Generated for Laravel <?= $version ?> on <?= date("Y-m-d H:i:s") ?>.
|
* Generated for Laravel <?= $version ?> on <?= date("Y-m-d H:i:s") ?>.
|
||||||
*
|
*
|
||||||
* This file should not be included in your code, only analyzed by your IDE!
|
* This file should not be included in your code, only analyzed by your IDE!
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ class MetaCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->unregisterClassAutoloadExceptions();
|
||||||
|
|
||||||
$content = $this->view->make('meta', [
|
$content = $this->view->make('meta', [
|
||||||
'bindings' => $bindings,
|
'bindings' => $bindings,
|
||||||
'methods' => $this->methods,
|
'methods' => $this->methods,
|
||||||
@@ -159,4 +161,14 @@ class MetaCommand extends Command
|
|||||||
array('filename', 'F', InputOption::VALUE_OPTIONAL, 'The path to the meta file', $filename),
|
array('filename', 'F', InputOption::VALUE_OPTIONAL, 'The path to the meta file', $filename),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove our custom autoloader that we pushed onto the autoload stack
|
||||||
|
*/
|
||||||
|
private function unregisterClassAutoloadExceptions()
|
||||||
|
{
|
||||||
|
$autoloadFunctions = spl_autoload_functions();
|
||||||
|
$ourAutoloader = array_pop($autoloadFunctions);
|
||||||
|
spl_autoload_unregister($ourAutoloader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+153
-30
@@ -10,19 +10,20 @@
|
|||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Console;
|
namespace Barryvdh\LaravelIdeHelper\Console;
|
||||||
|
|
||||||
use Composer\Autoload\ClassMapGenerator;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Filesystem\Filesystem;
|
|
||||||
use ReflectionClass;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
use Barryvdh\Reflection\DocBlock;
|
use Barryvdh\Reflection\DocBlock;
|
||||||
use Barryvdh\Reflection\DocBlock\Context;
|
use Barryvdh\Reflection\DocBlock\Context;
|
||||||
use Barryvdh\Reflection\DocBlock\Tag;
|
|
||||||
use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
|
use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
|
||||||
|
use Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
use Composer\Autoload\ClassMapGenerator;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use ReflectionClass;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A command to generate autocomplete information for your IDE
|
* A command to generate autocomplete information for your IDE
|
||||||
@@ -58,6 +59,7 @@ class ModelsCommand extends Command
|
|||||||
protected $dirs = array();
|
protected $dirs = array();
|
||||||
protected $reset;
|
protected $reset;
|
||||||
protected $keep_text;
|
protected $keep_text;
|
||||||
|
protected $phpstorm_noinspections;
|
||||||
/**
|
/**
|
||||||
* @var bool[string]
|
* @var bool[string]
|
||||||
*/
|
*/
|
||||||
@@ -96,6 +98,7 @@ class ModelsCommand extends Command
|
|||||||
$model = $this->argument('model');
|
$model = $this->argument('model');
|
||||||
$ignore = $this->option('ignore');
|
$ignore = $this->option('ignore');
|
||||||
$this->reset = $this->option('reset');
|
$this->reset = $this->option('reset');
|
||||||
|
$this->phpstorm_noinspections = $this->option('phpstorm-noinspections');
|
||||||
if ($this->option('smart-reset')) {
|
if ($this->option('smart-reset')) {
|
||||||
$this->keep_text = $this->reset = true;
|
$this->keep_text = $this->reset = true;
|
||||||
}
|
}
|
||||||
@@ -154,6 +157,10 @@ class ModelsCommand extends Command
|
|||||||
array('nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'),
|
array('nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'),
|
||||||
array('reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'),
|
array('reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'),
|
||||||
array('smart-reset', 'r', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'),
|
array('smart-reset', 'r', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'),
|
||||||
|
array('phpstorm-noinspections', 'p', InputOption::VALUE_NONE,
|
||||||
|
'Add PhpFullyQualifiedNameUsageInspection and PhpUnnecessaryFullyQualifiedNameInspection PHPStorm ' .
|
||||||
|
'noinspection tags'
|
||||||
|
),
|
||||||
array('ignore', 'I', InputOption::VALUE_OPTIONAL, 'Which models to ignore', ''),
|
array('ignore', 'I', InputOption::VALUE_OPTIONAL, 'Which models to ignore', ''),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -185,7 +192,10 @@ class ModelsCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ignore = explode(',', $ignore);
|
$ignore = array_merge(
|
||||||
|
explode(',', $ignore),
|
||||||
|
$this->laravel['config']->get('ide-helper.ignored_models', array())
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($models as $name) {
|
foreach ($models as $name) {
|
||||||
if (in_array($name, $ignore)) {
|
if (in_array($name, $ignore)) {
|
||||||
@@ -226,6 +236,7 @@ class ModelsCommand extends Command
|
|||||||
|
|
||||||
$this->getPropertiesFromMethods($model);
|
$this->getPropertiesFromMethods($model);
|
||||||
$this->getSoftDeleteMethods($model);
|
$this->getSoftDeleteMethods($model);
|
||||||
|
$this->getCollectionMethods($model);
|
||||||
$output .= $this->createPhpDocs($name);
|
$output .= $this->createPhpDocs($name);
|
||||||
$ignore[] = $name;
|
$ignore[] = $name;
|
||||||
$this->nullableColumns = [];
|
$this->nullableColumns = [];
|
||||||
@@ -253,12 +264,15 @@ class ModelsCommand extends Command
|
|||||||
$models = array();
|
$models = array();
|
||||||
foreach ($this->dirs as $dir) {
|
foreach ($this->dirs as $dir) {
|
||||||
$dir = base_path() . '/' . $dir;
|
$dir = base_path() . '/' . $dir;
|
||||||
|
$dirs = glob($dir, GLOB_ONLYDIR);
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
if (file_exists($dir)) {
|
if (file_exists($dir)) {
|
||||||
foreach (ClassMapGenerator::createMap($dir) as $model => $path) {
|
foreach (ClassMapGenerator::createMap($dir) as $model => $path) {
|
||||||
$models[] = $model;
|
$models[] = $model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $models;
|
return $models;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +325,8 @@ class ModelsCommand extends Command
|
|||||||
if (!isset($this->properties[$name])) {
|
if (!isset($this->properties[$name])) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
$realType = $this->checkForCustomLaravelCasts($realType);
|
||||||
|
|
||||||
$this->properties[$name]['type'] = $this->getTypeOverride($realType);
|
$this->properties[$name]['type'] = $this->getTypeOverride($realType);
|
||||||
|
|
||||||
if (isset($this->nullableColumns[$name])) {
|
if (isset($this->nullableColumns[$name])) {
|
||||||
@@ -435,7 +451,7 @@ class ModelsCommand extends Command
|
|||||||
$name = Str::snake(substr($method, 3, -9));
|
$name = Str::snake(substr($method, 3, -9));
|
||||||
if (!empty($name)) {
|
if (!empty($name)) {
|
||||||
$reflection = new \ReflectionMethod($model, $method);
|
$reflection = new \ReflectionMethod($model, $method);
|
||||||
$type = $this->getReturnTypeFromDocBlock($reflection);
|
$type = $this->getReturnType($reflection);
|
||||||
$this->setProperty($name, $type, true, null);
|
$this->setProperty($name, $type, true, null);
|
||||||
}
|
}
|
||||||
} elseif (Str::startsWith($method, 'set') && Str::endsWith(
|
} elseif (Str::startsWith($method, 'set') && Str::endsWith(
|
||||||
@@ -505,7 +521,7 @@ class ModelsCommand extends Command
|
|||||||
'morphedByMany' => '\Illuminate\Database\Eloquent\Relations\MorphToMany'
|
'morphedByMany' => '\Illuminate\Database\Eloquent\Relations\MorphToMany'
|
||||||
) as $relation => $impl) {
|
) as $relation => $impl) {
|
||||||
$search = '$this->' . $relation . '(';
|
$search = '$this->' . $relation . '(';
|
||||||
if (stripos($code, $search) || $impl === (string)$type) {
|
if (stripos($code, $search) || ltrim($impl, '\\') === ltrim((string)$type, '\\')) {
|
||||||
//Resolve the relation's model to a Relation object.
|
//Resolve the relation's model to a Relation object.
|
||||||
$methodReflection = new \ReflectionMethod($model, $method);
|
$methodReflection = new \ReflectionMethod($model, $method);
|
||||||
if ($methodReflection->getNumberOfParameters()) {
|
if ($methodReflection->getNumberOfParameters()) {
|
||||||
@@ -560,7 +576,7 @@ class ModelsCommand extends Command
|
|||||||
true,
|
true,
|
||||||
null,
|
null,
|
||||||
'',
|
'',
|
||||||
$this->isRelationForeignKeyNullable($relationObj)
|
$this->isRelationNullable($relation, $relationObj)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -572,22 +588,32 @@ class ModelsCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the foreign key of the relation is nullable
|
* Check if the relation is nullable
|
||||||
*
|
*
|
||||||
* @param Relation $relation
|
* @param string $relation
|
||||||
|
* @param Relation $relationObj
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function isRelationForeignKeyNullable(Relation $relation)
|
protected function isRelationNullable(string $relation, Relation $relationObj): bool
|
||||||
{
|
{
|
||||||
$reflectionObj = new \ReflectionObject($relation);
|
$reflectionObj = new \ReflectionObject($relationObj);
|
||||||
|
|
||||||
|
if (in_array($relation, ['hasOne', 'hasOneThrough', 'morphOne'], true)) {
|
||||||
|
$defaultProp = $reflectionObj->getProperty('withDefault');
|
||||||
|
$defaultProp->setAccessible(true);
|
||||||
|
|
||||||
|
return !$defaultProp->getValue($relationObj);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$reflectionObj->hasProperty('foreignKey')) {
|
if (!$reflectionObj->hasProperty('foreignKey')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fkProp = $reflectionObj->getProperty('foreignKey');
|
$fkProp = $reflectionObj->getProperty('foreignKey');
|
||||||
$fkProp->setAccessible(true);
|
$fkProp->setAccessible(true);
|
||||||
|
|
||||||
return isset($this->nullableColumns[$fkProp->getValue($relation)]);
|
return isset($this->nullableColumns[$fkProp->getValue($relationObj)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -645,6 +671,10 @@ class ModelsCommand extends Command
|
|||||||
$classname = $reflection->getShortName();
|
$classname = $reflection->getShortName();
|
||||||
$originalDoc = $reflection->getDocComment();
|
$originalDoc = $reflection->getDocComment();
|
||||||
$keyword = $this->getClassKeyword($reflection);
|
$keyword = $this->getClassKeyword($reflection);
|
||||||
|
$interfaceNames = array_diff_key(
|
||||||
|
$reflection->getInterfaceNames(),
|
||||||
|
$reflection->getParentClass()->getInterfaceNames()
|
||||||
|
);
|
||||||
|
|
||||||
if ($this->reset) {
|
if ($this->reset) {
|
||||||
$phpdoc = new DocBlock('', new Context($namespace));
|
$phpdoc = new DocBlock('', new Context($namespace));
|
||||||
@@ -674,6 +704,11 @@ class ModelsCommand extends Command
|
|||||||
|
|
||||||
foreach ($this->properties as $name => $property) {
|
foreach ($this->properties as $name => $property) {
|
||||||
$name = "\$$name";
|
$name = "\$$name";
|
||||||
|
|
||||||
|
if ($this->hasCamelCaseModelProperties()) {
|
||||||
|
$name = Str::camel($name);
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($name, $properties)) {
|
if (in_array($name, $properties)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -685,10 +720,6 @@ class ModelsCommand extends Command
|
|||||||
$attr = 'property-read';
|
$attr = 'property-read';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hasCamelCaseModelProperties()) {
|
|
||||||
$name = Str::camel($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tagLine = trim("@{$attr} {$property['type']} {$name} {$property['comment']}");
|
$tagLine = trim("@{$attr} {$property['type']} {$name} {$property['comment']}");
|
||||||
$tag = Tag::createInstance($tagLine, $phpdoc);
|
$tag = Tag::createInstance($tagLine, $phpdoc);
|
||||||
$phpdoc->appendTag($tag);
|
$phpdoc->appendTag($tag);
|
||||||
@@ -708,6 +739,20 @@ class ModelsCommand extends Command
|
|||||||
if ($this->write && ! $phpdoc->getTagsByName('mixin')) {
|
if ($this->write && ! $phpdoc->getTagsByName('mixin')) {
|
||||||
$phpdoc->appendTag(Tag::createInstance("@mixin \\Eloquent", $phpdoc));
|
$phpdoc->appendTag(Tag::createInstance("@mixin \\Eloquent", $phpdoc));
|
||||||
}
|
}
|
||||||
|
if ($this->phpstorm_noinspections) {
|
||||||
|
/**
|
||||||
|
* Facades, Eloquent API
|
||||||
|
* @see https://www.jetbrains.com/help/phpstorm/php-fully-qualified-name-usage.html
|
||||||
|
*/
|
||||||
|
$phpdoc->appendTag(Tag::createInstance("@noinspection PhpFullyQualifiedNameUsageInspection", $phpdoc));
|
||||||
|
/**
|
||||||
|
* Relations, other models in the same namespace
|
||||||
|
* @see https://www.jetbrains.com/help/phpstorm/php-unnecessary-fully-qualified-name.html
|
||||||
|
*/
|
||||||
|
$phpdoc->appendTag(
|
||||||
|
Tag::createInstance("@noinspection PhpUnnecessaryFullyQualifiedNameInspection", $phpdoc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$serializer = new DocBlockSerializer();
|
$serializer = new DocBlockSerializer();
|
||||||
$serializer->getDocComment($phpdoc);
|
$serializer->getDocComment($phpdoc);
|
||||||
@@ -732,8 +777,14 @@ class ModelsCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}class {$classname} extends \Eloquent {}\n}\n\n";
|
$output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}class {$classname} extends \Eloquent ";
|
||||||
return $output;
|
|
||||||
|
if ($interfaceNames) {
|
||||||
|
$interfaces = implode(', \\', $interfaceNames);
|
||||||
|
$output .= "implements \\{$interfaces} ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output . "{}\n}\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -779,7 +830,7 @@ class ModelsCommand extends Command
|
|||||||
* @param string $className
|
* @param string $className
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getCollectionClass($className)
|
protected function getCollectionClass($className)
|
||||||
{
|
{
|
||||||
// Return something in the very very unlikely scenario the model doesn't
|
// Return something in the very very unlikely scenario the model doesn't
|
||||||
// have a newCollection() method.
|
// have a newCollection() method.
|
||||||
@@ -800,6 +851,16 @@ class ModelsCommand extends Command
|
|||||||
return $this->laravel['config']->get('ide-helper.model_camel_case_properties', false);
|
return $this->laravel['config']->get('ide-helper.model_camel_case_properties', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getReturnType(\ReflectionMethod $reflection): ?string
|
||||||
|
{
|
||||||
|
$type = $this->getReturnTypeFromDocBlock($reflection);
|
||||||
|
if ($type) {
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getReturnTypeFromReflection($reflection);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get method return type based on it DocBlock comment
|
* Get method return type based on it DocBlock comment
|
||||||
*
|
*
|
||||||
@@ -819,6 +880,29 @@ class ModelsCommand extends Command
|
|||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getReturnTypeFromReflection(\ReflectionMethod $reflection): ?string
|
||||||
|
{
|
||||||
|
$returnType = $reflection->getReturnType();
|
||||||
|
if (!$returnType) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = $returnType instanceof \ReflectionNamedType
|
||||||
|
? $returnType->getName()
|
||||||
|
: (string)$returnType;
|
||||||
|
|
||||||
|
if (!$returnType->isBuiltin()) {
|
||||||
|
$type = '\\' . $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($returnType->allowsNull()) {
|
||||||
|
$type .= '|null';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates methods provided by the SoftDeletes trait
|
* Generates methods provided by the SoftDeletes trait
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param \Illuminate\Database\Eloquent\Model $model
|
||||||
@@ -827,20 +911,31 @@ class ModelsCommand extends Command
|
|||||||
{
|
{
|
||||||
$traits = class_uses(get_class($model), true);
|
$traits = class_uses(get_class($model), true);
|
||||||
if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) {
|
if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) {
|
||||||
$this->setMethod('forceDelete', 'bool|null', []);
|
|
||||||
$this->setMethod('restore', 'bool|null', []);
|
|
||||||
|
|
||||||
$this->setMethod('withTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
$this->setMethod('withTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
||||||
$this->setMethod('withoutTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
$this->setMethod('withoutTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
||||||
$this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
$this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates methods that return collections
|
||||||
|
* @param \Illuminate\Database\Eloquent\Model $model
|
||||||
|
*/
|
||||||
|
protected function getCollectionMethods($model)
|
||||||
|
{
|
||||||
|
$collectionClass = $this->getCollectionClass(get_class($model));
|
||||||
|
|
||||||
|
if ($collectionClass !== '\\' . \Illuminate\Database\Eloquent\Collection::class) {
|
||||||
|
$this->setMethod('get', $collectionClass . '|static[]', ['$columns = [\'*\']']);
|
||||||
|
$this->setMethod('all', $collectionClass . '|static[]', ['$columns = [\'*\']']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ReflectionClass $reflection
|
* @param ReflectionClass $reflection
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getClassKeyword(ReflectionClass $reflection)
|
protected function getClassKeyword(ReflectionClass $reflection)
|
||||||
{
|
{
|
||||||
if ($reflection->isFinal()) {
|
if ($reflection->isFinal()) {
|
||||||
$keyword = 'final ';
|
$keyword = 'final ';
|
||||||
@@ -852,4 +947,32 @@ class ModelsCommand extends Command
|
|||||||
|
|
||||||
return $keyword;
|
return $keyword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $type
|
||||||
|
* @return string|null
|
||||||
|
* @throws \ReflectionException
|
||||||
|
*/
|
||||||
|
protected function checkForCustomLaravelCasts(string $type): ?string
|
||||||
|
{
|
||||||
|
if (!class_exists($type) || !interface_exists(CastsAttributes::class)) {
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reflection = new \ReflectionClass($type);
|
||||||
|
|
||||||
|
if (!$reflection->implementsInterface(CastsAttributes::class)) {
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
$methodReflection = new \ReflectionMethod($type, 'get');
|
||||||
|
|
||||||
|
$type = $this->getReturnTypeFromReflection($methodReflection);
|
||||||
|
|
||||||
|
if ($type === null) {
|
||||||
|
$type = $this->getReturnTypeFromDocBlock($methodReflection);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -329,7 +329,7 @@ class Method
|
|||||||
} elseif (is_resource($default)) {
|
} elseif (is_resource($default)) {
|
||||||
//skip to not fail
|
//skip to not fail
|
||||||
} else {
|
} else {
|
||||||
$default = "'" . trim($default) . "'";
|
$default = var_export($default, true);
|
||||||
}
|
}
|
||||||
$paramStr .= " = $default";
|
$paramStr .= " = $default";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Collections;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|
||||||
|
class SimpleCollection extends Collection
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Collections\SimpleCollection;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
public function newCollection(array $models = [])
|
||||||
|
{
|
||||||
|
return new SimpleCollection($models);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationHasMany(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Simple::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Collections\SimpleCollection;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Mockery;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
parent::getEnvironmentSetUp($app);
|
||||||
|
|
||||||
|
$app['config']->set('ide-helper', [
|
||||||
|
'model_locations' => [
|
||||||
|
// This is calculated from the base_path() which points to
|
||||||
|
// vendor/orchestra/testbench-core/laravel
|
||||||
|
'/../../../../tests/Console/ModelsCommand/CustomCollection/Models',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test(): void
|
||||||
|
{
|
||||||
|
$actualContent = null;
|
||||||
|
$mockFilesystem = Mockery::mock(Filesystem::class);
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('get')
|
||||||
|
->andReturn(file_get_contents(__DIR__ . '/Models/Simple.php'))
|
||||||
|
->once();
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('put')
|
||||||
|
->with(
|
||||||
|
Mockery::any(),
|
||||||
|
Mockery::capture($actualContent)
|
||||||
|
)
|
||||||
|
->andReturn(1) // Simulate we wrote _something_ to the file
|
||||||
|
->once();
|
||||||
|
|
||||||
|
$this->instance(Filesystem::class, $mockFilesystem);
|
||||||
|
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertEmpty($tester->getDisplay());
|
||||||
|
|
||||||
|
$expectedContent = <<<'PHP'
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Collections\SimpleCollection;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple
|
||||||
|
*
|
||||||
|
* @property integer $id
|
||||||
|
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Collections\SimpleCollection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple[] $relationHasMany
|
||||||
|
* @property-read int|null $relation_has_many_count
|
||||||
|
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Collections\SimpleCollection|static[] all($columns = ['*'])
|
||||||
|
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Collections\SimpleCollection|static[] get($columns = ['*'])
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple whereId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
public function newCollection(array $models = [])
|
||||||
|
{
|
||||||
|
return new SimpleCollection($models);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationHasMany(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Simple::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PHP;
|
||||||
|
|
||||||
|
$this->assertSame($expectedContent, $actualContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Post extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Mockery;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
parent::getEnvironmentSetUp($app);
|
||||||
|
|
||||||
|
$app['config']->set('ide-helper', [
|
||||||
|
'model_locations' => [
|
||||||
|
// This is calculated from the base_path() which points to
|
||||||
|
// vendor/orchestra/testbench-core/laravel
|
||||||
|
'/../../../../tests/Console/ModelsCommand/GenerateBasicPhpdocCamel/Models',
|
||||||
|
],
|
||||||
|
// Activate the camel_case mode
|
||||||
|
'model_camel_case_properties' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test(): void
|
||||||
|
{
|
||||||
|
$actualContent = null;
|
||||||
|
$mockFilesystem = Mockery::mock(Filesystem::class);
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('get')
|
||||||
|
->andReturn(file_get_contents(__DIR__ . '/Models/Post.php'))
|
||||||
|
->once();
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('put')
|
||||||
|
->with(
|
||||||
|
Mockery::any(),
|
||||||
|
Mockery::capture($actualContent)
|
||||||
|
)
|
||||||
|
->andReturn(1) // Simulate we wrote _something_ to the file
|
||||||
|
->once();
|
||||||
|
|
||||||
|
$this->instance(Filesystem::class, $mockFilesystem);
|
||||||
|
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertEmpty($tester->getDisplay());
|
||||||
|
|
||||||
|
$expectedContent = <<<'PHP'
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post
|
||||||
|
*
|
||||||
|
* @property integer $id
|
||||||
|
* @property string|null $charNullable
|
||||||
|
* @property string $charNotNullable
|
||||||
|
* @property string|null $stringNullable
|
||||||
|
* @property string $stringNotNullable
|
||||||
|
* @property string|null $textNullable
|
||||||
|
* @property string $textNotNullable
|
||||||
|
* @property string|null $mediumTextNullable
|
||||||
|
* @property string $mediumTextNotNullable
|
||||||
|
* @property string|null $longTextNullable
|
||||||
|
* @property string $longTextNotNullable
|
||||||
|
* @property integer|null $integerNullable
|
||||||
|
* @property integer $integerNotNullable
|
||||||
|
* @property integer|null $tinyIntegerNullable
|
||||||
|
* @property integer $tinyIntegerNotNullable
|
||||||
|
* @property integer|null $smallIntegerNullable
|
||||||
|
* @property integer $smallIntegerNotNullable
|
||||||
|
* @property integer|null $mediumIntegerNullable
|
||||||
|
* @property integer $mediumIntegerNotNullable
|
||||||
|
* @property integer|null $bigIntegerNullable
|
||||||
|
* @property integer $bigIntegerNotNullable
|
||||||
|
* @property integer|null $unsignedIntegerNullable
|
||||||
|
* @property integer $unsignedIntegerNotNullable
|
||||||
|
* @property integer|null $unsignedTinyIntegerNullable
|
||||||
|
* @property integer $unsignedTinyIntegerNotNullable
|
||||||
|
* @property integer|null $unsignedSmallIntegerNullable
|
||||||
|
* @property integer $unsignedSmallIntegerNotNullable
|
||||||
|
* @property integer|null $unsignedMediumIntegerNullable
|
||||||
|
* @property integer $unsignedMediumIntegerNotNullable
|
||||||
|
* @property integer|null $unsignedBigIntegerNullable
|
||||||
|
* @property integer $unsignedBigIntegerNotNullable
|
||||||
|
* @property float|null $floatNullable
|
||||||
|
* @property float $floatNotNullable
|
||||||
|
* @property float|null $doubleNullable
|
||||||
|
* @property float $doubleNotNullable
|
||||||
|
* @property float|null $decimalNullable
|
||||||
|
* @property float $decimalNotNullable
|
||||||
|
* @property float|null $unsignedDecimalNullable
|
||||||
|
* @property float $unsignedDecimalNotNullable
|
||||||
|
* @property integer|null $booleanNullable
|
||||||
|
* @property integer $booleanNotNullable
|
||||||
|
* @property string|null $enumNullable
|
||||||
|
* @property string $enumNotNullable
|
||||||
|
* @property string|null $jsonNullable
|
||||||
|
* @property string $jsonNotNullable
|
||||||
|
* @property string|null $jsonbNullable
|
||||||
|
* @property string $jsonbNotNullable
|
||||||
|
* @property string|null $dateNullable
|
||||||
|
* @property string $dateNotNullable
|
||||||
|
* @property string|null $datetimeNullable
|
||||||
|
* @property string $datetimeNotNullable
|
||||||
|
* @property string|null $datetimetzNullable
|
||||||
|
* @property string $datetimetzNotNullable
|
||||||
|
* @property string|null $timeNullable
|
||||||
|
* @property string $timeNotNullable
|
||||||
|
* @property string|null $timetzNullable
|
||||||
|
* @property string $timetzNotNullable
|
||||||
|
* @property string|null $timestampNullable
|
||||||
|
* @property string $timestampNotNullable
|
||||||
|
* @property string|null $timestamptzNullable
|
||||||
|
* @property string $timestamptzNotNullable
|
||||||
|
* @property integer|null $yearNullable
|
||||||
|
* @property integer $yearNotNullable
|
||||||
|
* @property mixed|null $binaryNullable
|
||||||
|
* @property mixed $binaryNotNullable
|
||||||
|
* @property string|null $uuidNullable
|
||||||
|
* @property string $uuidNotNullable
|
||||||
|
* @property string|null $ipaddressNullable
|
||||||
|
* @property string $ipaddressNotNullable
|
||||||
|
* @property string|null $macaddressNullable
|
||||||
|
* @property string $macaddressNotNullable
|
||||||
|
* @property \Illuminate\Support\Carbon|null $createdAt
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updatedAt
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereBigIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereBigIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereBinaryNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereBinaryNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereBooleanNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereBooleanNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereCharNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereCharNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDateNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDateNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDatetimeNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDatetimeNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDatetimetzNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDatetimetzNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDecimalNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDecimalNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDoubleNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereDoubleNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereEnumNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereEnumNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereFloatNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereFloatNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereIpaddressNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereIpaddressNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereJsonNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereJsonNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereJsonbNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereJsonbNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereLongTextNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereLongTextNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereMacaddressNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereMacaddressNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereMediumIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereMediumIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereMediumTextNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereMediumTextNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereSmallIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereSmallIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereStringNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereStringNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTextNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTextNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTimeNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTimeNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTimestampNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTimestampNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTimestamptzNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTimestamptzNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTimetzNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTimetzNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTinyIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereTinyIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedBigIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedBigIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedDecimalNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedDecimalNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedMediumIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedMediumIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedSmallIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedSmallIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedTinyIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUnsignedTinyIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUuidNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereUuidNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereYearNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post whereYearNullable($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class Post extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PHP;
|
||||||
|
|
||||||
|
$this->assertSame($expectedContent, $actualContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,11 +47,58 @@ class Simple extends Model
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAttributeReturnsImportedClass(): DateTime
|
public function getAttributeReturnsImportedClassAttribute(): DateTime
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAttributeReturnsFqnClass(): \Illuminate\Support\Facades\Date
|
public function getAttributeReturnsFqnClassAttribute(): \Illuminate\Support\Facades\Date
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsArrayAttribute(): array
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableArrayAttribute(): ?array
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsStdClassAttribute(): \stdClass
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableStdClassAttribute(): ?\stdClass
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsBoolAttribute(): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableBoolAttribute(): ?bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsFloatAttribute(): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableFloatAttribute(): ?bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsCallableAttribute(): callable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableCallableAttribute(): ?callable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Doesn't make sense, but…
|
||||||
|
*/
|
||||||
|
public function getAttributeReturnsVoidAttribute(): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,12 +62,25 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Getter\Models\Simple
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Getter\Models\Simple
|
||||||
*
|
*
|
||||||
* @property integer $id
|
* @property integer $id
|
||||||
* @property-read mixed $attribute_return_type_int_or_null
|
* @property-read int|null $attribute_return_type_int_or_null
|
||||||
|
* @property-read array $attribute_returns_array
|
||||||
|
* @property-read bool $attribute_returns_bool
|
||||||
|
* @property-read callable $attribute_returns_callable
|
||||||
|
* @property-read bool $attribute_returns_float
|
||||||
|
* @property-read \Illuminate\Support\Facades\Date $attribute_returns_fqn_class
|
||||||
|
* @property-read \DateTime $attribute_returns_imported_class
|
||||||
|
* @property-read array|null $attribute_returns_nullable_array
|
||||||
|
* @property-read bool|null $attribute_returns_nullable_bool
|
||||||
|
* @property-read callable|null $attribute_returns_nullable_callable
|
||||||
|
* @property-read bool|null $attribute_returns_nullable_float
|
||||||
|
* @property-read \stdClass|null $attribute_returns_nullable_std_class
|
||||||
|
* @property-read \stdClass $attribute_returns_std_class
|
||||||
|
* @property-read void $attribute_returns_void
|
||||||
* @property-read \what|\ever|\we-write/here $attribute_takes_phpdoc_literal
|
* @property-read \what|\ever|\we-write/here $attribute_takes_phpdoc_literal
|
||||||
* @property-read int $attribute_with_int_return_phpdoc
|
* @property-read int $attribute_with_int_return_phpdoc
|
||||||
* @property-read string $attribute_with_int_return_type_and_but_phpdoc_string
|
* @property-read string $attribute_with_int_return_type_and_but_phpdoc_string
|
||||||
* @property-read int $attribute_with_int_return_type_and_phpdoc
|
* @property-read int $attribute_with_int_return_type_and_phpdoc
|
||||||
* @property-read mixed $attribute_with_int_return_type
|
* @property-read int $attribute_with_int_return_type
|
||||||
* @property-read mixed $attribute_without_type
|
* @property-read mixed $attribute_without_type
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Getter\Models\Simple newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Getter\Models\Simple newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Getter\Models\Simple newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Getter\Models\Simple newQuery()
|
||||||
@@ -117,11 +130,58 @@ class Simple extends Model
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAttributeReturnsImportedClass(): DateTime
|
public function getAttributeReturnsImportedClassAttribute(): DateTime
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAttributeReturnsFqnClass(): \Illuminate\Support\Facades\Date
|
public function getAttributeReturnsFqnClassAttribute(): \Illuminate\Support\Facades\Date
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsArrayAttribute(): array
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableArrayAttribute(): ?array
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsStdClassAttribute(): \stdClass
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableStdClassAttribute(): ?\stdClass
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsBoolAttribute(): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableBoolAttribute(): ?bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsFloatAttribute(): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableFloatAttribute(): ?bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsCallableAttribute(): callable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeReturnsNullableCallableAttribute(): ?callable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Doesn't make sense, but…
|
||||||
|
*/
|
||||||
|
public function getAttributeReturnsVoidAttribute(): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Ignored extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class NotIgnored extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models\Ignored;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Mockery;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
parent::getEnvironmentSetUp($app);
|
||||||
|
|
||||||
|
$app['config']->set('ide-helper', [
|
||||||
|
'model_locations' => [
|
||||||
|
// This is calculated from the base_path() which points to
|
||||||
|
// vendor/orchestra/testbench-core/laravel
|
||||||
|
'/../../../../tests/Console/ModelsCommand/Ignored/Models',
|
||||||
|
],
|
||||||
|
'ignored_models' => [
|
||||||
|
Ignored::class
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test(): void
|
||||||
|
{
|
||||||
|
$actualContent = null;
|
||||||
|
$mockFilesystem = Mockery::mock(Filesystem::class);
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('get')
|
||||||
|
->andReturn(file_get_contents(__DIR__ . '/Models/Ignored.php'))
|
||||||
|
->andReturn(file_get_contents(__DIR__ . '/Models/NotIgnored.php'))
|
||||||
|
->once();
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('put')
|
||||||
|
->with(
|
||||||
|
Mockery::any(),
|
||||||
|
Mockery::capture($actualContent)
|
||||||
|
)
|
||||||
|
->andReturn(1) // Simulate we wrote _something_ to the file
|
||||||
|
->once();
|
||||||
|
|
||||||
|
$this->instance(Filesystem::class, $mockFilesystem);
|
||||||
|
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertEmpty($tester->getDisplay());
|
||||||
|
|
||||||
|
$expectedContent = <<<'PHP'
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models\NotIgnored
|
||||||
|
*
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models\NotIgnored newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models\NotIgnored newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models\NotIgnored query()
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class NotIgnored extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PHP;
|
||||||
|
|
||||||
|
$this->assertSame($expectedContent, $actualContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces\Models;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class User extends Model implements Authenticatable
|
||||||
|
{
|
||||||
|
public function getAuthIdentifierName()
|
||||||
|
{
|
||||||
|
// TODO: Implement getAuthIdentifierName() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAuthIdentifier()
|
||||||
|
{
|
||||||
|
// TODO: Implement getAuthIdentifier() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAuthPassword()
|
||||||
|
{
|
||||||
|
// TODO: Implement getAuthPassword() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRememberToken()
|
||||||
|
{
|
||||||
|
// TODO: Implement getRememberToken() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRememberToken($value)
|
||||||
|
{
|
||||||
|
// TODO: Implement setRememberToken() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRememberTokenName()
|
||||||
|
{
|
||||||
|
// TODO: Implement getRememberTokenName() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Mockery;
|
||||||
|
|
||||||
|
final class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
parent::getEnvironmentSetUp($app);
|
||||||
|
|
||||||
|
$app['config']->set('ide-helper', [
|
||||||
|
'model_locations' => [
|
||||||
|
// This is calculated from the base_path() which points to
|
||||||
|
// vendor/orchestra/testbench-core/laravel
|
||||||
|
'/../../../../tests/Console/ModelsCommand/Interfaces/Models',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test(): void
|
||||||
|
{
|
||||||
|
$actualContent = null;
|
||||||
|
$mockFilesystem = Mockery::mock(Filesystem::class);
|
||||||
|
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('put')
|
||||||
|
->with(
|
||||||
|
Mockery::any(),
|
||||||
|
Mockery::capture($actualContent)
|
||||||
|
)
|
||||||
|
->andReturn(1) // Simulate we wrote _something_ to the file
|
||||||
|
->once();
|
||||||
|
|
||||||
|
$this->instance(Filesystem::class, $mockFilesystem);
|
||||||
|
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--nowrite' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertEmpty($tester->getDisplay());
|
||||||
|
|
||||||
|
$expectedContent = <<<'PHP'
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// @formatter:off
|
||||||
|
/**
|
||||||
|
* A helper file for your Eloquent Models
|
||||||
|
* Copy the phpDocs from this file to the correct Model,
|
||||||
|
* And remove them from this file, to prevent double declarations.
|
||||||
|
*
|
||||||
|
* @author Barry vd. Heuvel <barryvdh@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces\Models{
|
||||||
|
/**
|
||||||
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces\Models\User
|
||||||
|
*
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces\Models\User newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces\Models\User newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces\Models\User query()
|
||||||
|
*/
|
||||||
|
class User extends \Eloquent implements \Illuminate\Contracts\Auth\Authenticatable {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PHP;
|
||||||
|
|
||||||
|
$this->assertSame($expectedContent, $actualContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts;
|
||||||
|
|
||||||
|
class CastedProperty
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
|
||||||
|
class CustomCasterWithDocblockReturn implements CastsAttributes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @return CastedProperty
|
||||||
|
*/
|
||||||
|
public function get($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
return new CastedProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function set($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
// TODO: Implement set() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
|
||||||
|
class CustomCasterWithNullablePrimitiveReturn implements CastsAttributes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get($model, string $key, $value, array $attributes): ?array
|
||||||
|
{
|
||||||
|
return new CastedProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function set($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
// TODO: Implement set() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
|
||||||
|
class CustomCasterWithPrimitiveDocblockReturn implements CastsAttributes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
|
public function get($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
return new CastedProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function set($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
// TODO: Implement set() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
|
||||||
|
class CustomCasterWithPrimitiveReturn implements CastsAttributes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get($model, string $key, $value, array $attributes): array
|
||||||
|
{
|
||||||
|
return new CastedProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function set($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
// TODO: Implement set() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
|
||||||
|
class CustomCasterWithReturnType implements CastsAttributes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get($model, string $key, $value, array $attributes): CastedProperty
|
||||||
|
{
|
||||||
|
return new CastedProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function set($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
// TODO: Implement set() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
|
||||||
|
class CustomCasterWithoutReturnType implements CastsAttributes
|
||||||
|
{
|
||||||
|
public function get($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
return new CastedProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function set($model, string $key, $value, array $attributes)
|
||||||
|
{
|
||||||
|
// TODO: Implement set() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithDocblockReturn;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithNullablePrimitiveReturn;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithoutReturnType;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveDocblockReturn;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveReturn;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithReturnType;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CustomCast extends Model
|
||||||
|
{
|
||||||
|
protected $casts = [
|
||||||
|
'casted_property_with_return_type' => CustomCasterWithReturnType::class,
|
||||||
|
'casted_property_with_return_docblock' => CustomCasterWithDocblockReturn::class,
|
||||||
|
'casted_property_with_return_primitive' => CustomCasterWithPrimitiveReturn::class,
|
||||||
|
'casted_property_with_return_primitive_docblock' => CustomCasterWithPrimitiveDocblockReturn::class,
|
||||||
|
'casted_property_with_return_nullable_primitive' => CustomCasterWithNullablePrimitiveReturn::class,
|
||||||
|
'casted_property_without_return' => CustomCasterWithoutReturnType::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Mockery;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
if (version_compare(Application::VERSION, '7.0', '<')) {
|
||||||
|
$this->markTestSkipped('This test requires Laravel 7.0 or higher');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
parent::getEnvironmentSetUp($app);
|
||||||
|
|
||||||
|
$app['config']->set('ide-helper', [
|
||||||
|
'model_locations' => [
|
||||||
|
// This is calculated from the base_path() which points to
|
||||||
|
// vendor/orchestra/testbench-core/laravel
|
||||||
|
'/../../../../tests/Console/ModelsCommand/LaravelCustomCasts/Models',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_it_parses_casted_properties_correctly(): void
|
||||||
|
{
|
||||||
|
$actualContent = null;
|
||||||
|
$mockFilesystem = Mockery::mock(Filesystem::class);
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('get')
|
||||||
|
->andReturn(file_get_contents(__DIR__.'/Models/CustomCast.php'))
|
||||||
|
->once();
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('put')
|
||||||
|
->with(
|
||||||
|
Mockery::any(),
|
||||||
|
Mockery::capture($actualContent)
|
||||||
|
)
|
||||||
|
->andReturn(1) // Simulate we wrote _something_ to the file
|
||||||
|
->once();
|
||||||
|
|
||||||
|
$this->instance(Filesystem::class, $mockFilesystem);
|
||||||
|
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertEmpty($tester->getDisplay());
|
||||||
|
|
||||||
|
$expectedContent = <<<'PHP'
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithDocblockReturn;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithNullablePrimitiveReturn;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithoutReturnType;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveDocblockReturn;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveReturn;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithReturnType;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast
|
||||||
|
*
|
||||||
|
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_return_type
|
||||||
|
* @property \CastedProperty $casted_property_with_return_docblock
|
||||||
|
* @property array $casted_property_with_return_primitive
|
||||||
|
* @property array|null $casted_property_with_return_primitive_docblock
|
||||||
|
* @property array|null $casted_property_with_return_nullable_primitive
|
||||||
|
* @property $casted_property_without_return
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast whereCastedPropertyWithReturnDocblock($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast whereCastedPropertyWithReturnNullablePrimitive($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast whereCastedPropertyWithReturnPrimitive($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast whereCastedPropertyWithReturnPrimitiveDocblock($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast whereCastedPropertyWithReturnType($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast whereCastedPropertyWithoutReturn($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class CustomCast extends Model
|
||||||
|
{
|
||||||
|
protected $casts = [
|
||||||
|
'casted_property_with_return_type' => CustomCasterWithReturnType::class,
|
||||||
|
'casted_property_with_return_docblock' => CustomCasterWithDocblockReturn::class,
|
||||||
|
'casted_property_with_return_primitive' => CustomCasterWithPrimitiveReturn::class,
|
||||||
|
'casted_property_with_return_primitive_docblock' => CustomCasterWithPrimitiveDocblockReturn::class,
|
||||||
|
'casted_property_with_return_nullable_primitive' => CustomCasterWithNullablePrimitiveReturn::class,
|
||||||
|
'casted_property_without_return' => CustomCasterWithoutReturnType::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
PHP;
|
||||||
|
|
||||||
|
$this->assertSame($expectedContent, $actualContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Mockery;
|
||||||
|
use function file_get_contents;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
parent::getEnvironmentSetUp($app);
|
||||||
|
|
||||||
|
$app['config']->set('ide-helper', [
|
||||||
|
'model_locations' => [
|
||||||
|
// This is calculated from the base_path() which points to
|
||||||
|
// vendor/orchestra/testbench-core/laravel
|
||||||
|
'/../../../../tests/Console/ModelsCommand/PHPStormNoInspection/Models',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNoinspectionNotPresent(): void
|
||||||
|
{
|
||||||
|
$actualContent = null;
|
||||||
|
$mockFilesystem = Mockery::mock(Filesystem::class);
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('get')
|
||||||
|
->andReturn(file_get_contents(__DIR__ . '/Models/Simple.php'))
|
||||||
|
->once();
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('put')
|
||||||
|
->with(
|
||||||
|
Mockery::any(),
|
||||||
|
Mockery::capture($actualContent)
|
||||||
|
)
|
||||||
|
->andReturn(1) // Simulate we wrote _something_ to the file
|
||||||
|
->once();
|
||||||
|
|
||||||
|
$this->instance(Filesystem::class, $mockFilesystem);
|
||||||
|
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertEmpty($tester->getDisplay());
|
||||||
|
|
||||||
|
$expectedContent = <<<'PHP'
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple
|
||||||
|
*
|
||||||
|
* @property integer $id
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple whereId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PHP;
|
||||||
|
|
||||||
|
$this->assertSame($expectedContent, $actualContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNoinspectionPresent(): void
|
||||||
|
{
|
||||||
|
$actualContent = null;
|
||||||
|
$mockFilesystem = Mockery::mock(Filesystem::class);
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('get')
|
||||||
|
->andReturn(file_get_contents(__DIR__ . '/Models/Simple.php'))
|
||||||
|
->once();
|
||||||
|
$mockFilesystem
|
||||||
|
->shouldReceive('put')
|
||||||
|
->with(
|
||||||
|
Mockery::any(),
|
||||||
|
Mockery::capture($actualContent)
|
||||||
|
)
|
||||||
|
->andReturn(1) // Simulate we wrote _something_ to the file
|
||||||
|
->once();
|
||||||
|
|
||||||
|
$this->instance(Filesystem::class, $mockFilesystem);
|
||||||
|
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
'--phpstorm-noinspections' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertEmpty($tester->getDisplay());
|
||||||
|
|
||||||
|
$expectedContent = <<<'PHP'
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple
|
||||||
|
*
|
||||||
|
* @property integer $id
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple whereId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
* @noinspection PhpFullyQualifiedNameUsageInspection
|
||||||
|
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
||||||
|
*/
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PHP;
|
||||||
|
|
||||||
|
$this->assertSame($expectedContent, $actualContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,11 @@ class Simple extends Model
|
|||||||
return $this->hasOne(Simple::class);
|
return $this->hasOne(Simple::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function relationHasOneWithDefault(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(Simple::class)->withDefault();
|
||||||
|
}
|
||||||
|
|
||||||
public function relationBelongsTo(): BelongsTo
|
public function relationBelongsTo(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Simple::class);
|
return $this->belongsTo(Simple::class);
|
||||||
@@ -36,6 +41,16 @@ class Simple extends Model
|
|||||||
return $this->belongsToMany(Simple::class);
|
return $this->belongsToMany(Simple::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function relationBelongsToManyWithSub(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Simple::class)->where('foo', 'bar');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationBelongsToManyWithSubAnother(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->relationBelongsToManyWithSub()->where('foo', 'bar');
|
||||||
|
}
|
||||||
|
|
||||||
public function relationMorphTo(): MorphTo
|
public function relationMorphTo(): MorphTo
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
|
|||||||
@@ -74,13 +74,18 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|||||||
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\ModelsOtherNamespace\AnotherModel $relationBelongsToInAnotherNamespace
|
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\ModelsOtherNamespace\AnotherModel $relationBelongsToInAnotherNamespace
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationBelongsToMany
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationBelongsToMany
|
||||||
* @property-read int|null $relation_belongs_to_many_count
|
* @property-read int|null $relation_belongs_to_many_count
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationBelongsToManyWithSub
|
||||||
|
* @property-read int|null $relation_belongs_to_many_with_sub_count
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationBelongsToManyWithSubAnother
|
||||||
|
* @property-read int|null $relation_belongs_to_many_with_sub_another_count
|
||||||
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\ModelsOtherNamespace\AnotherModel $relationBelongsToSameNameAsColumn
|
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\ModelsOtherNamespace\AnotherModel $relationBelongsToSameNameAsColumn
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationHasMany
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationHasMany
|
||||||
* @property-read int|null $relation_has_many_count
|
* @property-read int|null $relation_has_many_count
|
||||||
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple $relationHasOne
|
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple|null $relationHasOne
|
||||||
|
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple $relationHasOneWithDefault
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationMorphMany
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationMorphMany
|
||||||
* @property-read int|null $relation_morph_many_count
|
* @property-read int|null $relation_morph_many_count
|
||||||
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple $relationMorphOne
|
* @property-read \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple|null $relationMorphOne
|
||||||
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $relationMorphTo
|
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $relationMorphTo
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationMorphedByMany
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Models\Simple[] $relationMorphedByMany
|
||||||
* @property-read int|null $relation_morphed_by_many_count
|
* @property-read int|null $relation_morphed_by_many_count
|
||||||
@@ -103,6 +108,11 @@ class Simple extends Model
|
|||||||
return $this->hasOne(Simple::class);
|
return $this->hasOne(Simple::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function relationHasOneWithDefault(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(Simple::class)->withDefault();
|
||||||
|
}
|
||||||
|
|
||||||
public function relationBelongsTo(): BelongsTo
|
public function relationBelongsTo(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Simple::class);
|
return $this->belongsTo(Simple::class);
|
||||||
@@ -113,6 +123,16 @@ class Simple extends Model
|
|||||||
return $this->belongsToMany(Simple::class);
|
return $this->belongsToMany(Simple::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function relationBelongsToManyWithSub(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Simple::class)->where('foo', 'bar');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationBelongsToManyWithSubAnother(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->relationBelongsToManyWithSub()->where('foo', 'bar');
|
||||||
|
}
|
||||||
|
|
||||||
public function relationMorphTo(): MorphTo
|
public function relationMorphTo(): MorphTo
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
|
|||||||
@@ -62,12 +62,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple
|
||||||
*
|
*
|
||||||
* @property integer $id
|
* @property integer $id
|
||||||
* @method static bool|null forceDelete()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple newQuery()
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple onlyTrashed()
|
* @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple onlyTrashed()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple query()
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple query()
|
||||||
* @method static bool|null restore()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple whereId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple whereId($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple withTrashed()
|
* @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple withTrashed()
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple withoutTrashed()
|
* @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\SoftDeletes\Models\Simple withoutTrashed()
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CustomCastsTable extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('custom_casts', static function (Blueprint $table) {
|
||||||
|
$table->string('casted_property_with_return_type');
|
||||||
|
$table->string('casted_property_with_return_docblock');
|
||||||
|
$table->string('casted_property_with_return_primitive');
|
||||||
|
$table->string('casted_property_with_return_primitive_docblock');
|
||||||
|
$table->string('casted_property_with_return_nullable_primitive');
|
||||||
|
$table->string('casted_property_without_return');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,21 @@ class ExampleTest extends TestCase
|
|||||||
$this->assertEquals(['$last', '$first = \'Barry\'', '...$middle'], $method->getParamsWithDefault(false));
|
$this->assertEquals(['$last', '$first = \'Barry\'', '...$middle'], $method->getParamsWithDefault(false));
|
||||||
$this->assertEquals(true, $method->shouldReturn());
|
$this->assertEquals(true, $method->shouldReturn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test special characters in methods default values
|
||||||
|
*/
|
||||||
|
public function testDefaultSpecialChars()
|
||||||
|
{
|
||||||
|
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
||||||
|
$reflectionMethod = $reflectionClass->getMethod('setSpecialChars');
|
||||||
|
|
||||||
|
$method = new Method($reflectionMethod, 'Example', $reflectionClass);
|
||||||
|
$this->assertEquals('$chars', $method->getParams(true));
|
||||||
|
$this->assertEquals(['$chars'], $method->getParams(false));
|
||||||
|
$this->assertEquals('$chars = \'$\\\'\\\\\'', $method->getParamsWithDefault(true));
|
||||||
|
$this->assertEquals(['$chars = \'$\\\'\\\\\''], $method->getParamsWithDefault(false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExampleClass
|
class ExampleClass
|
||||||
@@ -60,4 +75,9 @@ class ExampleClass
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setSpecialChars($chars = "\$'\\")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user