Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Barry backport #2

Merged
merged 56 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
726e595
Add support for nikic/php-parser:^5 and (hopefully) doctrine/dbal:^4 …
mfn Jan 28, 2024
850fc5f
test: case for the issue #1505;
olexoliinyk0 Feb 2, 2024
9374952
Adapt snapshot testcase
mfn Feb 3, 2024
416e0ab
Merge pull request #1506 from olexoliinyk0/test/case-of-1505
mfn Feb 3, 2024
e65d30b
Remove doctrine/dbal:^4 support (#1507)
mfn Feb 5, 2024
cf4687f
Prepare 2.14.0 release (#1503)
mfn Feb 5, 2024
485c756
Prepare 2.14.0 release
barryvdh Feb 5, 2024
a8b34ad
Removed support for Laravel 8 and therefore for PHP < 8.0 (#1504)
mfn Feb 5, 2024
115068e
Clarify use of --reset and --smart-reset flags in documentation (#1494)
tobytwigger Feb 7, 2024
512612f
Remove outdated dev references to older versions (#1508)
mfn Feb 7, 2024
cc9ed44
disable inspections of helper files (#1486)
eidng8 Feb 7, 2024
f465625
Fix non-facade classes will result in no autocomplete (#841)
netpok Feb 7, 2024
9d14b01
skip swoole, otherwise fatal error (#1477)
TimoFrenzel Feb 7, 2024
f3ad134
FIX vulnerability CVE-2021-43608 (#1392)
allanlaal Feb 7, 2024
f64ff9c
Add support for enum default arguments using enum cases (#1464)
d8vjork Feb 7, 2024
c290af8
reset foreignKeyConstraintsColumns on model loop start (#1461)
snmatsui Feb 7, 2024
04c1a8d
Support generating helper files for real-time facades (#1455)
filipac Feb 7, 2024
872b470
Update CHANGELOG.md
barryvdh Feb 7, 2024
16548fc
Update README.md (#1451)
jamesbhatta Feb 7, 2024
2535f8e
Fix tests and CS
barryvdh Feb 7, 2024
409bbf6
Fix unsetMethod in ModelsCommand (#1453)
leo108 Feb 7, 2024
62fc436
Reintroduce support for multi-db setups (#1426)
benpoulson Feb 7, 2024
7d69dc6
CS
barryvdh Feb 7, 2024
5c886fb
Support the BINARY(...) database field type (#1434)
Sfonxs Feb 7, 2024
6115100
Add support for composite keys (#1479)
calebdw Feb 8, 2024
4751420
Accept `scope` & `scopes` as relation (#1452)
Muetze42 Feb 8, 2024
f12d933
Add support for non type-hinted attribute accessors with no backed pr…
pindab0ter Feb 8, 2024
9343d3a
CS
barryvdh Feb 8, 2024
cee441c
Fix #1300 relation_return_type must take precedence if it is defined …
menthol Feb 8, 2024
341c0ab
feat: add support for AsCollection and AsArrayObject casts (#1393)
pataar Feb 8, 2024
bc158a1
Add `AllowDynamicProperties` Attribute to cooperate with php8.2 depre…
GeoSot Feb 8, 2024
c119e89
CS
barryvdh Feb 8, 2024
dca3ebe
Prepare 2.15 release (#1514)
barryvdh Feb 14, 2024
b47a118
Adjust gitattribute (#1515)
mfn Feb 14, 2024
7783185
Fix final class keyword (#1517)
barryvdh Feb 15, 2024
bcc2332
[TEST] Show that custom phpdoc tags without space afterwards are unex…
mfn Feb 16, 2024
ed39977
Switch to 3.0 tag (#1519)
barryvdh Feb 17, 2024
6579c03
Remove doctrine (#1512)
barryvdh Feb 17, 2024
8bfe918
Update CHANGELOG.md
barryvdh Feb 17, 2024
05259b6
Add support for Laravel 11 (#1520)
barryvdh Feb 17, 2024
9af62e2
Bump minimum PHP version to 8.1 & misc maintenance (#1521)
mfn Feb 17, 2024
d7ed749
Use int/bool instead of longer variant (#1524)
barryvdh Feb 19, 2024
02af2a2
Merge reset/smart reset, don't set class (#1523)
barryvdh Feb 19, 2024
49ac75d
Remove `--smart-reset` completely (#1525)
mfn Feb 19, 2024
8eab699
phpunit --migrate-configuration (#1526)
mfn Feb 19, 2024
bc1d67f
Prepare 3.0 release (#1530)
barryvdh Mar 1, 2024
8e7134c
Add `AllowDynamicProperties` Attribute to cooperate with php8.2 depre…
stefanScrumble Mar 8, 2024
f1992ae
Fix collection attribute typing
stefanScrumble Mar 8, 2024
dcdb0c8
Update CHANGELOG.md
stefanScrumble Jan 4, 2024
8ae2632
Update CHANGELOG.md
stefanScrumble Jan 4, 2024
98252fe
Update composer.json
stefanScrumble Jan 5, 2024
7ad31cc
composer fix-style
Mar 8, 2024
e5782c3
Fix tests
stefanScrumble Mar 8, 2024
1a76112
Merge branch 'barry-backport' of https://github.com/scrumble-nl/larav…
stefanScrumble Mar 8, 2024
788c33b
Fix tests
stefanScrumble Mar 8, 2024
bcc32b4
Merge branch 'master' into barry-backport
stefanScrumble Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.editorconfig export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.php_cs.common.php export-ignore
/.php_cs.dist export-ignore
/.php_cs.tests.php export-ignore
/psalm.xml export-ignore
/psalm-baseline.xml export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.php-cs-fixer.cache export-ignore
/.php-cs-fixer.php export-ignore
/.php-cs-fixer.tests.cache export-ignore
/phpunit.xml.dist export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
/tests export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/composer-normalize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
normalize:
timeout-minutes: 15
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Git checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/fix-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
fix-style:
name: Fix Code Style
timeout-minutes: 15
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
COMPOSER_NO_INTERACTION: 1

Expand All @@ -18,7 +18,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.3
coverage: none

- name: Install dependencies
Expand Down
24 changes: 8 additions & 16 deletions .github/workflows/run-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,19 @@ on:

jobs:
php-laravel-integration-tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1
strategy:
fail-fast: false
matrix:
php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3]
laravel: [10.*, 9.*, 8.*]
php: [8.3, 8.2, 8.1]
laravel: [11.*, 10.*]
exclude:
- php: 8.0
laravel: 10.*
- php: 7.4
laravel: 10.*
- php: 7.4
laravel: 10.*
- php: 7.3
laravel: 10.*
- php: 7.4
laravel: 9.*
- php: 7.3
laravel: 9.*
- php: 8.1
laravel: 11.*

name: P${{ matrix.php }} - Laravel${{ matrix.laravel }}
steps:
- name: Checkout code
Expand All @@ -57,7 +49,7 @@ jobs:
run: |
cd sample
sed -e 's|"type": "project",|&\n"repositories": [ { "type": "path", "url": "../src" } ],|' -i composer.json
composer require --dev "barryvdh/laravel-ide-helper:*"
composer require --dev "barryvdh/laravel-ide-helper:*" --with-all-dependencies

- name: Execute generate run
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run-static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ on:
jobs:
build:
timeout-minutes: 15
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.3
coverage: none
extensions: pdo_sqlite

Expand Down
29 changes: 8 additions & 21 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,15 @@ jobs:
COMPOSER_NO_INTERACTION: 1

strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019]
php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3]
laravel: [8.*, 9.*, 10.*]
dependency-version: [prefer-lowest, prefer-stable]
os: [ubuntu-22.04, windows-2019]
php: [8.3, 8.2, 8.1]
laravel: [10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
exclude:
- php: 8.0
laravel: 10.*
- php: 7.4
laravel: 10.*
- php: 7.3
laravel: 10.*
- php: 8.0
dependency-version: prefer-lowest
- php: 7.4
laravel: 9.*
- php: 7.3
laravel: 9.*
- os: windows-2019
php: 7.4
- os: windows-2019
php: 7.3
- php: 8.1
laravel: 11.*
steps:
- name: Set git to use LF
if: ${{ matrix.os == 'windows-2019' }}
Expand All @@ -62,7 +49,7 @@ jobs:
composer remove vimeo/psalm --no-update --dev
composer remove friendsofphp/php-cs-fixer --no-update --dev
composer require "laravel/framework:${{ matrix.laravel }}" --no-update --no-progress
composer update --prefer-dist --no-progress
composer update --prefer-dist --no-progress --${{ matrix.stability }}

- name: Execute Unit Tests
run: composer test-ci
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.phpunit.result.cache

/.idea
/.php_cs
/.php_cs.cache
/.php_cs.tests.cache
/.php-cs-fixer.cache
/.php-cs-fixer.php
/.php-cs-fixer.tests.cache
/composer.lock
/vendor
3 changes: 1 addition & 2 deletions .php_cs.common.php → .php-cs-fixer.common.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
],
'return_type_declaration' => true,
'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
'single_trait_insert_per_statement' => true,
'ternary_operator_spaces' => true,
'visibility_required' => [
Expand All @@ -56,7 +55,7 @@
'no_unused_imports' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
Expand Down
6 changes: 3 additions & 3 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
->in(__DIR__)
->exclude('tests');

$config = require __DIR__ . '/.php_cs.common.php';
$config = require __DIR__ . '/.php-cs-fixer.common.php';

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setFinder($finder)
->setRules($config)
->setRiskyAllowed(true)
->setCacheFile(__DIR__ . '/.php_cs.cache');
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache');
6 changes: 3 additions & 3 deletions .php_cs.tests.php → .php-cs-fixer.tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
->in(__DIR__ . '/tests')
->exclude('__snapshots__');

$config = require __DIR__ . '/.php_cs.common.php';
$config = require __DIR__ . '/.php-cs-fixer.common.php';

// Additional rules for tests
$config = array_merge(
Expand All @@ -15,8 +15,8 @@
]
);

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setFinder($finder)
->setRules($config)
->setRiskyAllowed(true)
->setCacheFile(__DIR__ . '/.php_cs.tests.cache');
->setCacheFile(__DIR__ . '/.php-cs-fixer.tests.cache');
76 changes: 76 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,82 @@

All notable changes to this project will be documented in this file.

[Next release](https://github.com/barryvdh/laravel-ide-helper/compare/v3.0.0...master)
--------------

### Fixed

### Changed

### Added

2024-03-01, 3.0.0
------------------

### Added
- Support for Laravel 11 [#1520 / KentarouTakeda](https://github.com/barryvdh/laravel-ide-helper/pull/1520)

### Changed
- Make `--reset` always keep the text and remove `--smart-reset`. Always skip the classname [#1523 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1523) & [#1525 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1525)
- Use short types (`int` and `bool` instead of `integer` and `boolean`) [#1524 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1524)

### Removed
- Support for Laravel 9 and use of doctrine/dbal [#1512 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1512)
With this functionality gone, a few changes have been made:
- support for custom datatypes has been dropped (config `custom_db_types`) unknown data types default to `string` now and to fix the type, add a proper cast in Eloquent
- You _might_ have top-level dependency on doctrine/dbal. This may have been in the past due to ide-helper, we suggest to check if you still need it and remove it otherwise
- Minimum PHP version, due to Laravel 10, is now PHP 8.1

2024-02-15, 2.15.1
------------------

### Fixed
- Fix final class keyword in wrong position [#1517 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1517)

### Changed

### Added

2024-02-14, 2.15.0
------------------
### Fixed
- Fix case issue in `ModelsCommand::unsetMethod()` [#1453 / leo108](https://github.com/barryvdh/laravel-ide-helper/pull/1453)
- Fix non-facade classes will result in no autocomplete [#841 / netpok](https://github.com/barryvdh/laravel-ide-helper/pull/841)
- Skip swoole, otherwise fatal error [#1477 / TimoFrenzel](https://github.com/barryvdh/laravel-ide-helper/pull/1477)
- Fix vulnerability CVE-2021-43608 [#1392 / allanlaal](https://github.com/barryvdh/laravel-ide-helper/pull/1392)
- Reset foreignKeyConstraintsColumns on model loop start [#1461 / snmatsui](https://github.com/barryvdh/laravel-ide-helper/pull/1461)
- Accept scope & scopes as relation [#1452 / Muetze42](https://github.com/barryvdh/laravel-ide-helper/pull/1452)
- Fix #1300 relation_return_type must take precedence if it is defined [#1394 / menthol](https://github.com/barryvdh/laravel-ide-helper/pull/1394)

### Changed
- Disable inspections of helper files [#1486 / eidng8](https://github.com/barryvdh/laravel-ide-helper/pull/1486)
- Removed support for Laravel 8 and therefore for PHP < 8.0 [#1504 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1504)

### Added
- Add support for enum default arguments using enum cases. [#1464 / d8vjork](https://github.com/barryvdh/laravel-ide-helper/pull/1464)
- Add support for real-time facades in the helper file. [#1455 / filipac](https://github.com/barryvdh/laravel-ide-helper/pull/1455)
- Add support for relations with composite keys. [#1479 / calebdw](https://github.com/barryvdh/laravel-ide-helper/pull/1479)
- Add support for attribute accessors with no backing field or type hinting [#1411 / pindab0ter](https://github.com/barryvdh/laravel-ide-helper/pull/1411).
- Add support for AsCollection and AsArrayObject casts [#1393 / pataar](https://github.com/barryvdh/laravel-ide-helper/pull/1393)
- Reintroduce support for multi-db setups [#1426 / benpoulson](https://github.com/barryvdh/laravel-ide-helper/pull/1426)
- Support the BINARY(...) database field type [#1434 / Sfonxs](https://github.com/barryvdh/laravel-ide-helper/pull/1434)
- Add AllowDynamicProperties Attribute to cooperate with php8.2 deprecation [#1428 / GeoSot](https://github.com/barryvdh/laravel-ide-helper/pull/1428)

2024-02-05, 2.14.0
------------------

### Changed
- Official support for Lumen has been dropped [#1425 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1425)
- Refactor resolving of null information for custom casted attribute types [#1330 / wimski](https://github.com/barryvdh/laravel-ide-helper/pull/1330)

### Fixed
- Catch exceptions when loading aliases [#1465 / dongm2ez](https://github.com/barryvdh/laravel-ide-helper/pull/1465)

### Added
- Add support for nikic/php-parser 5 (next to 4) [#1502 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1502)
- Add support for `immutable_date:*` and `immutable_datetime:*` casts. [#1380 / thekonz](https://github.com/barryvdh/laravel-ide-helper/pull/1380)
- Add support for attribute accessors marked as protected. [#1339 / pindab0ter](https://github.com/barryvdh/laravel-ide-helper/pull/1339)

2024-01-04, v2.14.0
------------------

Expand Down
38 changes: 13 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
This package generates helper files that enable your IDE to provide accurate autocompletion.
Generation is done based on the files in your project, so they are always up-to-date.

It supports Laravel 8+ and PHP 7.3+
The 3.x branch supports Laravel 10 and 11. For older version, use the 2.x releases.

- [Installation](#installation)
- [Usage](#usage)
Expand All @@ -33,6 +33,10 @@ Require this package with composer using the following command:
composer require --dev barryvdh/laravel-ide-helper
```

> [!NOTE]
> If you encounter version conflicts with doctrine/dbal, please try:
> `composer require --dev barryvdh/laravel-ide-helper --with-all-dependencies`

This package makes use of [Laravels package auto-discovery mechanism](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518), which means if you don't install dev dependencies in production, it also won't be loaded.

If for some reason you want manually control this:
Expand Down Expand Up @@ -68,7 +72,7 @@ If for some reason you want manually control this:
_Check out [this Laracasts video](https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/15) for a quick introduction/explanation!_

- `php artisan ide-helper:generate` - [PHPDoc generation for Laravel Facades ](#automatic-phpdoc-generation-for-laravel-facades)
- `php artisan ide-helper:models` - [PHPDocs for models](#automatic-PHPDocs-for-models)
- `php artisan ide-helper:models` - [PHPDocs for models](#automatic-phpdocs-for-models)
- `php artisan ide-helper:meta` - [PhpStorm Meta file](#phpstorm-meta-for-container-instances)


Expand Down Expand Up @@ -109,6 +113,10 @@ The generator tries to identify the real class, but if it cannot be found, you c
Some classes need a working database connection. If you do not have a default working connection, some facades will not be included.
You can use an in-memory SQLite driver by adding the `-M` option.

If you use [real-time facades](https://laravel.com/docs/master/facades#real-time-facades) in your app, those will also be included in the generated file using a `@mixin` annotation and extending the original class underneath the facade.

**Note**: this feature uses the generated real-time facades files in the `storage/framework/cache` folder. Those files are generated on-demand as you use the real-time facade, so if the framework has not generated that first, it will not be included in the helper file. Run the route/command/code first and then regenerate the helper file and this time the real-time facade will be included in it.

You can choose to include helper files. This is not enabled by default, but you can override it with the `--helpers (-H)` option.
The `Illuminate/Support/helpers.php` is already set up, but you can add/remove your own files in the config file.

Expand Down Expand Up @@ -141,9 +149,9 @@ The class name will be different from the model, avoiding the IDE duplicate anno

> Please make sure to back up your models, before writing the info.

Writing to the models should keep the existing comments and only append new properties/methods.
The existing PHPDoc is replaced, or added if not found.
With the `--reset (-R)` option, the existing PHPDocs are ignored, and only the newly found columns/relations are saved as PHPDocs.
Writing to the models should keep the existing comments and only append new properties/methods. It will not update changed properties/methods.

With the `--reset (-R)` option, the whole existing PHPDoc is replaced, including any comments that have been made.

```bash
php artisan ide-helper:models "App\Models\Post"
Expand Down Expand Up @@ -263,26 +271,6 @@ add support for creating a new dedicated class instead of using local scopes in

If for some reason it's undesired to have them generated (one for each column), you can disable this via config `write_model_external_builder_methods` and setting it to `false`.

#### Unsupported or custom database types

Common column types (e.g. varchar, integer) are correctly mapped to PHP types (`string`, `int`).

But sometimes you may want to use custom column types in your database like `geography`, `jsonb`, `citext`, `bit`, etc. which may throw an "Unknown database type"-Exception.

For those special cases, you can map them via the config `custom_db_types`. Example:
```php
'custom_db_types' => [
'mysql' => [
'geography' => 'array',
'point' => 'array',
],
'postgresql' => [
'jsonb' => 'string',
'_int4' => 'array',
],
],
```

#### Custom Relationship Types

If you are using relationships not built into Laravel you will need to specify the name and returning class in the config to get proper generation.
Expand Down
Loading