* tests: show that custom phpdoc tags without space afterwards are unexpectedly changed
This adds a test for the (current bug) behaviour of https://github.com/barryvdh/laravel-ide-helper/issues/666
If this ever gets fixed, this fails and needs to be adapted,
ensuring it won't break again.
* test: adapt now that #666 has been fixed
* Support generating helper files for real-time facades
Add changelog entry for real-time facades support
Mention real-time facades support in readme
Fix code style
Import
* Remove useless assertions
We cannot 100% control the output file has only the real-time facades, anything else can be in the final output
* add case when default value is of type enum
* Update CHANGELOG.md
* add tests for enum arguments default values
* ignore psalm issue (built-in `\UnitEnum` class does not exists in PHP7)
* Update run-static-analysis.yml to use PHP8.1
---------
Co-authored-by: Barry vd. Heuvel <[email protected]>
Co-authored-by: Barry vd. Heuvel <[email protected]>
* Add support for protected Attribute accessors
* Fix formatting
* Prevent accessors methods marked as private from being added
* Exclude specific accessors based on trait instead of class
* Add changelog entry
* Add clarifying comment
* Fix accessor attributes not working on PHP < 8.1
* Reintroduce method variable to reduce PR clutter
* Change variable name to reduce PR clutter
* Update CHANGELOG.md
---------
Co-authored-by: Barry vd. Heuvel <[email protected]>
Co-authored-by: Barry vd. Heuvel <[email protected]>
* option to use generics syntax, default to yes in laravel 9
* rename `use_generics_syntax` to `use_generics_annotations`
* update readme and changelog
* remove laravel 9 default override
* include key type in generics annotations
* readme rewording
* set `use_generics_annotations` to `true` by default
* update tests to reflect `use_generics_annotations` being set to `true` by default
* default `use_generics_annotations` setting to true when not set in config
Co-authored-by: Markus Podar <[email protected]>
---------
Co-authored-by: Markus Podar <[email protected]>
* Implement new config to specify return type of custom relations
* Apply suggestions from code review
Co-authored-by: Markus Podar <[email protected]>
* add test for morphed
* fix test output
* add info about how to add custom relationships
* fix wording
Co-authored-by: Markus Podar <[email protected]>
#1289 calls `getReturnType` for every method on every model, which in
turn calls `getReturnTypeFromDocBlock` which has this code:
```php
$phpDocContext = (new ContextFactory())->createFromReflector($reflection);
```
Extracting the docblock is super slow, always has been. Now that we do
this for every method, this adds up a lot.
Performance on a private commercial project _before_ #1289 was introduced:
```
$ time ./artisan ide-helper:models --write --reset >/dev/null
real 0m2.857s
user 0m1.835s
sys 0m0.129s
```
After #1289 :
```
$ time ./artisan ide-helper:models --write --reset >/dev/null
real 0m54.147s
user 0m47.132s
sys 0m1.047s
```
However, in this case we **do not need** the phpdoc fallback (which is
legitimate and by design for many other cases), because also the Laravel
implementation only works by inspecting the _actual type_, see
https://github.com/laravel/framework/blob/e0c2620b57be6416820ea7ca8e46fd2f71d2fe35/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L570-L575
```php
$returnType = (new ReflectionMethod($this, $method))->getReturnType();
return static::$attributeMutatorCache[get_class($this)][$key] = $returnType &&
$returnType instanceof ReflectionNamedType &&
$returnType->getName() === Attribute::class &&
is_callable($this->{$method}()->get);
```
This side-stepping the phpdoc parsing a) still works correctly and b)
brings us back to the previous performance characteristics:
```
time ./artisan ide-helper:models --write --reset >/dev/null
real 0m2.987s
user 0m1.915s
sys 0m0.120s
```
* ✨ Set properties from model functions returning an Attribute
* ✅ Add test for model Attributes
* 🎨 Fix code style
* 🔖 Update changelog
* ✅ Update test to not require php 8
* 🐛 Fix PHP 7.3 incompatibility
* ✅ Update tests to only run when Illuminate Attribute exists
* Make all tests pass cross platform
* Add job to run tests on Windows
* Merge test jobs with conditional Windows step for line endings
* Prefix job name with OS
* Update git lf step if statement
* Exclude all tests for Windows except PHP 8.0
* composer fix-style
Co-authored-by: Barry vd. Heuvel <[email protected]>
Co-authored-by: laravel-ide-helper <[email protected]>
* Allow for PhpDoc for macros with union types
* Replace null coalescing operator
* Test init PhpDoc for macros with parameter union types
* Allow for PhpDoc for macros with union return types
* Add helper method to Macro class
* Add changelog entry
* Format
* Complement changelog with PR link
* Add missing return
* Fix test for PHP < 8
* Rewrite PHP 8 test using eval()
* Remove obsolete test class
* Suppress Psalm errors for undefined ReflectionUnionType class
* Remove unreachable return statement