Compare commits

...
15 Commits
Author SHA1 Message Date
Barry vd. Heuvel 8740a9a158 Fix CS 2019-09-08 11:56:38 +02:00
liquid207 d344cdc842 Fix phpcs (#803) 2019-09-08 11:55:17 +02:00
Mandy Schoep 5e411ef104 Do not added instances of a anonymous class to the phpstorm_meta file (#806) 2019-09-08 11:46:25 +02:00
Barry vd. Heuvel 499a2113b3 Check if method exists 2019-09-08 11:45:23 +02:00
Barry vd. Heuvel f8a8cb18e0 Always require doctrine 2019-09-08 11:36:40 +02:00
Barry vd. Heuvel 16eb4f65ee Update readme.md 2019-09-03 19:51:13 +02:00
Kevin Bond 0edf8f750e remove monolog configuration (fixes #818) (#820) 2019-09-03 19:49:46 +02:00
Johan van Helden 1b15d2930b fix the identation in the config (#817) 2019-08-31 12:53:08 +02:00
Matthew Hailwood 3668e3821a Add support for custom cast classes (#816)
* Add support for custom cast classes

* Fix unrelated code style warning.
2019-08-30 07:32:01 +02:00
Barry vd. Heuvel 7b4cef1ea4 Update composer.json 2019-08-23 14:21:37 +02:00
Stanislas cd2a71d43c ModelsCommand: Remove question mark (#812)
Sorry this is a bit nitpicky 😅
2019-08-06 07:54:53 +02:00
edvordo c9132b28a6 Chages to x2Many relationships detection & adds relationship_count docBlock comment (#783)
* x to Many relationships are detected via a `Many` keyword in the relationship object class name
   * reason: example: `belongsTo` was incorrectly recognized as `belongsToMany`
 * adds `@property-read int|null $x2Many_relationship_method_name_count` model class docBlock comment
   * when model makes use of `withCount` or `loadCount` there is a property on the resource `$instance->relationship_method_count` that states the count of related models
   * can be `NULL` when `withCount` or `loadCount` aren't used
2019-06-18 16:38:42 +02:00
Guilherme Pressutto 8ab6e0536b Fixed meta not working with app()->makeWith() (#791) 2019-05-29 17:09:57 +02:00
Theodore R. Smith 87ebe458e9 Removed confusing README installation instructions (#786)
While installing this for my project, I didn't see the `--dev` instructions until I was literally editing this README for a pull request.

Since laravel-ide-helper is only designed for development purposes, let's just remove the superfluous entry altogether. Smart devs who for some crazy reason need it on prod will know to remove the `--dev`, while less knowledgeable devs won't shoot themselves in the foot accidentally.
2019-04-17 22:07:56 +02:00
leo108 9ef14f83be use Throwable instead of Exception (#779) 2019-03-27 05:56:31 +01:00
6 changed files with 29 additions and 41 deletions
+8 -11
View File
@@ -11,23 +11,20 @@
],
"require": {
"php": ">=7",
"illuminate/support": "^5.5,<5.9",
"illuminate/console": "^5.5,<5.9",
"illuminate/filesystem": "^5.5,<5.9",
"illuminate/support": "^5.5|^6",
"illuminate/console": "^5.5|^6",
"illuminate/filesystem": "^5.5|^6",
"barryvdh/reflection-docblock": "^2.0.6",
"composer/composer": "^1.6"
"composer/composer": "^1.6",
"doctrine/dbal": "~2.3"
},
"require-dev": {
"illuminate/config": "^5.1,<5.9",
"illuminate/view": "^5.1,<5.9",
"illuminate/config": "^5.5|^6",
"illuminate/view": "^5.5|^6",
"phpro/grumphp": "^0.14",
"phpunit/phpunit" : "4.*",
"scrutinizer/ocular": "~1.1",
"squizlabs/php_codesniffer": "^3",
"doctrine/dbal": "~2.3"
},
"suggest": {
"doctrine/dbal": "Load information from the database about models for phpdocs (~2.3)"
"squizlabs/php_codesniffer": "^3"
},
"autoload": {
"psr-4": {
+3 -14
View File
@@ -98,18 +98,7 @@ return array(
'Session' => array('Illuminate\Session\Store'),
),
'magic' => array(
'Log' => array(
'debug' => 'Monolog\Logger::addDebug',
'info' => 'Monolog\Logger::addInfo',
'notice' => 'Monolog\Logger::addNotice',
'warning' => 'Monolog\Logger::addWarning',
'error' => 'Monolog\Logger::addError',
'critical' => 'Monolog\Logger::addCritical',
'alert' => 'Monolog\Logger::addAlert',
'emergency' => 'Monolog\Logger::addEmergency',
)
),
'magic' => array(),
/*
|--------------------------------------------------------------------------
@@ -189,10 +178,10 @@ return array(
| Cast the given "real type" to the given "type".
|
*/
'type_overrides' => array(
'type_overrides' => array(
'integer' => 'int',
'boolean' => 'bool',
),
),
/*
|--------------------------------------------------------------------------
+2 -8
View File
@@ -1,4 +1,4 @@
## Laravel 5 IDE Helper Generator
## Laravel IDE Helper Generator
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
@@ -29,7 +29,7 @@ Note: You do need CodeComplice for Sublime Text: https://github.com/spectacles/C
Require this package with composer using the following command:
```bash
composer require barryvdh/laravel-ide-helper
composer require --dev barryvdh/laravel-ide-helper
```
After updating composer, add the service provider to the `providers` array in `config/app.php`
@@ -39,12 +39,6 @@ Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
```
**Laravel 5.5** uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
To install this package on only development systems, add the `--dev` flag to your composer command:
```bash
composer require --dev barryvdh/laravel-ide-helper
```
In Laravel, instead of adding the service provider in the `config/app.php` file, you can add the following code to your `app/Providers/AppServiceProvider.php` file, within the `register()` method:
```php
+1 -1
View File
@@ -316,7 +316,7 @@ class Alias
{
foreach ($this->magicMethods as $magic => $real) {
list($className, $name) = explode('::', $real);
if (!class_exists($className) && !interface_exists($className)) {
if ((!class_exists($className) && !interface_exists($className)) || !method_exists($className, $name)) {
continue;
}
$method = new \ReflectionMethod($className, $name);
+4 -2
View File
@@ -47,6 +47,7 @@ class MetaCommand extends Command
protected $methods = [
'new \Illuminate\Contracts\Container\Container',
'\Illuminate\Container\Container::makeWith(0)',
'\Illuminate\Contracts\Container\Container::make(0)',
'\Illuminate\Contracts\Container\Container::makeWith(0)',
'\App::make(0)',
@@ -87,10 +88,11 @@ class MetaCommand extends Command
try {
$concrete = $this->laravel->make($abstract);
if (is_object($concrete)) {
$reflectionClass = new \ReflectionClass($concrete);
if (is_object($concrete) && !$reflectionClass->isAnonymous()) {
$bindings[$abstract] = get_class($concrete);
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$this->comment("Cannot make '$abstract': ".$e->getMessage());
}
+11 -5
View File
@@ -96,7 +96,7 @@ class ModelsCommand extends Command
//If filename is default and Write is not specified, ask what to do
if (!$this->write && $filename === $this->filename && !$this->option('nowrite')) {
if ($this->confirm(
"Do you want to overwrite the existing model files? Choose no to write to $filename instead?"
"Do you want to overwrite the existing model files? Choose no to write to $filename instead"
)
) {
$this->write = true;
@@ -217,7 +217,7 @@ class ModelsCommand extends Command
$output .= $this->createPhpDocs($name);
$ignore[] = $name;
$this->nullableColumns = [];
} catch (\Exception $e) {
} catch (\Throwable $e) {
$this->error("Exception: " . $e->getMessage() . "\nCould not analyze class $name.");
}
}
@@ -290,7 +290,7 @@ class ModelsCommand extends Command
$realType = '\Illuminate\Support\Collection';
break;
default:
$realType = 'mixed';
$realType = class_exists($type) ? ('\\' . $type) : 'mixed';
break;
}
@@ -456,7 +456,7 @@ class ModelsCommand extends Command
//Use reflection to inspect the code, based on Illuminate/Support/SerializableClosure.php
$reflection = new \ReflectionMethod($model, $method);
// php 7.x type or fallback to docblock
$type = (string) $reflection->getReturnType() ?: (string)$this->getReturnTypeFromDocBlock($reflection);
$type = (string) ($reflection->getReturnType() ?: $this->getReturnTypeFromDocBlock($reflection));
$file = new \SplFileObject($reflection->getFileName());
$file->seek($reflection->getStartLine() - 1);
@@ -503,7 +503,7 @@ class ModelsCommand extends Command
'morphToMany',
'morphedByMany',
];
if (in_array($relation, $relations)) {
if (strpos(get_class($relationObj), 'Many') !== false) {
//Collection or array of models (because Collection is Arrayable)
$this->setProperty(
$method,
@@ -511,6 +511,12 @@ class ModelsCommand extends Command
true,
null
);
$this->setProperty(
Str::snake($method) . '_count',
'int|null',
true,
false
);
} elseif ($relation === "morphTo") {
// Model isn't specified because relation is polymorphic
$this->setProperty(