isaackaara
c3f795e909
fix: skip autoload exception when class existence is being checked ( #1764 )
...
The MetaCommand's custom autoloader throws a ReflectionException for any
class not found during meta generation. However, this breaks libraries
that use class_exists() to check for optional dependencies before loading
them (e.g. Doctrine ORM checking for StaticReflectionService removed in
doctrine/persistence v4).
This fix checks the call stack (up to 3 frames) for class_exists(),
interface_exists(), trait_exists(), or enum_exists() calls and returns
gracefully instead of throwing, allowing the existence check to return
false as expected.
Fixes #1750
2026-03-04 17:15:04 +01:00
2fba281b14
Fix PHPDoc placement before PHP 8 class attributes and add regression tests ( #1769 )
...
* Initial plan
* Add tests for PHP class attribute placement and fix whitespace in regex
Co-authored-by: barryvdh <[email protected] >
* Add advanced edge case tests: final+nested-brackets and multiple attributes
Co-authored-by: barryvdh <[email protected] >
* Add PHP 8.5 test for closures inside attribute arguments
Co-authored-by: barryvdh <[email protected] >
* composer fix-style
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected] >
Co-authored-by: barryvdh <[email protected] >
Co-authored-by: laravel-ide-helper <[email protected] >
2026-03-04 12:00:42 +01:00
isaackaara
392d5cfc80
fix: place PHPDoc before class attributes when writing to models ( #1765 )
...
When using --write/-W with models that have PHP 8 attributes (e.g.
#[ObservedBy(...)]), the generated PHPDoc block was inserted between
the attribute and the class declaration:
#[ObservedBy([ImageObserver::class])]
/**
* @property string $name
*/
final class Image extends Model
This breaks PHPStan/Larastan because the docblock must come before
the attributes. The fix scans backward from the class declaration to
find any preceding PHP 8 attributes and inserts the docblock before
them:
/**
* @property string $name
*/
#[ObservedBy([ImageObserver::class])]
final class Image extends Model
Fixes #1734
2026-03-04 10:52:03 +01:00
Pieter Willekens and laravel-ide-helper
fd3cfbe09d
feat(ModelsCommand): add configuration option to disable model query methods ( #1692 )
...
* feat(ModelsCommand): add configuration option to disable model query methods
* composer fix-style
* update comment
* revert whitespace changes
* composer fix-style
* composer fix-style
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2026-02-11 11:45:10 +01:00
Pieter Willekens
3bd70eafd0
fix: wrap bare intersection types in parentheses when adding nullable ( #1756 )
...
When a MorphTo relation's docblock uses a bare intersection type in the
generic parameter (e.g. `MorphTo<BaseModel&CanBeAssigned, $this>`), the
generated property type incorrectly becomes `BaseModel&CanBeAssigned|null`
instead of the correct `(BaseModel&CanBeAssigned)|null`.
This adds `wrapIntersectionType()` which ensures bare intersection types
are wrapped in parentheses before `|null` is appended, producing valid
DNF type syntax. Applied in both `setProperty()` and `applyNullability()`.
2026-02-10 15:19:29 +01:00
Pieter Willekens
5aca186d92
perf: reduce redundant lookups and file I/O in generation hot paths ( #1757 )
...
- Convert usedMethods from list to hash map for O(1) dedup lookups
- Cache getRelationTypes() and getRelationReturnTypes() per command run
- Reuse SplFileObject instances by filename instead of re-opening per method
- Cache ContextFactory results per declaring class across docblock helpers
Benchmarked with hyperfine (10 runs, 2 warmup): 1.37x faster (~27%).
2026-02-10 15:18:58 +01:00
Barry vd. Heuvel
cff155b0d3
Replace psalm with larastan ( #1755 )
...
* Use larastan instead of psalm
* Fix cs
* Fix baseline
2026-02-07 14:32:53 +01:00
Sava and Sava Markovic
d87ec5835d
Support all DNF types from PHP RFC ( #1751 )
...
* Support all DNF types from PHP RFC
* Update failing test
---------
Co-authored-by: Sava Markovic <[email protected] >
2026-01-26 14:24:36 +01:00
Evan Burrell
b0dcd7c62f
Make Soft Deleted Relationships Nullable ( #1749 )
2026-01-11 14:34:18 +01:00
Yannick Schinko
b106f7ee85
Add support for decimal column type ( #1739 )
...
* Add support for `decimal` column type
Previously `decimal` columns were represented with a cast. This now is no longer the case and instead the column type itself is `decimal`. This change takes that into account.
* The column type may also be `numeric`
* Update tests
2025-12-10 10:11:07 +01:00
Jesper Noordsij
e9283c40a2
Remove calls to PHP 8.5-deprecated setAccessible ( #1744 )
...
These are no-op as of PHP 8.1 and thus no longer needed
See also https://wiki.php.net/rfc/make-reflection-setaccessible-no-op
2025-12-10 10:10:09 +01:00
erikn69 and Joel Stein
8d00250cba
Add magic *_exists properties ( #1712 )
...
* Added magic `*_exists` properties.
* fix return datatype
* disabled by default
---------
Co-authored-by: Joel Stein <[email protected] >
2025-07-17 22:11:57 +02:00
Pieter Willekens
fafe264b3c
fix(ModelsCommand): use 'string' as realType for 'encrypted' casts ( #1698 )
2025-07-17 08:06:36 +02:00
Kristijan
cff244b9b5
fix: Fixed wrong doc for softDeletes withTrashed method ( #1688 )
2025-07-17 07:50:16 +02:00
erikn69
6c4ba2ad38
Support AsCollection::of($map), AsCollection::using($class, $map) ( #1714 )
...
* Support `AsCollection::of($map)`, `AsCollection::using($class, $map)`
* test compatibility(`of($map)`,`using($class, $map)` compiled), only laravel `>=12.10`
2025-07-17 07:23:52 +02:00
Marvin Naumann
0fa96e572d
detect default parameter from type float and adding tests for scopes with typed parameters ( #1697 )
2025-04-22 15:31:43 +02:00
8eec4f1ff5
feat(ModelsCommand): add support for the new Scope attribute ( #1694 )
...
* composer fix-style
* feat(model): add support for new Scope attribute
* composer fix-style
* snapshot
* check if class_exists for psalm
* check if class_exists for psalm
* resolve psalm issue
* remove prefix slash
* revert whitespace changes
* composer fix-style
* Update composer.json
---------
Co-authored-by: laravel-ide-helper <[email protected] >
Co-authored-by: Barry vd. Heuvel <[email protected] >
2025-04-04 16:14:00 +02:00
Pieter Willekens
d567978ebe
chore(meta): ignore abstracts in the autoloader ( Fixes #1671 ) ( #1686 )
2025-02-27 20:19:11 +01:00
Tom Westrick
3d4e37798e
Fix AsArrayObject cast to be Laravel's ArrayObject ( #1675 )
2025-02-22 15:16:07 +01:00
yparitcher
40485e7350
Fix MorphTo Model Doc Generation ( #1668 )
...
fix:
```php
/**
* @return MorphTo<contravariant ModelA|ModelB, $this>
*/
public function reminderable(): MorphTo {
return $this->morphTo(__FUNCTION__, 'entity', 'entity_id');
}
```
From:
```php
* @property-read contravariant ModelA|ModelB $reminderable
```
To:
```php
* @property-read ModelA|ModelB $reminderable
```
Fixes : #1667
2025-02-04 17:49:42 +01:00
skyler544 and Skyler Mayfield
ead24b10f6
prevent generation of incorrect property annotation ( #1665 )
...
Co-authored-by: Skyler Mayfield <[email protected] >
2025-01-29 22:43:43 +01:00
Barry vd. Heuvel
980a87e250
Check if returnType from docblock is not null ( #1658 )
2025-01-14 10:07:00 +01:00
Casper Bloemendaal
271682a2a6
feat: use generics of return type to determine resulting models ( #1653 )
2025-01-08 11:01:30 +01:00
Barry vd. Heuvel and laravel-ide-helper
55268cd47a
Catch meta, tweak auth ( #1654 )
...
* Catch meta, tweak auth
* composer fix-style
* Catch meta, tweak auth
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2025-01-08 11:00:41 +01:00
Barry vd. Heuvel
4c656cc71d
Remove duplicate config, fix ->can() ( #1650 )
2025-01-06 15:08:47 +01:00
Barry vd. Heuvel and laravel-ide-helper
f8381565ad
Add more metadata ( #1646 )
...
* Add more metadata
* composer fix-style
* Parse .env
* composer fix-style
* Check if .env exists
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2024-12-30 15:06:36 +01:00
Barry vd. Heuvel and laravel-ide-helper
e509790805
Use forked ContextFactory ( #1643 )
...
* Use forked ContextFactory
* composer fix-style
* Trim slashes
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2024-12-30 12:03:45 +01:00
Barry vd. Heuvel and laravel-ide-helper
791ba555f4
Add meta override for user return types ( #1642 )
...
* Add meta override for user return types
* composer fix-style
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2024-12-30 10:31:30 +01:00
Barry vd. Heuvel and laravel-ide-helper
4e4da0825a
Add phpstorm meta argument hints ( #1640 )
...
* Add phpstorm meta hints
* composer fix-style
* Use php-templates from vs-code
* Fix view instance
* composer fix-style
* Add translations
* composer fix-style
* map to string
* composer fix-style
* Fix test
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2024-12-29 19:44:08 +01:00
Lau Ernebjerg Josefsen
4ad74ba241
Add weak generics for array type objects ( #1621 )
2024-12-29 11:52:05 +01:00
Barry vd. Heuvel and laravel-ide-helper
347483be03
Add option for only eloquent ( #1636 )
...
* Add option for only eloquent
* composer fix-style
* Add snapshot
* Add option to models command
* composer fix-style
* Fix namespace
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2024-12-29 11:51:09 +01:00
Barry vd. Heuvel and laravel-ide-helper
14fdb572bb
Update testsuite for Generator, simplify service provider and mock ( #1635 )
...
* Add templates to Eloquent
* Test generator, update constructor
* composer fix-style
* Add filename test
* UPdate test
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2024-12-28 19:56:36 +01:00
Lito
5da09fad67
Fixed PHP 8.4 deprecation warning ( #1622 )
...
* Fixed PHP 8.4 deprecation warning
* Fix PHP 8.4 deprecation warning
2024-12-09 16:03:20 +01:00
Jeramy Hing
472c1bad5d
Feature: Add Config Option to Enforce Nullable Relationships ( #1580 )
...
* feat: add config option for nullable relationships
Introduce enforce_nullable_relationships configuration to control nullable Eloquent relationships.
* refactor: update logic for nullable relationships
Update isRelationNullable method to respect new config option.
* test: add tests for nullable relationship config
- Verify behavior of enforce_nullable_relationships configuration option.
- Create snapshot to reflect enforce_nullable_relationships set to false.
* docs: improve documented context and usage
* docs: update CHANGELOG with enforce_nullable_relationships option
2024-10-30 22:35:58 +01:00
Pieter Willekens and laravel-ide-helper
07e3bd8796
fix(pivot): only use unique classes in the pivot union ( Fixes #1606 ) ( #1607 )
...
* fix(pivot): only use unique classes in the pivot union (Fixes #1606 )
* composer fix-style
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2024-10-29 15:00:16 +01:00
Ramon Dantas and Barry vd. Heuvel
800e2347a6
feat: use numeric type on fields with decimal casts ( #1583 )
...
* feat: use `numeric` type on fields with `decimal` casts
* docs: update CHANGELOG.md
---------
Co-authored-by: Barry vd. Heuvel <[email protected] >
2024-10-28 12:32:31 +01:00
Barry vd. Heuvel
7549f58a30
Smarter reset ( #1603 )
...
* Smarter reset
* Changelog
* Fix phpdocs
2024-10-28 12:21:53 +01:00
Barry vd. Heuvel
d6fb7907cc
Merge branch 'patch-1' of github.com:uno-sw/laravel-ide-helper into uno-sw-patch-1
2024-10-28 11:35:50 +01:00
Pieter Willekens and laravel-ide-helper
dc70337e48
feat(pivot): add support for multiple pivot types when using the same accessor ( #1597 )
...
* feat(pivot): add support for multiple pivot types when using the same accessor
* composer fix-style
* changelog
* resolve namespaces
* Revert "resolve namespaces"
This reverts commit 37559ab089 .
* resolve namespaces
---------
Co-authored-by: laravel-ide-helper <[email protected] >
2024-10-28 11:32:19 +01:00
KentarouTakeda
4b051e45c7
Fix the description of unused option ( #1600 )
2024-10-28 11:30:54 +01:00
KentarouTakeda
085ca3e225
Compatible with Generics Eloquent Builder in Laravel 11.15 ( #1591 )
...
* feat: support generics eloquent builder
* fix: required laravel version
* fix: ci execution is only for Laravel-11
* docs: add CHANGELOG
* docs: update supported Laravel versions and adjust output examples
2024-10-17 18:37:19 +02:00
khaled sadek
643329d23d
Fix type of hased model property ( #1579 )
...
* set hashed properity as string
* add to changelog
* add test
2024-08-07 09:29:14 +02:00
uno-sw
51fb97b8fb
Add support for AsCollection::using and AsEnumCollection::of casts
2024-08-02 13:18:15 +09:00
schrosis
001091e605
fix: unknown format PHPDoc ( #1538 )
2024-07-12 16:09:08 +02:00
f5759e2001
Add static to isBuiltin() check in ide-helper:models ( #1541 )
...
* Add `\\static` as check
For some reason, the `static` keyword as a return type, does not return `isBuiltin()` === true, so a `\\` is added. We need to manually add it to the built in check.
* Update ModelsCommand.php
* Add tests
* Add CHANGELOG.md entry
---------
Co-authored-by: Markus Podar <[email protected] >
Co-authored-by: Barry vd. Heuvel <[email protected] >
2024-07-12 16:08:08 +02:00
michal and Barry vd. Heuvel
f7a3dc8ff2
Add support in morphTo relationship for null values (1547) ( #1549 )
...
Co-authored-by: Barry vd. Heuvel <[email protected] >
2024-07-12 16:06:56 +02:00
Braunson Yager and Barry vd. Heuvel
672acce5ae
feat: add support for AsEnumCollection casts ( #1557 )
...
* Adding support for casting to AsEnumCollection
* Adding missing string to advanced_casts table for enum_collection
* Added to snapshots and ArrayCastsWithComment
* Update CHANGELOG.md
* Reverted automated whitespace, strict changes
* Updated test snapshots, tests passing
* Whitespace revert
---------
Co-authored-by: Barry vd. Heuvel <[email protected] >
2024-07-12 16:03:57 +02:00
c6509b658f
Improved attribute handling with types and Attribute support ( #1567 )
...
* Add `AllowDynamicProperties` Attribute to cooperate with php8.2 deprecation
* lint snapshot
* Fix collection attribute typing
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update composer.json
* Fix collectino with template types WIP
* Add `AllowDynamicProperties` Attribute to cooperate with php8.2 deprecation
* Fix collection attribute typing
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update composer.json
* composer fix-style
* Fix tests
* Fix tests
* composer fix-style
* Fix collectino with complex template types{
* Delete phpactor
* Install from scrumble repo
* Implemented correct attribute handling
* composer fix-style
* Revert "Install from scrumble repo"
This reverts commit 3f1057adb6 .
* Re-add barryvdh links
* Revert "Update composer.json"
This reverts commit 98252fe740 .
* Fix pivot test
* Correct CHANGELOG.md with attribute merge request
* More clear PhpDocTypeParser filename and clarified directory according to PSR12
---------
Co-authored-by: GeoSot <[email protected] >
Co-authored-by: laravel-ide-helper <[email protected] >
Co-authored-by: Luukdewaaier <[email protected] >
Co-authored-by: Luuk de Weijer <[email protected] >
2024-07-12 15:53:04 +02:00
sforward
6338abb2d7
Fix return value of scopes from parent class ( #1366 )
2024-04-01 08:43:59 +02:00
dev2a
ac7e186270
Add pivot class property ( #1518 )
...
* Add pivot class property
* Add test for pivot class properties
* Fix failed test for pivot class properties
* Update CHANGELOG.md
* Fix failed test
2024-03-11 14:37:15 +01:00