Commit Graph
740 Commits
Author SHA1 Message Date
Ahmed Fathy 4f13ba85bd Generate PHPDoc for laravel 8.x factories (#1074)
* Generate PHPDoc for laravel 8.x factories

* formatting

* sorting imports

* fix code style

* fix tests in laravel 7.x and lower

* use markTestSkipped

* fix test failing ~_~

* add  argument

* determine the laravel vertion is 8.2.x or upper

* use version_compare instead of artisan command

* use correct namespace

* formatting

* formatting

* formatting

* update next release notes
2021-01-06 13:38:26 +01:00
Markus Podar 0fee1c47d3 Update changelog / releases (#1134) 2020-12-30 18:12:38 +01:00
Markus Podar 64a6b90258 [2.9] Drop support for: Laravel 6, Laravel 7, PHP 7.2 and add doctrine/dbal ^3 (#1114)
* composer.json: drop support for PHP 7.2/Laravel 6+7 and bump dependencies

* tests: remove framework version tests

They don't apply anymore, we're Laravel 8+ only from now on

* changelog: update for ending support for L6/7 and PHP7.2
v2.9.0
2020-12-29 11:11:05 +01:00
Aleksei Lebedev 25cc68c75f Macro::initPhpDoc() will save original docblock if present. (#1116)
* `Macro::initPhpDoc()` will save original docblock if present.

* Added `MacroTest::testInitPhpDocClosureWithoutDocBlock()`.

* Mock class rename.

* Code cleanup.
2020-12-23 12:26:18 +01:00
Aleksei Lebedev 36c4406b3a Alias will grab macros from \Illuminate\Database\Eloquent\Builder too (#1118)
* `Alias` will grab macros from `\Illuminate\Database\Eloquent\Builder` too.

* `@return` will contains `|static` for Eloquent Builder macros which return Eloquent Builder instance.

* `Macro` tests.

* `Alias::detectMethods()` tests.

* Mock classes rename.
2020-12-21 11:15:47 +01:00
Barry vd. Heuvel 9ba2f5c557 Update run-static-analysis.yml (#1131) 2020-12-21 09:34:43 +01:00
Kaloqn 5515cabea3 FQCN bugfix when writing external eloquent builder methods inside models. (#1113)
* Fix code that was causing the test to break and fix bug with not built in types

* Run cs fixer

* Remove fetching the doc block type and the putting it as a type hint as a php doc block is sufficient

* Revert doc block type hinting

* Enchance doc block type hinting

* Combine replacements

* Use the full builder class instead of the parsed one after the getClassName function and remove in array check

* Get the builder from the model itself instead of passing a string directly the function

* Use the full builder class to get the builder methods and reflection, but use the parsed builder class after setting its method in the doc

* Add test for fqn support on external eloquent builder

* Use the external builder if necessary when building the magic wheres

* Use the default eloquent builder if the user has disabled the external builder option
v2.8.2
2020-12-06 09:55:05 +01:00
Kaloqn 9859958cfa Fix broken test "GeneratePhpdocWithExternalEloquentBuilder" (#1111)
* Fix code that was causing the test to break and fix bug with not built in types

* Run cs fixer

* Remove fetching the doc block type and the putting it as a type hint as a php doc block is sufficient

* Revert doc block type hinting

* Enchance doc block type hinting

* Combine replacements
2020-12-04 14:23:42 +01:00
Markus Podar ae5d7708b7 Remove format and broken generateJsonHelper (#1053)
The JSON generate doesn't work, always generates an empty list.

I looked a bit around and seems changes around 3 years ago broke it.

Since there was no bug report ever about this, I conclude this feature
isn't used and suggest to remove it.

This also changes the config `filename` as there's no need for the
extension-less version and the format is gone too. This change is
backwards compatible as we just add back the `.php` in case it's missing
though users are encouraged to update it.
2020-12-04 09:54:50 +01:00
Barry vd. Heuvel 113545bc1a Fix snapshot 2020-12-04 09:25:31 +01:00
Barry vd. Heuvel ff54a20d21 Fix CS 2020-12-04 09:22:58 +01:00
Kaloqn db53e8e2b5 Add support for dedicated eloquent builders and type/doc parameter support. (#1089)
* Add support for generating helpers for external eloquent builders

* Extract external builder methods generator to its own method and add an option to toggle this feature

* Check if we are using the default name of the eloquent builder

* Add tests with snapshots for external eloquent builder feature

* Refactor codegs

* Allow for type hinting

* Update test

* Run cs fix

* Update readme

* Use getName for parameter instead of relying on __toString()

* Do not use str_contains and use built in php method
2020-12-04 07:36:08 +01:00
Matthew Hailwood b3a79fe6c1 Allow casts with a return type of static or this to reference themselves (#1103)
* Allow casts with a return type of static or this to reference themselves

Supports

```php
/**
     * @param $model
     * @param string $key
     * @param $value
     * @param array $attributes
     * @return static
     */
    public function get($model, string $key, $value, array $attributes)
    {
        return new static($value);
    }
```

or

```php
/**
     * @param $model
     * @param string $key
     * @param $value
     * @param array $attributes
     * @return $this
     */
    public function get($model, string $key, $value, array $attributes)
    {
        return new static($value);
    }
```

* Update CHANGELOG.md
2020-12-04 07:33:45 +01:00
Markus Podar b4138e5122 [PHP8] Add initial compatibility (#1106)
* gha: run on PHP8 too

The composer.json constraint is unbound, so it's already "allowed" at least.

* gha: remove php-cs-fixer when running unit tests

- not necessary anyway
- not compatible with PHP8 currently

* gha: lumen 6 and 7 don't support PHP8

* composer.json: allow spatie/phpunit-snapshot-assertions 4.* for PHP8 compatibility

* php8-compat: Method ReflectionParameter::getClass() is deprecated

* php8-compat: adapt expected error message depending on PHP version

* composer.json: bump mockery to 1.3.3 minimum

This is the minimum version also supporting PHP8

* gha: disable prefer-lowest for PHP8

Some lower version requirements like doctrone/dbal won't work and
would require at least dbal 2.12.0, which in turn doesn't support PHP 7.2
anymore.

So instead of bumping dbal and excluding PHP 7.2 users, we ignore the
lowest version for PHP 8 for the time being.

* Update CHANGELOG.md
2020-12-04 07:28:07 +01:00
Markus Podar c4d1f780b0 composer.json: remove -dev from composer/composer dependency (#1109)
Stable 2 has been released some time ago
2020-12-04 07:13:26 +01:00
Chun-Sheng, Liandlaravel-ide-helper 317889805b Test enhancement (#1100)
* Improve PHPUnit assertions

* composer fix-style

Co-authored-by: laravel-ide-helper <[email protected]>
2020-11-30 15:33:15 +01:00
Markus Podarandlaravel-ide-helper ca0cf7355a [GHA] Misc improvements (#1101)
* gha: be more specific which OS to use

Avoids "surprises" when Github changes the underlying version, like they
currently announce with a warning:
> Ubuntu-latest workflows will use Ubuntu-20.04 soon. For more details, see https://github.com/actions/virtual-environments/issues/1816

Note: basically right now "latest" is actually 18.04 and not 20.04

* composer fix-style

* gha: require league/flysystem:^1 for lumen

2.* doesn't work out of the box

* gha: explicit version of composer isn't necessary anymore

v2 is already the default

* Be explicit to require the pdo SQLite extension for tests

Co-authored-by: laravel-ide-helper <[email protected]>
2020-11-30 15:13:01 +01:00
Pataar 336ae44ef2 Add Lumen 8 to integration test (#1093) 2020-11-17 10:45:20 +01:00
domkrm 0168e7256b Fix generate error when macroable class has a "fake" method (#1066) 2020-09-21 16:26:32 +02:00
Isaac EarlandMarkus Podar 1044f466e9 allow model_locations to have glob patterns (#1059)
* allow model_locations to have glob patterns

This if statement check for a valid directory was happening to early.  It was checking the string that contained the wildcards to see if it is a valid directory and always failing.  Need to check after the foreach starts. fixes #1058 .

* test(#1059) Allow glob directories

* Fix tests to chdir() into where to expect the glob to work

* Update CHANGELOG.md

Co-authored-by: Markus Podar <[email protected]>
2020-09-20 22:06:24 +02:00
Igor Finagin fd4d280a80 [LARAVEL 8] include_factory_builders does not work anymore (#1047) (#1049)
* [LARAVEL 8] include_factory_builders does not work anymore (#1047)

* Change skip expression
Append comment about deprecated to config file
Append comment about deprecated to README file
2020-09-20 08:36:35 +02:00
Richard van BaarsenandMarkus Podar 2ff9672a49 Add @see location for macros & mixins to PhpDoc (#1054)
* Add @see location for macros & mixins to PhpDoc

* Fix CS

* Add entry to changelog

* Improve changelog entry

* Adjust CS

* Update CHANGELOG.md

Co-authored-by: Markus Podar <[email protected]>
2020-09-11 16:35:41 +02:00
PataarandMarkus Podar 00ee13e0cf Add integration test workflow (#1050)
* Add fresh run workflow

* Change name of step

* Update .github/workflows/run-fresh.yml

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

* Apply suggestions from code review

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

* Fix feedback

* Fix feedback, add file existence check

* Improve test

* Change way of checking files

* Fix tests

* Add log count check

* Add fi

Co-authored-by: Markus Podar <[email protected]>
2020-09-11 14:59:01 +02:00
Markus Podar 4ef3876b94 Fix compatibility with Lumen (#1043)
* Fix compatibility with Lumen

Fixes https://github.com/barryvdh/laravel-ide-helper/issues/1042

Got broken by https://github.com/barryvdh/laravel-ide-helper/pull/1026

TL;DR: can't use anything in the `Illuminate\Foundation` namespace
without safety check, as it doesn't exist in Lumen.

* Add helper to check for Laravel

* Use helper to check for Laravel
2020-09-11 09:13:35 +02:00
Markus Podar 5db6029f2c Give feedback when a relation can't be resolved (#1052)
Improves https://github.com/barryvdh/laravel-ide-helper/pull/1017 slightly
2020-09-10 21:58:16 +02:00
Markus Podar 2a3c7fb087 Update CHANGELOG.md (#1046) 2020-09-09 09:13:22 +02:00
Shohei KondoandMarkus Podar b677af89c2 implement DeferrableProvider (#914)
$defer has been deprecated after laravel 5.8
(https://laravel.com/docs/5.8/upgrade#deferred-service-providers)

and removed after laravel 6.x
(https://github.com/laravel/framework/pull/27505)

Co-authored-by: Markus Podar <[email protected]>
2020-09-09 08:27:14 +02:00
Markus Podar 594534ec5a [PSALM] Update baseline (#1044)
* composer: add script to set psalm baseline

* composer psalm-set-baseline
2020-09-08 21:52:35 +02:00
efinder2andMarkus Podar 7305504c99 Created a positiblity to add custom relation type (#987)
* Created a positiblity to add custom relation type

* Changed access modifier

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

* fixed hints from code review

* Added Test for https://github.com/barryvdh/laravel-ide-helper/pull/987

* composer fix-style

* Clarify doc in config entry

* Update CHANGELOG.md

Co-authored-by: Markus Podar <[email protected]>
2020-09-08 07:18:43 +02:00
Artem KryukovandMarkus Podar 186340bedc Fix phpdoc generate for custom cast with parameter (#986)
* Fix phpdoc generate for custom cast with parameter

* Add param for cast

* Simplify cast class name normalizing

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

* Update changelog

* composer fix-style

Co-authored-by: Markus Podar <[email protected]>
2020-09-07 22:39:35 +02:00
Markus Podar 4aa2e6a576 Update CHANGELOG.md (#1040) 2020-09-07 19:03:31 +02:00
Markus Podar 9baf93a502 Add github issue/PR templates (#1041) 2020-09-07 19:02:38 +02:00
Markus PodarandBarry vd. Heuvel affa55122f [TESTS] Running in CI should not create but rather fail on missing snapshots (#1039)
* tests: running in CI should not create but rather fail on missing snapshots

Otherwise they get created on the CI infrastructure but that's it, the
build won't fail although it was forgotten to add the snapshot.

* Bump minimum phpunit version which correctly accepts the `-d` parameter

The `prefer-lowest` version we get with L6 is 8.0.0 which throws this error:
```
PHP Fatal error:  Uncaught TypeError: ini_set() expects parameter 2 to be string, bool given in /home/runner/work/laravel-ide-helper/laravel-ide-helper/vendor/phpunit/phpunit/src/TextUI/Command.php:379
```

* Update composer.json

Co-authored-by: Barry vd. Heuvel <[email protected]>
v2.8.1
2020-09-07 09:36:37 +02:00
Barry vd. HeuvelandMarkus Podar b7d84785b1 GHA Composer v2 (#968)
* Update run-tests.yml

* Update run-tests.yml

* Update run-tests.yml

* Update run-tests.yml

* Update run-tests.yml

* Update run-tests.yml

* Update run-tests.yml

* gha: no need for self-update, setup-php `composer:v2` already gives the version we want

Co-authored-by: Markus Podar <[email protected]>
2020-09-07 09:26:20 +02:00
Daniel Mendes 4df96b5e62 Change $this->app->environment() !== 'production' to $this->app->isLocal() (#886)
* README.md: $this->app->environment() !== 'production' to $this->app->isLocal()

* Renamed to README.md

* Remove unrelated changes
2020-09-06 07:58:51 +02:00
domkrmandDominik Krämer 3a22b8daf6 Add better support for macros and mixins (#1006)
Co-authored-by: Dominik Krämer <[email protected]>
2020-09-06 07:58:13 +02:00
edcorewebandMarkus Podar 24596b67f1 New --write-mixin option. (#764)
* New --write-mixin option.

* Keep all tags from the existing docblock.

* Update argument description to be more descriptive

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

* Add the new --write-mixin option to the docs

* Add test for the new --write-mixin option

* Update README.md

* composer fix-style

* Adapt test after refactoring recently done

Co-authored-by: Markus Podar <[email protected]>
2020-09-06 07:57:00 +02:00
Markus Podar d978986523 Remove GrumPHP (#1036)
* composer remove --dev phpro/grumphp

* Remove remains of grumphp
2020-09-04 19:05:00 +02:00
Markus Podar 3ea232dc3a Add initial changelog (#1035)
At least until 2.6.6; quite a chore ;)

The idea is to keep it updated; ideally each PR updates the changelog
otherwise we/I will keep track of the "notable" changes.

The goal would be that once the next release is about to happen, the
changes collected here so far can just be copy-pasted to the release
notes and the top link has to be bumped.

I would define "notable" as user-facing, thus many internal changes
(readme, test suite, etc.) have not been added to give end-users a
clearer focus what may have changed/improved _for them_.
2020-09-03 06:00:59 +02:00
Markus Podar 007d3adb68 Run composer fix-style and vendor/bin/phpunit -d --update-snapshots to solve failed build (#1032) 2020-09-01 19:50:05 +02:00
Markus PodarandBarry vd. Heuvel 764bc02b84 [CODESTYLE] Replace phpcs with php-cs-fixer (#1030)
* composer require --dev friendsofphp/php-cs-fixer:^2

* php-cs-fixer: ignore cache and custom local config file

* php-cs-fixer: initial config

* php-cs-fixer: replace commands in composer

* php-cs-fixer: add PSR12 "as good as it currently gets"

* php-cs-fixer: apply PSR12 to codebase

* tests: add workaround to keep unused imports for snapshot testing

* php-cs-fixer: apply no_unused_imports

* php-cs-fixer: apply array_syntax short

* php-cs-fixer: apply single_quote

* php-cs-fixer: switch ordered_imports sort_algorithm to alpha

Let's be opinionated here for consistency

* php-cs-fixer: split between non-tests and tests and share config

* php-cs-fixer: apply declare_strict_types for tests

* php-cs-fixer: apply fully_qualified_strict_types

* php-cs-fixer: apply space_after_semicolon

* php-cs-fixer: apply trailing_comma_in_multiline_array

* php-cs-fixer: apply trim_array_spaces

* php-cs-fixer: apply unary_operator_spaces

* php-cs-fixer: apply whitespace_after_comma_in_array

* php-cs-fixer: apply native_function_invocation

* php-cs-fixer: apply concat_space

* grumphp: reflect we're using phpcsfixer now

* composer remove --dev squizlabs/php_codesniffer

* gha: simplify fix-style approach

Not really necessary to remove packages and then manually prevent
unrelated commits creeping in

Co-authored-by: Barry vd. Heuvel <[email protected]>
2020-09-01 11:32:31 +02:00
edvordo a96add6981 update(config/model command): add option to force usage of FQN + tests (#1031) 2020-09-01 09:11:12 +02:00
Markus Podar 4a6d127440 Improve gitignore a bit (#1029)
- build isn't used AFAIK?
- add `/` prefix were we know they're only expected to be in the root anyway
  except `.phpunit.result.cache` which may appear anywhere it's run from
2020-08-31 20:33:07 +02:00
Markus Podar 1ca875fbca Make createLocalViewFactory compatible with Laravel 8 (#1026)
* Make createLocalViewFactory compatible with Laravel 8

Fixes https://github.com/barryvdh/laravel-ide-helper/issues/1024

* tests: move up mockFilesystem so it get be re-used in other tests

Note: removed `$this->mockOutput = '';` as it was a no-op, that property
doesn't exist (it was probably a typo, but I guess we don't need it
anyway)

* tests: show basic features for ide-helper:meta working
2020-08-31 06:20:02 +02:00
Markus Podar 462989abd5 Fix type for new meta command 🤷‍♀️ (#997) 2020-08-30 21:33:19 +02:00
Markus Podar bd5b6ecee7 Remove unused use vars (#1027) 2020-08-30 21:32:47 +02:00
Markus Podar 3b66fea925 tests: no need for < 6 check, as we don't test < L6 anymore (#1025) 2020-08-30 21:32:15 +02:00
Markus Podar 707ec990e7 tests: remove L5.5 workaround (#1023) 2020-08-29 08:12:11 +02:00
Barry vd. Heuvelandbarryvdh a49cb46fdf Bump Laravel versions (#1022)
* Bump Laravel versions

* Test Laravel 8

* Update composer.json

* Update composer.json

* normalize composer.json

* Tweak MethodTest for Laravel 8

Co-authored-by: barryvdh <[email protected]>
2020-08-28 22:26:05 +02:00
Barry vd. Heuvel a12f902b33 Avoid duplicate tests (#1021) 2020-08-28 16:12:41 +02:00