Skip to content

Commit

Permalink
Use forked ContextFactory (#1643)
Browse files Browse the repository at this point in the history
* Use forked ContextFactory

* composer fix-style

* Trim slashes

---------

Co-authored-by: laravel-ide-helper <[email protected]>
  • Loading branch information
barryvdh and laravel-ide-helper authored Dec 30, 2024
1 parent 791ba55 commit e509790
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
"require": {
"php": "^8.2",
"ext-json": "*",
"barryvdh/reflection-docblock": "^2.2",
"barryvdh/reflection-docblock": "^2.3",
"composer/class-map-generator": "^1.0",
"illuminate/console": "^11.15",
"illuminate/database": "^11.15",
"illuminate/filesystem": "^11.15",
"illuminate/support": "^11.15",
"nikic/php-parser": "^4.18 || ^5",
"phpdocumentor/type-resolver": "^1.1.0"
"nikic/php-parser": "^4.18 || ^5"
},
"require-dev": {
"ext-pdo_sqlite": "*",
Expand Down
6 changes: 4 additions & 2 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Barryvdh\LaravelIdeHelper\Parsers\PhpDocReturnTypeParser;
use Barryvdh\Reflection\DocBlock;
use Barryvdh\Reflection\DocBlock\Context;
use Barryvdh\Reflection\DocBlock\ContextFactory;
use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
use Barryvdh\Reflection\DocBlock\Tag;
use Composer\ClassMapGenerator\ClassMapGenerator;
Expand Down Expand Up @@ -49,7 +50,6 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\View\Factory as ViewFactory;
use phpDocumentor\Reflection\Types\ContextFactory;
use ReflectionClass;
use ReflectionNamedType;
use ReflectionObject;
Expand Down Expand Up @@ -1571,7 +1571,9 @@ protected function getClassNameInDestinationFile(object $model, string $classNam
*/
protected function getUsedClassNames(ReflectionClass $reflection): array
{
$namespaceAliases = array_flip((new ContextFactory())->createFromReflector($reflection)->getNamespaceAliases());
$namespaceAliases = array_flip(array_map(function ($alias) {
return ltrim($alias, '\\');
}, (new ContextFactory())->createFromReflector($reflection)->getNamespaceAliases()));
$namespaceAliases[$reflection->getName()] = $reflection->getShortName();

return $namespaceAliases;
Expand Down

0 comments on commit e509790

Please sign in to comment.