Commit Graph
836 Commits
Author SHA1 Message Date
KentarouTakeda 07f5eaea73 Fix return type of methods provided by SoftDeletes (#1345)
* Fix return type of methods provided by `SoftDeletes`

* Update CHANGELOG

* fix test / update snapshot
2022-08-11 12:36:43 +02:00
Corey McCormick c76fbb5b61 Allow for proper database resolve with schemas (#1349)
* Allow for proper database resolve with schemas

* Remove need to explode database and table name
2022-08-11 12:35:46 +02:00
angeljqv c40fee2a3f Update .gitattributes (#1355) 2022-08-11 12:32:48 +02:00
Wim Reckman 5eadd2c7de Fix model factory method arguments for Laravel >= 9 (#1361) 2022-08-11 12:32:14 +02:00
Barry vd. Heuvelandlaravel-ide-helper 6e26f22c76 Feat useclassmappackage (#1357)
* Use composer/class-map-generator

* composer fix-style

Co-authored-by: laravel-ide-helper <[email protected]>
2022-06-20 15:54:12 +02:00
JefemyandMarkus Podar ee9188acf1 Implement new config to specify return type of custom relations (#1300)
* 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]>
2022-05-22 20:07:54 +02:00
Markus Podar a567f73140 readme: explicitly state supported version (#1348)
Based on the discussion in https://github.com/barryvdh/laravel-ide-helper/issues/1347
2022-05-21 22:40:30 +02:00
Markus Podar 6a461a7c47 Fix integration tests by fixing a PHP 8.1+ deprecation warnings in ReflectionClass (#1351)
* gha: get more insights when/if logs exist

* Better handle cases when we can receive a concrete instance

The problem with `null` being passed to `ReflectionClass` was always
there but in PHP 8.1+ it triggers a deprecation warnings.

Since having `null` in `$concrete` doesn't make sense to reflect
anything anyway, we just throw a custom exception (which gets caught a
couple lines below) and just carry on.

When using `-v` this can be seen, example:
```
$ ./artisan ide-helper:meta -v
Cannot make 'Faker\Generator': Class 'Faker\Provider\en_US\Barcode' not found.
Cannot make 'Illuminate\Contracts\Auth\Authenticatable': Class  does not exist
Cannot make 'cache.psr6': Class 'Symfony\Component\Cache\Adapter\Psr16Adapter' not found.
Cannot make 'csp-nonce': Class 'Wza3Mf4CXIvCkcp9K3boMUGJoK6S9maO' not found.
Cannot make 'env': Class 'local' not found.
Cannot make 'filesystem.cloud': Disk [s3] does not have a configured driver.
Cannot make 'redis.connection': Redis connection [default] not configured.
A new meta file was written to .phpstorm.meta.php
```

* gha: make sure to run meta with -v to see all output

Helps when debugging things

* Add CHANGELOG.md entry
2022-05-21 22:38:28 +02:00
Barry vd. Heuvel 3ba1e2573b Update CHANGELOG.md v2.12.3 2022-03-06 15:33:42 +01:00
Barry vd. Heuvelandbarryvdh 6b58c23e6f Update composer.json (#1327)
* Update composer.json

* normalize composer.json

Co-authored-by: barryvdh <[email protected]>
2022-03-06 15:31:47 +01:00
FLeudts 6041681495 Add support for Carbon serialization options (#1324)
* Add Carbon serialization option handling

* Tests Added

* Add changelog

* Spellcheck
2022-03-04 09:12:42 +01:00
Barry vd. Heuvel ddb74fb5c8 Test 9.* integration (#1314) 2022-02-09 08:09:10 +01:00
Barry vd. Heuvel 7917cce7c9 Update CHANGELOG.md v2.12.2 2022-02-08 20:30:33 +01:00
Barry vd. Heuvel 6627cb9587 Normalize composer.json 2022-02-08 20:26:43 +01:00
Barry vd. Heuvelandlaravel-ide-helper 3b03e4055d Replace composer with copy of classmap generator (#1313)
* Replace composer with copy of classmap generator

* composer fix-style

* Remove phpcleaner

* composer fix-style

* Use filecleaner copy

* composer fix-style

Co-authored-by: laravel-ide-helper <[email protected]>
2022-02-08 20:20:22 +01:00
Barry vd. Heuvel a227fca325 Update README.md 2022-01-30 13:44:04 +01:00
Markus Podar 999167d4c2 Prepare 2.12.1 patch release (#1307)
### Fixed
- Properly handle `Castable`s without return type. [#1306 / binotaliu](https://github.com/barryvdh/laravel-ide-helper/pull/1306)
v2.12.1
2022-01-24 22:36:43 +01:00
BinotaLIU 2673bf4889 return mixed if we failed detect castable type (#1306)
fixed #1305
2022-01-24 21:39:17 +01:00
Markus Podar 771770e56c Merge pull request #1304 from mfn/mfn-release
Prepare 2.12 release
v2.12.0
2022-01-23 17:50:53 +01:00
Barry vd. Heuvel 88353535f2 Update composer.json 2022-01-23 17:46:42 +01:00
mfn acb2df9dfb normalize composer.json 2022-01-23 16:39:03 +00:00
Markus Podar 7052b4f708 Prepare 2.12 release
### Added
- Add support for custom casts that using `Castable` [#1287 / binotaliu](https://github.com/barryvdh/laravel-ide-helper/pull/1287)
- Added Laravel 9 support [#1297 / rcerljenko](https://github.com/barryvdh/laravel-ide-helper/pull/1297)
2022-01-23 17:38:31 +01:00
Yehuda Katz ac1e27167d Disabled PHPCS (#1301)
PHPCS is a common development tool. It makes sense to disable it in addition to Eclipse/IntelliJ formatting disable
2022-01-20 14:27:58 +01:00
de64d665e0 added laravel 9 support (#1297)
* added laravel 9 support

* added exclude directives to matrix

* fixed matrix

* Update composer.json

* Update run-integration-tests.yml

* Update CHANGELOG.md

Co-authored-by: Ricardo Čerljenko <[email protected]>
Co-authored-by: Barry vd. Heuvel <[email protected]>
2022-01-13 15:38:59 +01:00
Markus Podar 93d987336b Adapt/fix changelog now that a new release was made (#1294)
Triggered by https://github.com/barryvdh/laravel-ide-helper/pull/1287#issuecomment-1008344636
2022-01-09 22:26:59 +01:00
BinotaLIU 744a9cf380 support Castables (#1287) 2022-01-09 18:52:15 +01:00
Markus Podar f2a7f9d84f Improve performance for supporting Laravel 8.77+ cast attributes (#1292)
#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
```
v2.11.0
2022-01-03 21:47:54 +01:00
Simon Jønsson 29dd57e1e2 Support Laravel 8.77 Attributes (#1289)
*  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
2022-01-03 10:02:18 +01:00
Maduka Jayalath 6244a931a0 Update README.md (#1290)
Shorten links to texts from artisan commands so it will be easy to copy those commands to use.
2022-01-03 07:40:25 +01:00
Michael Newton ebea96213d Improve casts support (#1262)
* support for all possible `Model::$casts` types

* add testing for casts

* update changelog

* update changelog (again?)
2021-11-14 17:40:15 +01:00
Sergiy Petrov 01be015f86 PHP 8.1 Support (#1274)
* test against php 8.1

* fix tests
2021-10-31 14:55:33 +01:00
Silvan Krähenbühl a091b9c94a Allow casts without property (#1267)
* Allow casts without property

* Update changelog
2021-10-25 13:45:30 +02:00
George Boot dd12b7cdcb Generate cleaner model mixin classes (#1268)
* Generate cleaner model mixin classes

* Fix test
2021-10-25 13:44:43 +02:00
Stephan Tijink ae48e1e467 Update dependency composer/composer to 1.10.23 and 2.1.9 due to security issue (#1271)
* Update composer/composer to 2.0.23

* Update composer/composer to 2.1.9

* Also update composer/composer 1.x
2021-10-25 09:09:49 +02:00
Wim Reckmanandlaravel-ide-helper c733bde1ea Move default models filename to config (#1241)
* Move default models filename to config

* Add default value when getting models helper filename from config

* composer fix-style

Co-authored-by: laravel-ide-helper <[email protected]>
2021-08-10 07:12:56 +02:00
atsu.kg 52a4b64656 Consider foreign key constraints with isRelationNullable (#1231)
* Consider foreign key constraints with isRelationNullable

* test: add belongsTo Variation

* command: composer test-regenerate
2021-08-07 13:31:20 +02:00
Barry vd. Heuvel b268871c16 Fix tests 2021-08-04 11:40:36 +02:00
Ajay Dwivedi 2fc239623b Fix #1173 Use FQN for write-mixin (#1174)
* Fix #1173 Use FQN for write-mixin

* Fix #1173 Use FQN for write-mixin: Update Test cases
2021-08-04 11:26:51 +02:00
37f08320ea Make tests pass on Windows (#1205)
* 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]>
2021-08-04 11:22:48 +02:00
ZeroThe2nd b6871d09a4 Bugfix/custom types cause exception (#1228)
* bugfix/custom-types-cause-exception

- Added use statements for DBAL Exception and Type
- Added @throws tag to getPropertiesFromTable method
- Added Type::addType() to properly register types
- Added Try-Catch around Type::addType() to give users a proper error message, then throw the exception up.

* bugfix/custom-types-cause-exception

- Updated CHANGELOG.MD

* bugfix/custom-types-cause-exception

- Fixed `Type enum_string_boolean already exists.` error from being triggered when multiple models are loaded
2021-08-04 11:18:55 +02:00
Karel Faille 3b75048d12 Support variadic parameters in models command (#1234) 2021-08-04 11:13:23 +02:00
Jan Misker b162347aff fix when no enclosingClass can be found (#1239)
In certain situations no enclosingClass can be found, quick fix is to just return then.
2021-08-04 11:12:34 +02:00
Richard van Baarsen f4e0fc3695 Allow for PhpDoc for macros with union types (#1148)
* 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
2021-07-30 08:54:59 +02:00
Alexander StockandMarkus Podar af84c78dec Use platformName to determine db type (#1212)
* Use current connection platform (driver) instead of default connection name to determine used dbms. Previous solution isn't working, when multiple connections with custom names are used.

* chore: add changelog

Co-authored-by: Markus Podar <[email protected]>
2021-06-20 10:38:04 +02:00
Daniël de WitandMarkus Podar e71f3d5fc0 Check for traits recursively (#1216)
* Check for traits recursively

* Remove autoload bool from class_uses_recursive

* Add test

* Update src/Console/ModelsCommand.php

Co-authored-by: Markus Podar <[email protected]>

* Updated changelog

Co-authored-by: Markus Podar <[email protected]>
2021-06-20 10:18:14 +02:00
Markus Podar df670747c3 composer.json: remove --prefer-lowest (#1217)
IMHO it's impractical to expect this package to have to work with the
"first release of Laravel for any major release" even when there are
already sever more releases: no one is/should stick to that version.

This is a re-submit of https://github.com/barryvdh/laravel-ide-helper/pull/1076

See also:
- https://github.com/barryvdh/laravel-ide-helper/pull/1216#issuecomment-831029022
- https://github.com/barryvdh/laravel-ide-helper/pull/1185#issuecomment-831029353
2021-06-20 10:11:57 +02:00
Barry vd. Heuvel 3a4eee9487 Update composer.json 2021-06-12 10:09:56 +02:00
Barry vd. Heuvel eb8c5729ae Update FUNDING.yml 2021-06-12 10:09:29 +02:00
Markus Podar dc5282e9a4 Merge pull request #1211 from madalinignisca/patch-1
Fix link to DBAL types
2021-04-13 20:37:23 +02:00
Madalin IgniscaandMarkus Podar c82529babd Update config/ide-helper.php
Let's hope users know to switch to the version locked by composer.

Co-authored-by: Markus Podar <[email protected]>
2021-04-13 11:46:59 +02:00