mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-20 11:03:09 +00:00
Fix collectino with complex template types{
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
# IDE Helper Generator for Laravel
|
# IDE Helper Generator for Laravel
|
||||||
|
|
||||||
[](https://github.com/barryvdh/laravel-ide-helper/actions)
|
[](https://github.com/scrumble-nl/laravel-ide-helper/actions)
|
||||||
[](http://choosealicense.com/licenses/mit/)
|
[](http://choosealicense.com/licenses/mit/)
|
||||||
[](https://packagist.org/packages/barryvdh/laravel-ide-helper)
|
[](https://packagist.org/packages/barryvdh/laravel-ide-helper)
|
||||||
[](https://packagist.org/packages/barryvdh/laravel-ide-helper)
|
[](https://packagist.org/packages/barryvdh/laravel-ide-helper)
|
||||||
[](https://fruitcake.nl/)
|
|
||||||
|
|
||||||
**Complete PHPDocs, directly from the source**
|
**Complete PHPDocs, directly from the source**
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ class PhpDocTypeParser
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $typeAlias;
|
private string $typeAlias;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $namespaceAliases;
|
private array $namespaceAliases;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $typeAlias
|
* @param string $typeAlias
|
||||||
@@ -29,7 +29,7 @@ class PhpDocTypeParser
|
|||||||
/**
|
/**
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function parse()
|
public function parse(): string|null
|
||||||
{
|
{
|
||||||
$matches = [];
|
$matches = [];
|
||||||
preg_match('/(\w+)(<.*>)/', $this->typeAlias, $matches);
|
preg_match('/(\w+)(<.*>)/', $this->typeAlias, $matches);
|
||||||
@@ -56,16 +56,25 @@ class PhpDocTypeParser
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$matches = [];
|
$type = '';
|
||||||
preg_match_all('/\w+/', $template, $matches);
|
$result = '';
|
||||||
$types = array_unique($matches[0]);
|
|
||||||
foreach ($types as $type) {
|
|
||||||
$typeAlias = $this->namespaceAliases[$type] ?? $type;
|
|
||||||
|
|
||||||
dump($this->namespaceAliases, $typeAlias);
|
foreach (str_split($template) as $char) {
|
||||||
$template = preg_replace("/\W$type\W/", $typeAlias, $template);
|
$match = preg_match('/[A-z]/', $char);
|
||||||
|
|
||||||
|
if (!$match) {
|
||||||
|
$type = $this->namespaceAliases[$type] ?? $type;
|
||||||
|
$result .= $type;
|
||||||
|
$result .= $char;
|
||||||
|
$type = '';
|
||||||
|
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $template;
|
$type .= $char;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,35 +12,35 @@ use Illuminate\Support\Collection as IntCollection;
|
|||||||
|
|
||||||
class WithCollection extends Model
|
class WithCollection extends Model
|
||||||
{
|
{
|
||||||
// /**
|
/**
|
||||||
// * @return Collection<int, string>
|
* @return Collection<int, string>
|
||||||
// */
|
*/
|
||||||
// public function getCollectionAttribute(): Collection
|
public function getCollectionAttribute(): Collection
|
||||||
// {
|
{
|
||||||
// return new Collection();
|
return new Collection();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * @return Collection
|
* @return Collection
|
||||||
// */
|
*/
|
||||||
// public function getCollectionWithoutTemplateAttribute(): Collection
|
public function getCollectionWithoutTemplateAttribute(): Collection
|
||||||
// {
|
{
|
||||||
// return new Collection();
|
return new Collection();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public function getCollectionWithoutDocBlockAttribute(): Collection
|
public function getCollectionWithoutDocBlockAttribute(): Collection
|
||||||
// {
|
{
|
||||||
// return new Collection();
|
return new Collection();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * @return Collection<int, NonModel>
|
* @return Collection<int, NonModel>
|
||||||
// */
|
*/
|
||||||
// public function getCollectionWithNonModelTemplateAttribute(): Collection
|
public function getCollectionWithNonModelTemplateAttribute(): Collection
|
||||||
// {
|
{
|
||||||
// return new Collection();
|
return new Collection();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<Collection, CollectionModel<IntCollection, CollectionModel<int, NonModel>>>
|
* @return Collection<Collection, CollectionModel<IntCollection, CollectionModel<int, NonModel>>>
|
||||||
*/
|
*/
|
||||||
|
|||||||
+34
-31
@@ -15,42 +15,41 @@ use Illuminate\Support\Collection as IntCollection;
|
|||||||
*/
|
*/
|
||||||
class WithCollection extends Model
|
class WithCollection extends Model
|
||||||
{
|
{
|
||||||
// /**
|
/**
|
||||||
// * @return Collection<int, string>
|
* @return Collection<int, string>
|
||||||
// */
|
*/
|
||||||
// public function getCollectionAttribute(): Collection
|
public function getCollectionAttribute(): Collection
|
||||||
// {
|
{
|
||||||
// return new Collection();
|
return new Collection();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * @return Collection
|
* @return Collection
|
||||||
// */
|
*/
|
||||||
// public function getCollectionWithoutTemplateAttribute(): Collection
|
public function getCollectionWithoutTemplateAttribute(): Collection
|
||||||
// {
|
{
|
||||||
// return new Collection();
|
return new Collection();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public function getCollectionWithoutDocBlockAttribute(): Collection
|
public function getCollectionWithoutDocBlockAttribute(): Collection
|
||||||
// {
|
{
|
||||||
// return new Collection();
|
return new Collection();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * @return Collection<int, NonModel>
|
* @return Collection<int, NonModel>
|
||||||
// */
|
*/
|
||||||
// public function getCollectionWithNonModelTemplateAttribute(): Collection
|
public function getCollectionWithNonModelTemplateAttribute(): Collection
|
||||||
// {
|
{
|
||||||
// return new Collection();
|
return new Collection();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<Collection, CollectionModel<IntCollection, CollectionModel<int, NonModel>>>
|
* @return Collection<Collection, CollectionModel<IntCollection, CollectionModel<int, NonModel>>>
|
||||||
*/
|
*/
|
||||||
public function getCollectionWithNestedTemplateAttribute(): Collection
|
public function getCollectionWithNestedTemplateAttribute(): Collection
|
||||||
{
|
{
|
||||||
return new Collection();
|
return new Collection();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<?php
|
<?php
|
||||||
@@ -70,7 +69,11 @@ namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateMixinCol
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @property-read \Illuminate\Support\Collection\Illuminate\Support\Collection\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateMixinCollection\NonModels\CollectionModelIntCollection,\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateMixinCollection\NonModels\CollectionModelint,\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateMixinCollection\NonModels\NonModel>> $collection_with_nested_template
|
* @property-read \Illuminate\Support\Collection<int, string> $collection
|
||||||
|
* @property-read \Illuminate\Support\Collection<\Illuminate\Support\Collection, \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateMixinCollection\NonModels\CollectionModel<\Illuminate\Support\Collection, \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateMixinCollection\NonModels\CollectionModel<int, \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateMixinCollection\NonModels\NonModel>>> $collection_with_nested_template
|
||||||
|
* @property-read \Illuminate\Support\Collection<int, \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateMixinCollection\NonModels\NonModel> $collection_with_non_model_template
|
||||||
|
* @property-read \Illuminate\Support\Collection $collection_without_doc_block
|
||||||
|
* @property-read \Illuminate\Support\Collection $collection_without_template
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WithCollection newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|WithCollection newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WithCollection newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|WithCollection newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WithCollection query()
|
* @method static \Illuminate\Database\Eloquent\Builder|WithCollection query()
|
||||||
|
|||||||
Reference in New Issue
Block a user