* 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
* Remove doctrine/dbal:^4 support
Tests fail with:
`PHP Fatal error: Declaration of Illuminate\Database\PDO\Concerns\ConnectsToDatabase::connect(array $params, $username = null, $password = null, array $driverOptions = []) must be compatible with Doctrine\DBAL\Driver::connect(array $params): Doctrine\DBAL\Driver\Connection in /home/runner/work/laravel-ide-helper/laravel-ide-helper/vendor/laravel/framework/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php on line 22`
* gha: install with downgrading all dependencies
* Add note to readme
* Add support for nikic/php-parser:^5
- `createForHostVersion` has been added to php-parse 4.18 so code can
run with both versions [1]
- therefore also bumped the minimum required version to it
Note:
The dev dependency vimeo/psalm is **not** compatible with
php-parser:^5 currently. This does not impact usages of this library,
but sometimes cause friction when working on this library.
For our CI this isn't a problem, because we already remove that
dependency before running the test suite.
[1] https://github.com/nikic/PHP-Parser/blob/master/UPGRADE-5.0.md#changes-to-the-parser-factory
* gha: prevent cancelling of all jobs if one fails
* Update CHANGELOG.md
* gha: remove unsupported Laravel / PHP combinations
According to https://laravel.com/docs/10.x/releases
* Add dbal:^4 too
I'm proposing to drop official suport for Lumen for the following reasons:
- Lumen itself is dead, per [1]
> **Note:** In the years since releasing Lumen, PHP has made a variety of wonderful performance improvements. For this reason, along with the availability of [Laravel Octane](https://laravel.com/docs/octane), we no longer recommend that you begin new projects with Lumen. Instead, we recommend always beginning new projects with [Laravel](https://laravel.com).
Laravel Octact is just Laravel and no one using ide-helper with it
needs anything special.
- For now, the change is mostly on the logistics side (readme, run tests,
issues). In the past we had some special code but over time this was
already removed.
For now people still can use it and nothing will break out of the blue,
but eventually it might
There are a only a few Lumen related issues open currently which would
be closed by this (#1105, #1069, #438).
[1] https://github.com/laravel/lumen/commit/69b26578d2f15595ea901278434b74df459c4329
Co-authored-by: Barry vd. Heuvel <[email protected]>
* gha: fix workflow by allowing the composer-normalize plugin
We don't need to enable it in the project itself, but at least in this
workflow which explicitly uses it.
See https://github.com/barryvdh/laravel-ide-helper/actions/runs/3980013548/jobs/6822812621#step:4:34
```
Error: ergebnis/composer-normalize (installed globally) contains a Composer plugin which is blocked by your allow-plugins config. You may add it to the list if you consider it safe.
You can run "composer global config --no-plugins allow-plugins.ergebnis/composer-normalize [true|false]" to enable it (true) or disable it explicitly and suppress this exception (false)
```
* gha: also run this workflow when it is changed itself
* 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
#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
```
* 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
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.
* 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
* 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]>
* 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]>
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_.
- 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
* 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
Discovered via https://github.com/barryvdh/laravel-ide-helper/pull/1017#issuecomment-679318764
This only happens if you run an artisan command _before_ `runCommand`,
but since every of these tests performs migrations, using artisan,
the mocked output instance is left behind and also affected us.
The call added in `runCommand` explicitly unregisters
`\Illuminate\Console\OutputStyle` and thus also throwing away possibly
mocked versions.
I've tested this and yes, it *always* requires a FQN.
Therefore I removed the extra note regarding namespace/wrapping because
even by default Laravel has the `App\` namesapce, which requires this.
Fixes https://github.com/barryvdh/laravel-ide-helper/issues/995
* phpcs: enable also for config, resources and tests
* composer fix-style
* vendor/bin/phpunit -d --update-snapshots
* gha: instead of checking the style, fix and auto-commit it 💪
- support for < L5.5 was dropped, so no need to check if it's >= Laravel 5.2
- for the same reason, the Lumen 5.0/5.1 check isn't necessary because only supporting Laravel 5.5 means we only support the Laravel 5.5 _components_ which means the minimum supported Lumen version is also 5.5 (per https://lumen.laravel.com/docs/master/releases#5.5.0 )
Ensures they're always ordered / processed independent of the
environment. `ClassMapGenerator::createMap` uses symfony/finder which
itself supports sorting but this isn't used from the `ClassMapGenerator`.
Fixes https://github.com/barryvdh/laravel-ide-helper/issues/885
* readme: sublime command has been removed
Was removed in https://github.com/barryvdh/laravel-ide-helper/pull/976
as it was already deprecated for 7 years.
* readme: old link only redirects, use the destination link directly
* readme: mention that the default _ide_helper.php name can be changed
* readme: document `meta_filename` and hint it can be written into a special subdirectory
* readme: remove hint about \Eloquent or `@mixin`, as the latter is automatically added nowadays
* readme: update how the current phpdoc looks like
* readme: document `write_model_magic_where`
* readme: document `write_model_relation_count_properties`
* readme: document `custom_db_types`
* readme: clarify installation regarding auto-discovery vs. manual
* readme: mention to avoid caching the config in dev
Inspired by https://github.com/barryvdh/laravel-ide-helper/issues/832
- also drop dedicated testbench version, composer can figure it out itself
https://laravel.com/docs/7.x/releases#support-policy
Only 5.5 receives security fixes until 2020-08-30,
everything else < 6 isn't supported anymore.
Therefore I dropped all versions not officially
supported.
I also find the change in the matrix more readable without having to
mentally parse a set of a lot "includes",
I think this clarifies the intent better.
This also results in more jobs are more (correctly allowed) variations are now covered.
* Remove travis leftovers
* gha: remove --no-interaction
* gha: use separate job for style check and use composer scripts
* gha: give workflow a nice name
* gha: remove packages we don't need, reduce workflow runtime
Co-authored-by: Barry vd. Heuvel <[email protected]>
These two methods are already regular methods on the trait, there's no
need to add them and additionally they're not static, so their
definition was changed for the worse.
The other methods are magic so it's fine to keep them.
Fixes https://github.com/barryvdh/laravel-ide-helper/issues/917
* tests: be more systematic when testing discrete column types
Still not covering all due to SQLite limitation
* tests: relations of models
* tests: model in another namespace gets correctly qualified
* tests: cover SoftDeletes trait
* tests: cover some variants of getter
* tests: add abstract class for all database related tests
* tests: add abstract class for all ModelsCommand related tests
* tests: add GenerateBasicPhpdoc test
* tests: add CustomDate test
* tests: remove MITM abstract TestCaseDatabase, not useful here
* tests: skip new ModelsCommand test on Laravel < 6
* tests: remove CarbonImmutable checked
Since we decided to skip for Laravel < 6.0 anyway, it's always present
The current version emits the following:
```
Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in laravel-ide-helper/vendor/phpro/grumphp/src/Locator/ConfigurationFile.php on line 75
Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in laravel-ide-helper/vendor/phpro/grumphp/src/Locator/ConfigurationFile.php on line 75
```
Manually tested it locally, worked as expected.
* travis: use explicit test matrix and drop PHP < 7.2
* composer: use more liberal version requirements for orchestra
This is to easier satisfy when we want to use older Laravel versions on travis
* tests: add shim for assertStringContainsString for older Laravel/phpunit versions
Specifically, Laravel 5.5 works with an older phpunit version, which
does not feature assertStringContainsString
* composer: bump minimum PHP version to 7.2
* travis: explicitly install Mockery for testing older Laravel versions
* composer: make mockery a root requirement and remove the one from travis
* travis: further improve based on suggestions from https://github.com/fruitcake/laravel-cors/blob/master/.travis.yml
* tests: skip test if mixin markers are already present in model
We're also testing Laravel 5.5 which contains them (they were removed later)