- 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)
* Remove grumphp
It reports so many violations, I don't think anyone paid attention
to them in some time.
Also there's code sniffer which is:
- installed
- works
- and also run on travis explicitly
Here are the current violations:
```
$ vendor/bin/grumphp run
PHP Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /Users/mfischer/src/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 /Users/mfischer/src/laravel-ide-helper/vendor/phpro/grumphp/src/Locator/ConfigurationFile.php on line 75
GrumPHP is sniffing your code!✘
Running task 2/2: Phpunit... ✔
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▄███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▀█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▀▀▓▓▓▓▓▓▓▓▓▓▓▓█▀▀▀▀▀▀▀▀▀▀▀▀▀▀████████████▄
▄███████ ██████████
███████▀ ▀▀▀▀▀▄ ▄▀▀▀▀▀ █████ ▀
▐████ ▐██ ▐██ ████▌
████▌ ███
▌██▌ ▄▄ ▄▄ ▐███
███ ▄▄▄▄▄▄▄▄▄▄▄▄ ▐███
██▄ ▐███████████████████████████
█▀███████████▀ ▀▀███████████
██████████▄███████▄███████████
▐█████████████████████████████
█████████████████████████████
██ █████████████████████▐██▀
▀ ▐███████████████████▌ ▐▀
████▀████████▀▐███
▀█▌ ▐█████ ██▌
██▀ ▐▀
██████████████████████████████████
█░░░░░░▀█▀░░░░░░▀█░░░░░░▀█▀░░░░░▀█
█░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█
█░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█
█░░▐█▌░░█░░░██░░░█░░░░░░▄█░░▄▄▄▄▄█
█░░▐█▌░░█░░░██░░░█░░░░████░░░░░░░█
█░░░█░░░█▄░░░░░░▄█░░░░████▄░░░░░▄█
██████████████████████████████████
FILE: ...Users/mfischer/src/laravel-ide-helper/resources/views/helper.php
----------------------------------------------------------------------
FOUND 46 ERRORS AND 3 WARNINGS AFFECTING 24 LINES
----------------------------------------------------------------------
23 | ERROR | [x] Expected 1 space(s) after FOREACH keyword; 0
| | found
23 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
24 | ERROR | [x] Line indented incorrectly; expected at least 4
| | spaces, found 0
24 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
24 | ERROR | [x] Newline required after opening brace
24 | ERROR | [x] Closing brace must be on a line by itself
24 | ERROR | [x] Each PHP statement must be on a line by itself
26 | ERROR | [x] Line indented incorrectly; expected at least 4
| | spaces, found 0
26 | ERROR | [x] Expected 1 space(s) after FOREACH keyword; 0
| | found
26 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
26 | ERROR | [x] Blank line found at start of control structure
28 | ERROR | [x] Line indented incorrectly; expected at least 8
| | spaces, found 4
29 | ERROR | [x] Line indented incorrectly; expected at least 8
| | spaces, found 4
30 | ERROR | [x] Expected 1 space(s) after FOREACH keyword; 0
| | found
30 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
30 | ERROR | [x] Blank line found at start of control structure
32 | ERROR | [x] Line indented incorrectly; expected at least 12
| | spaces, found 8
34 | ERROR | [x] Expected 1 space(s) after IF keyword; 0 found
34 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
34 | ERROR | [x] Blank line found at start of control structure
37 | ERROR | [x] Closing brace indented incorrectly; expected 9
| | spaces, found 12
39 | ERROR | [x] Expected 1 space(s) after IF keyword; 0 found
39 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
51 | ERROR | [x] Expected 1 space(s) after FOREACH keyword; 0
| | found
51 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
53 | ERROR | [x] Line indented incorrectly; expected at least 4
| | spaces, found 0
53 | ERROR | [x] Expected 1 space(s) after FOREACH keyword; 0
| | found
53 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
53 | ERROR | [x] Blank line found at start of control structure
55 | ERROR | [x] Line indented incorrectly; expected at least 8
| | spaces, found 4
55 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
55 | WARNING | [ ] Line exceeds 120 characters; contains 180
| | characters
56 | ERROR | [x] Expected 1 space(s) after FOREACH keyword; 0
| | found
56 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
59 | ERROR | [x] Expected 1 space(s) after IF keyword; 0 found
59 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
59 | ERROR | [x] Blank line found at start of control structure
62 | ERROR | [x] Closing brace indented incorrectly; expected 13
| | spaces, found 16
64 | ERROR | [x] Expected 1 space(s) after IF keyword; 0 found
64 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
70 | ERROR | [x] Closing brace indented incorrectly; expected 4
| | spaces, found 0
76 | ERROR | [x] Expected 1 space(s) after IF keyword; 0 found
76 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
78 | ERROR | [x] Line indented incorrectly; expected at least 4
| | spaces, found 0
82 | ERROR | [x] Expected 1 space(s) after IF keyword; 0 found
82 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
109 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
112 | WARNING | [ ] Line exceeds 120 characters; contains 141
| | characters
113 | WARNING | [ ] Line exceeds 120 characters; contains 139
| | characters
----------------------------------------------------------------------
PHPCBF CAN FIX THE 46 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: /Users/mfischer/src/laravel-ide-helper/resources/views/meta.php
----------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 6 LINES
----------------------------------------------------------------------
14 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
17 | ERROR | [x] Line indented incorrectly; expected at least 4
| | spaces, found 0
17 | ERROR | [x] Expected 1 space(s) after FOREACH keyword; 0 found
17 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
23 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
24 | ERROR | [x] Spaces must be used to indent lines; tabs are not
| | allowed
26 | ERROR | [x] Line indented incorrectly; expected at least 4
| | spaces, found 0
26 | ERROR | [x] Expected 1 space(s) after FOREACH keyword; 0 found
26 | ERROR | [x] Expected 1 space(s) after closing parenthesis;
| | found 0
29 | ERROR | [x] Spaces must be used to indent lines; tabs are not
| | allowed
----------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 260ms; Memory: 12MB
```
* Remove scrutinizer/ocular
Looks unused, also not used on travis
* Remove StyleCI
Isn't enabled
* Revert "Remove grumphp"
This reverts commit a69696f0
* grumphp: add whitelist to ignore the resources/ folder
* grumphp: per .editorconf the indentation is 4 spaces, not 2
* phpunit: use dedicate `Tests` namespace for tests
* tests: replace phpunit with orchestra/testbench
* phpunit: ignore result cache file
* phpunit: adapt test for newer version
* tests: add base testcase class with a helper to run/assert commands
* tests: add test for ide-helper:eloquent
* travis: add global default variables
* travis: disable xdebug, speeds up running tests
* travis: convert php versions to build matrix for environment vars
* travis: only run phpcs/phpunit when the env vars signal it
However phpcs only runs with one test combination from the matrix,
not necessary to execute it every time.
Laravel 5.8 introduced a feature to support a custom date class via
`Date::use()`, see https://github.com/laravel/framework/pull/25320
When e.g. using `Date::use(CarbonImmutable)` in a project, it means
all date casts are not returning `\Illuminate\Support\Carbon` anymore
but `\Carbon\CarbonImmutable`, which means all the generated type hints
for dates are now wrong.
This change tries to be still backwards compatible with Laravel < 5.8
which do not have the Date facade.
A cast in Laravel should only affect the type, but not the database intrinsics whether a column accepts `null` or not.
As an example, consider this table (Postgres syntax):
```sql
CREATE TABLE foo (
some_column jsonb
);
```
This will be generated as: `@property string|null $some_column`
When providing a the following casts on the model:
```php
protected $casts = [
'some_column' => 'array',
];
```
then the generated property changes to: `@property array $some_column`
However the DB still accepts `null`, but this can't be expressed via the casts.
This change will make the null "sticky" and generate: `@property array|null $some_column`