mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ad16a295a | ||
|
|
c3f795e909 | ||
|
|
2fba281b14 | ||
|
|
39bcb60b7c | ||
|
|
16f685aa9f | ||
|
|
392d5cfc80 | ||
|
|
3d8fccd700 | ||
|
|
e9b62b6ee0 | ||
|
|
37dfcf9e14 | ||
|
|
573c9f3f57 | ||
|
|
fd3cfbe09d | ||
|
|
3bd70eafd0 | ||
|
|
5aca186d92 | ||
|
|
148f956272 | ||
|
|
cff155b0d3 |
@@ -1,75 +1,79 @@
|
|||||||
name: Integration Tests
|
name: Integration Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- "*"
|
- "*"
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * *'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
php-laravel-integration-tests:
|
php-laravel-integration-tests:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
timeout-minutes: 15
|
|
||||||
env:
|
|
||||||
COMPOSER_NO_INTERACTION: 1
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
php: [8.4, 8.3, 8.2]
|
|
||||||
laravel: [11.x, 12.x]
|
|
||||||
|
|
||||||
name: P${{ matrix.php }} - Laravel${{ matrix.laravel }}
|
timeout-minutes: 15
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
with:
|
|
||||||
path: src
|
|
||||||
|
|
||||||
- name: Setup PHP
|
env:
|
||||||
uses: shivammathur/setup-php@v2
|
COMPOSER_NO_INTERACTION: 1
|
||||||
with:
|
|
||||||
php-version: ${{ matrix.php }}
|
|
||||||
coverage: none
|
|
||||||
|
|
||||||
- name: Install dependencies
|
strategy:
|
||||||
run: |
|
fail-fast: false
|
||||||
composer create-project --prefer-dist laravel/laravel:${{ matrix.laravel }} --stability=dev --no-progress sample
|
matrix:
|
||||||
cd sample
|
php: [8.5, 8.4, 8.3, 8.2]
|
||||||
composer config minimum-stability dev
|
laravel: [11.x, 12.x, 13.x]
|
||||||
composer update --prefer-stable --prefer-dist --no-progress
|
exclude:
|
||||||
|
- laravel: 13.x
|
||||||
|
php: 8.2
|
||||||
|
|
||||||
- name: Add package from source
|
name: P${{ matrix.php }} - Laravel${{ matrix.laravel }}
|
||||||
run: |
|
|
||||||
cd sample
|
|
||||||
sed -e 's|"type": "project",|&\n"repositories": [ { "type": "path", "url": "../src" } ],|' -i composer.json
|
|
||||||
composer require --dev "barryvdh/laravel-ide-helper:*" --with-all-dependencies
|
|
||||||
|
|
||||||
- name: Execute generate run
|
steps:
|
||||||
run: |
|
- name: Checkout code
|
||||||
cd sample
|
uses: actions/checkout@v6
|
||||||
php artisan ide-helper:generate
|
with:
|
||||||
|
path: src
|
||||||
|
|
||||||
- name: Execute meta run
|
- name: Setup PHP
|
||||||
run: |
|
uses: shivammathur/setup-php@v2
|
||||||
cd sample
|
with:
|
||||||
php artisan ide-helper:meta -v
|
php-version: ${{ matrix.php }}
|
||||||
|
coverage: none
|
||||||
|
|
||||||
- name: Check file existence
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
ls sample/_ide_helper.php
|
composer create-project --prefer-dist laravel/laravel:${{ matrix.laravel }} --stability=dev --no-progress sample
|
||||||
ls sample/.phpstorm.meta.php
|
cd sample
|
||||||
|
composer config minimum-stability dev
|
||||||
|
composer update --prefer-stable --prefer-dist --no-progress
|
||||||
|
|
||||||
|
- name: Add package from source
|
||||||
|
run: |
|
||||||
|
cd sample
|
||||||
|
sed -e 's|"type": "project",|&\n"repositories": [ { "type": "path", "url": "../src" } ],|' -i composer.json
|
||||||
|
composer require --dev "barryvdh/laravel-ide-helper:*" --with-all-dependencies
|
||||||
|
|
||||||
- name: Check logs
|
- name: Execute generate run
|
||||||
run: |
|
run: |
|
||||||
if [ `ls -1q "sample/storage/logs/" | wc -l` -gt 0 ]; then
|
cd sample
|
||||||
for logfile in sample/storage/logs/*; do
|
php artisan ide-helper:generate
|
||||||
echo "-- $logfile --"
|
|
||||||
cat $logfile
|
- name: Execute meta run
|
||||||
done
|
run: |
|
||||||
exit 1
|
cd sample
|
||||||
fi
|
php artisan ide-helper:meta -v
|
||||||
|
|
||||||
|
- name: Check file existence
|
||||||
|
run: |
|
||||||
|
ls sample/_ide_helper.php
|
||||||
|
ls sample/.phpstorm.meta.php
|
||||||
|
|
||||||
|
- name: Check logs
|
||||||
|
run: |
|
||||||
|
if [ `ls -1q "sample/storage/logs/" | wc -l` -gt 0 ]; then
|
||||||
|
for logfile in sample/storage/logs/*; do
|
||||||
|
echo "-- $logfile --"
|
||||||
|
cat $logfile
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ jobs:
|
|||||||
run: composer install --prefer-dist --no-progress --no-suggest
|
run: composer install --prefer-dist --no-progress --no-suggest
|
||||||
|
|
||||||
- name: Analyze
|
- name: Analyze
|
||||||
run: composer analyze
|
run: vendor/bin/phpstan --no-progress --error-format=github
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- "*"
|
- "*"
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * *'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
php-tests:
|
php-tests:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
||||||
env:
|
env:
|
||||||
COMPOSER_NO_INTERACTION: 1
|
COMPOSER_NO_INTERACTION: 1
|
||||||
|
|
||||||
@@ -22,36 +22,40 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest]
|
os: [ubuntu-latest]
|
||||||
php: [8.5, 8.4, 8.3, 8.2]
|
php: [8.5, 8.4, 8.3, 8.2]
|
||||||
laravel: [~11.15, 12.x]
|
laravel: [12.x, 13.x, ~11.15]
|
||||||
stability: [prefer-lowest, prefer-stable]
|
stability: [prefer-lowest, prefer-stable]
|
||||||
include:
|
include:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
php: 8.3
|
php: 8.3
|
||||||
laravel: 12.x
|
laravel: 12.x
|
||||||
stability: prefer-stable
|
stability: prefer-stable
|
||||||
|
exclude:
|
||||||
|
- laravel: 13.x
|
||||||
|
php: 8.2
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set git to use LF
|
- name: Set git to use LF
|
||||||
if: ${{ matrix.os == 'windows-latest' }}
|
if: "${{ matrix.os == 'windows-latest' }}"
|
||||||
run: |
|
run: |
|
||||||
git config --global core.autocrlf false
|
git config --global core.autocrlf false
|
||||||
git config --global core.eol lf
|
git config --global core.eol lf
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php }}
|
php-version: ${{ matrix.php }}
|
||||||
coverage: none
|
coverage: none
|
||||||
extensions: pdo_sqlite, fileinfo
|
extensions: pdo_sqlite, fileinfo
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
composer remove vimeo/psalm --no-update --dev
|
composer remove vimeo/psalm --no-update --dev
|
||||||
composer remove friendsofphp/php-cs-fixer --no-update --dev
|
composer remove friendsofphp/php-cs-fixer --no-update --dev
|
||||||
composer require "laravel/framework:${{ matrix.laravel }}" --no-update --no-progress
|
composer require "laravel/framework:${{ matrix.laravel }}" --no-update --no-progress
|
||||||
composer update --prefer-dist --no-progress --${{ matrix.stability }}
|
composer update --prefer-dist --no-progress --${{ matrix.stability }}
|
||||||
|
|
||||||
- name: Execute Unit Tests
|
- name: Execute Unit Tests
|
||||||
run: composer test-ci
|
run: composer test-ci
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
/auth.json
|
||||||
|
/build
|
||||||
/.idea
|
/.idea
|
||||||
/.php-cs-fixer.cache
|
/.php-cs-fixer.cache
|
||||||
/.php-cs-fixer.php
|
/.php-cs-fixer.php
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require __DIR__ . '/vendor/autoload.php';
|
|||||||
|
|
||||||
$finder = PhpCsFixer\Finder::create()
|
$finder = PhpCsFixer\Finder::create()
|
||||||
->in(__DIR__)
|
->in(__DIR__)
|
||||||
->exclude('tests');
|
->exclude(['tests', 'build']);
|
||||||
|
|
||||||
$config = require __DIR__ . '/.php-cs-fixer.common.php';
|
$config = require __DIR__ . '/.php-cs-fixer.common.php';
|
||||||
|
|
||||||
|
|||||||
+13
-12
@@ -25,21 +25,22 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"barryvdh/reflection-docblock": "^2.4",
|
"barryvdh/reflection-docblock": "^2.4",
|
||||||
"composer/class-map-generator": "^1.0",
|
"composer/class-map-generator": "^1.0",
|
||||||
"illuminate/console": "^11.15 || ^12",
|
"illuminate/console": "^11.15 || ^12 || ^13.0",
|
||||||
"illuminate/database": "^11.15 || ^12",
|
"illuminate/database": "^11.15 || ^12 || ^13.0",
|
||||||
"illuminate/filesystem": "^11.15 || ^12",
|
"illuminate/filesystem": "^11.15 || ^12 || ^13.0",
|
||||||
"illuminate/support": "^11.15 || ^12"
|
"illuminate/support": "^11.15 || ^12 || ^13.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-pdo_sqlite": "*",
|
"ext-pdo_sqlite": "*",
|
||||||
"friendsofphp/php-cs-fixer": "^3",
|
"friendsofphp/php-cs-fixer": "^3",
|
||||||
"illuminate/config": "^11.15 || ^12",
|
"illuminate/config": "^11.15 || ^12 || ^13.0",
|
||||||
"illuminate/view": "^11.15 || ^12",
|
"illuminate/view": "^11.15 || ^12 || ^13.0",
|
||||||
|
"larastan/larastan": "^3.1",
|
||||||
"mockery/mockery": "^1.4",
|
"mockery/mockery": "^1.4",
|
||||||
"orchestra/testbench": "^9.2 || ^10",
|
"orchestra/testbench": "^9.2 || ^10 || ^11.0",
|
||||||
"phpunit/phpunit": "^10.5 || ^11.5.3",
|
"phpstan/phpstan-phpunit": "^2.0",
|
||||||
|
"phpunit/phpunit": "^10.5 || ^11.5.3 || ^12.5.12",
|
||||||
"spatie/phpunit-snapshot-assertions": "^4 || ^5",
|
"spatie/phpunit-snapshot-assertions": "^4 || ^5",
|
||||||
"vimeo/psalm": "^5.4",
|
|
||||||
"vlucas/phpdotenv": "^5"
|
"vlucas/phpdotenv": "^5"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
@@ -74,7 +75,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": "psalm",
|
"analyze": "phpstan",
|
||||||
|
"analyze-set-baseline": "phpstan --generate-baseline",
|
||||||
"check-style": [
|
"check-style": [
|
||||||
"php-cs-fixer fix --diff --diff-format=udiff --dry-run",
|
"php-cs-fixer fix --diff --diff-format=udiff --dry-run",
|
||||||
"php-cs-fixer fix --diff --diff-format=udiff --dry-run --config=.php_cs.tests.php"
|
"php-cs-fixer fix --diff --diff-format=udiff --dry-run --config=.php_cs.tests.php"
|
||||||
@@ -83,9 +85,8 @@
|
|||||||
"php-cs-fixer fix",
|
"php-cs-fixer fix",
|
||||||
"php-cs-fixer fix --config=.php-cs-fixer.tests.php"
|
"php-cs-fixer fix --config=.php-cs-fixer.tests.php"
|
||||||
],
|
],
|
||||||
"psalm-set-baseline": "psalm --set-baseline=psalm-baseline.xml",
|
|
||||||
"test": "phpunit",
|
"test": "phpunit",
|
||||||
"test-ci": "phpunit -d --without-creating-snapshots",
|
"test-ci": "phpunit",
|
||||||
"test-regenerate": "phpunit -d --update-snapshots"
|
"test-regenerate": "phpunit -d --update-snapshots"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-29
@@ -49,17 +49,14 @@ return [
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Factory builders
|
| Write model query methods
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Set to true to generate factory generators for better factory()
|
| Set to false to disable generated docs for the 'query()', 'newQuery()' and 'newModelQuery()' methods.
|
||||||
| method auto-completion.
|
|
||||||
|
|
|
||||||
| Deprecated for Laravel 8 or latest.
|
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'include_factory_builders' => false,
|
'write_query_methods' => true,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -204,29 +201,29 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Support for camel cased models
|
| Support for camel cased models
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| There are some Laravel packages (such as Eloquence) that allow for accessing
|
| There are some Laravel packages (such as Eloquence) that allow for accessing
|
||||||
| Eloquent model properties via camel case, instead of snake case.
|
| Eloquent model properties via camel case, instead of snake case.
|
||||||
|
|
|
|
||||||
| Enabling this option will support these packages by saving all model
|
| Enabling this option will support these packages by saving all model
|
||||||
| properties as camel case, instead of snake case.
|
| properties as camel case, instead of snake case.
|
||||||
|
|
|
|
||||||
| For example, normally you would see this:
|
| For example, normally you would see this:
|
||||||
|
|
|
|
||||||
| * @property \Illuminate\Support\Carbon $created_at
|
| * @property \Illuminate\Support\Carbon $created_at
|
||||||
| * @property \Illuminate\Support\Carbon $updated_at
|
| * @property \Illuminate\Support\Carbon $updated_at
|
||||||
|
|
|
|
||||||
| With this enabled, the properties will be this:
|
| With this enabled, the properties will be this:
|
||||||
|
|
|
|
||||||
| * @property \Illuminate\Support\Carbon $createdAt
|
| * @property \Illuminate\Support\Carbon $createdAt
|
||||||
| * @property \Illuminate\Support\Carbon $updatedAt
|
| * @property \Illuminate\Support\Carbon $updatedAt
|
||||||
|
|
|
|
||||||
| Note, it is currently an all-or-nothing option.
|
| Note, it is currently an all-or-nothing option.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
'model_camel_case_properties' => false,
|
'model_camel_case_properties' => false,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
parameters:
|
||||||
|
ignoreErrors:
|
||||||
|
-
|
||||||
|
message: '#^File ends with a trailing whitespace\. This may cause problems when running the code in the web browser\. Remove the closing \?\> mark or remove the whitespace\.$#'
|
||||||
|
identifier: whitespace.fileEnd
|
||||||
|
count: 1
|
||||||
|
path: resources/views/helper.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method Illuminate\\Contracts\\Filesystem\\Filesystem\:\:requireOnce\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Console/MetaCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method Illuminate\\Contracts\\Foundation\\Application\:\:getBindings\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Console/MetaCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method Barryvdh\\Reflection\\DocBlock\\Tag\:\:getMethodName\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Console/ModelsCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method Barryvdh\\Reflection\\DocBlock\\Tag\:\:getType\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Console/ModelsCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method Barryvdh\\Reflection\\DocBlock\\Tag\:\:getVariableName\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Console/ModelsCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method Illuminate\\Support\\Optional\:\:getNumberOfParameters\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Console/ModelsCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method Illuminate\\Support\\Optional\:\:getParameters\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Console/ModelsCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method Illuminate\\Support\\Optional\:\:getReturnType\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Console/ModelsCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined static method Illuminate\\Database\\Eloquent\\Model\:\:newFactory\(\)\.$#'
|
||||||
|
identifier: staticMethod.notFound
|
||||||
|
count: 2
|
||||||
|
path: src/Console/ModelsCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Call to an undefined method ReflectionFunctionAbstract\:\:getDeclaringClass\(\)\.$#'
|
||||||
|
identifier: method.notFound
|
||||||
|
count: 1
|
||||||
|
path: src/Method.php
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
includes:
|
||||||
|
- phpstan-baseline.neon
|
||||||
|
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
level: 2
|
||||||
|
paths:
|
||||||
|
- src
|
||||||
|
- resources/views
|
||||||
|
excludePaths:
|
||||||
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<files psalm-version="5.4.0@62db5d4f6a7ae0a20f7cc5a4952d730272fc0863">
|
|
||||||
<file src="src/Factories.php">
|
|
||||||
<UndefinedClass occurrences="2">
|
|
||||||
<code>Factory</code>
|
|
||||||
<code>Factory</code>
|
|
||||||
</UndefinedClass>
|
|
||||||
</file>
|
|
||||||
<file src="src/Generator.php">
|
|
||||||
<UndefinedClass occurrences="6">
|
|
||||||
<code>\Auth</code>
|
|
||||||
<code>\Cache</code>
|
|
||||||
<code>\Cache</code>
|
|
||||||
<code>\DB</code>
|
|
||||||
<code>\Queue</code>
|
|
||||||
<code>\Storage</code>
|
|
||||||
</UndefinedClass>
|
|
||||||
</file>
|
|
||||||
<file src="src/Console/ModelsCommand.php">
|
|
||||||
<UndefinedClass occurrences="1">
|
|
||||||
<code>\UnitEnum</code>
|
|
||||||
</UndefinedClass>
|
|
||||||
</file>
|
|
||||||
</files>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<psalm
|
|
||||||
errorLevel="7"
|
|
||||||
resolveFromConfigFile="true"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="https://getpsalm.org/schema/config"
|
|
||||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
|
||||||
errorBaseline="psalm-baseline.xml"
|
|
||||||
>
|
|
||||||
<projectFiles>
|
|
||||||
<directory name="src" />
|
|
||||||
<ignoreFiles>
|
|
||||||
<directory name="vendor" />
|
|
||||||
</ignoreFiles>
|
|
||||||
</projectFiles>
|
|
||||||
</psalm>
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* @var Barryvdh\LaravelIdeHelper\Alias[][] $namespaces_by_alias_ns
|
* @var Barryvdh\LaravelIdeHelper\Alias[][] $namespaces_by_alias_ns
|
||||||
* @var Barryvdh\LaravelIdeHelper\Alias[][] $namespaces_by_extends_ns
|
* @var Barryvdh\LaravelIdeHelper\Alias[][] $namespaces_by_extends_ns
|
||||||
|
* @var string[] $real_time_facades
|
||||||
* @var bool $include_fluent
|
* @var bool $include_fluent
|
||||||
* @var string $helpers
|
* @var string $helpers
|
||||||
*/
|
*/
|
||||||
@@ -119,12 +120,3 @@ namespace Illuminate\Support {
|
|||||||
}
|
}
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php foreach ($factories as $factory) : ?>
|
|
||||||
namespace <?=$factory->getNamespaceName()?> {
|
|
||||||
/**
|
|
||||||
* @method \Illuminate\Database\Eloquent\Collection|<?=$factory->getShortName()?>[]|<?=$factory->getShortName()?> create($attributes = [])
|
|
||||||
* @method \Illuminate\Database\Eloquent\Collection|<?=$factory->getShortName()?>[]|<?=$factory->getShortName()?> make($attributes = [])
|
|
||||||
*/
|
|
||||||
class <?=$factory->getShortName()?>FactoryBuilder extends \Illuminate\Database\Eloquent\FactoryBuilder {}
|
|
||||||
}
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|||||||
+14
-11
@@ -1,4 +1,16 @@
|
|||||||
<?= '<?php' ?>
|
<?= '<?php' ?>
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var array $bindings
|
||||||
|
* @var string[] $methods
|
||||||
|
* @var string[] $configMethods
|
||||||
|
* @var Illuminate\Support\Collection $configValues
|
||||||
|
* @var array<string, array> $expectedArgumentSets
|
||||||
|
* @var array $expectedArguments
|
||||||
|
* @var string[] $userMethods
|
||||||
|
* @var string $userModel/
|
||||||
|
* */
|
||||||
|
?>
|
||||||
|
|
||||||
/* @noinspection ALL */
|
/* @noinspection ALL */
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
@@ -35,15 +47,6 @@ namespace PHPSTORM_META {
|
|||||||
]));
|
]));
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
<?php if (count($factories)) : ?>
|
|
||||||
override(\factory(0), map([
|
|
||||||
'' => '@FactoryBuilder',
|
|
||||||
<?php foreach ($factories as $factory) : ?>
|
|
||||||
'<?= $factory->getName() ?>' => \<?= $factory->getName() ?>FactoryBuilder::class,
|
|
||||||
<?php endforeach; ?>
|
|
||||||
]));
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
override(\Illuminate\Foundation\Testing\Concerns\InteractsWithContainer::mock(0), map(["" => "@&\Mockery\MockInterface"]));
|
override(\Illuminate\Foundation\Testing\Concerns\InteractsWithContainer::mock(0), map(["" => "@&\Mockery\MockInterface"]));
|
||||||
override(\Illuminate\Foundation\Testing\Concerns\InteractsWithContainer::partialMock(0), map(["" => "@&\Mockery\MockInterface"]));
|
override(\Illuminate\Foundation\Testing\Concerns\InteractsWithContainer::partialMock(0), map(["" => "@&\Mockery\MockInterface"]));
|
||||||
override(\Illuminate\Foundation\Testing\Concerns\InteractsWithContainer::instance(0), type(1));
|
override(\Illuminate\Foundation\Testing\Concerns\InteractsWithContainer::instance(0), type(1));
|
||||||
@@ -79,7 +82,7 @@ namespace PHPSTORM_META {
|
|||||||
override(\tap(0), type(0));
|
override(\tap(0), type(0));
|
||||||
override(\optional(0), type(0));
|
override(\optional(0), type(0));
|
||||||
|
|
||||||
<?php if (isset($expectedArgumentSets)): ?>
|
<?php if ($expectedArgumentSets): ?>
|
||||||
<?php foreach ($expectedArgumentSets as $name => $argumentsList) : ?>
|
<?php foreach ($expectedArgumentSets as $name => $argumentsList) : ?>
|
||||||
registerArgumentsSet('<?= $name ?>', <?php foreach ($argumentsList as $i => $arg) : ?><?php if ($i % 5 == 0) {
|
registerArgumentsSet('<?= $name ?>', <?php foreach ($argumentsList as $i => $arg) : ?><?php if ($i % 5 == 0) {
|
||||||
echo "\n";
|
echo "\n";
|
||||||
@@ -87,7 +90,7 @@ namespace PHPSTORM_META {
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if (isset($expectedArguments)) : ?>
|
<?php if ($expectedArguments) : ?>
|
||||||
<?php foreach ($expectedArguments as $arguments) : ?>
|
<?php foreach ($expectedArguments as $arguments) : ?>
|
||||||
<?php
|
<?php
|
||||||
$classes = isset($arguments['class']) ? (array) $arguments['class'] : [null];
|
$classes = isset($arguments['class']) ? (array) $arguments['class'] : [null];
|
||||||
|
|||||||
+14
-18
@@ -101,7 +101,7 @@ class Alias
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($facade === '\Illuminate\Database\Eloquent\Model') {
|
if ($facade === '\Illuminate\Database\Eloquent\Model') {
|
||||||
$this->usedMethods = ['decrement', 'increment'];
|
$this->usedMethods = ['decrement' => true, 'increment' => true];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ class Alias
|
|||||||
public function shouldExtendParentClass()
|
public function shouldExtendParentClass()
|
||||||
{
|
{
|
||||||
return $this->parentClass
|
return $this->parentClass
|
||||||
&& $this->getExtendsNamespace() !== '\\Illuminate\\Support\\Facades';
|
&& !is_subclass_of($this->extends, Facade::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,9 +325,8 @@ class Alias
|
|||||||
/**
|
/**
|
||||||
* Get the real root of a facade
|
* Get the real root of a facade
|
||||||
*
|
*
|
||||||
* @return bool|string
|
|
||||||
*/
|
*/
|
||||||
protected function detectRoot()
|
protected function detectRoot(): void
|
||||||
{
|
{
|
||||||
$facade = $this->facade;
|
$facade = $this->facade;
|
||||||
|
|
||||||
@@ -382,11 +381,10 @@ class Alias
|
|||||||
$method = new \ReflectionMethod($className, $name);
|
$method = new \ReflectionMethod($className, $name);
|
||||||
$class = new ReflectionClass($className);
|
$class = new ReflectionClass($className);
|
||||||
|
|
||||||
if (!in_array($magic, $this->usedMethods)) {
|
if (!isset($this->usedMethods[$magic])) {
|
||||||
if ($class !== $this->root) {
|
if ($class !== $this->root) {
|
||||||
$this->methods[] = new Method(
|
$this->methods[] = new Method(
|
||||||
$method,
|
$method,
|
||||||
$this->alias,
|
|
||||||
$class,
|
$class,
|
||||||
$magic,
|
$magic,
|
||||||
$this->interfaces,
|
$this->interfaces,
|
||||||
@@ -395,7 +393,7 @@ class Alias
|
|||||||
$this->getTemplateNames()
|
$this->getTemplateNames()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->usedMethods[] = $magic;
|
$this->usedMethods[$magic] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,7 +401,6 @@ class Alias
|
|||||||
/**
|
/**
|
||||||
* Get the methods for one or multiple classes.
|
* Get the methods for one or multiple classes.
|
||||||
*
|
*
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
protected function detectMethods()
|
protected function detectMethods()
|
||||||
{
|
{
|
||||||
@@ -413,13 +410,12 @@ class Alias
|
|||||||
$methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
|
$methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
|
||||||
if ($methods) {
|
if ($methods) {
|
||||||
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
||||||
if (!in_array($method->name, $this->usedMethods)) {
|
if (!isset($this->usedMethods[$method->name])) {
|
||||||
// Only add the methods to the output when the root is not the same as the class.
|
// Only add the methods to the output when the root is not the same as the class.
|
||||||
// And don't add the __*() methods
|
// And don't add the __*() methods
|
||||||
if ($this->extends !== $class && substr($method->name, 0, 2) !== '__') {
|
if ($this->extends !== $class && substr($method->name, 0, 2) !== '__') {
|
||||||
$this->methods[] = new Method(
|
$this->methods[] = new Method(
|
||||||
$method,
|
$method,
|
||||||
$this->alias,
|
|
||||||
$reflection,
|
$reflection,
|
||||||
$method->name,
|
$method->name,
|
||||||
$this->interfaces,
|
$this->interfaces,
|
||||||
@@ -428,7 +424,7 @@ class Alias
|
|||||||
$this->getTemplateNames(),
|
$this->getTemplateNames(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->usedMethods[] = $method->name;
|
$this->usedMethods[$method->name] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,7 +435,7 @@ class Alias
|
|||||||
$properties = $reflection->getStaticProperties();
|
$properties = $reflection->getStaticProperties();
|
||||||
$macros = isset($properties['macros']) ? $properties['macros'] : [];
|
$macros = isset($properties['macros']) ? $properties['macros'] : [];
|
||||||
foreach ($macros as $macro_name => $macro_func) {
|
foreach ($macros as $macro_name => $macro_func) {
|
||||||
if (!in_array($macro_name, $this->usedMethods)) {
|
if (!isset($this->usedMethods[$macro_name])) {
|
||||||
try {
|
try {
|
||||||
$method = $this->getMacroFunction($macro_func);
|
$method = $this->getMacroFunction($macro_func);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
@@ -449,14 +445,13 @@ class Alias
|
|||||||
// Add macros
|
// Add macros
|
||||||
$this->methods[] = new Macro(
|
$this->methods[] = new Macro(
|
||||||
$method,
|
$method,
|
||||||
$this->alias,
|
|
||||||
$reflection,
|
$reflection,
|
||||||
$macro_name,
|
$macro_name,
|
||||||
$this->interfaces,
|
$this->interfaces,
|
||||||
$this->classAliases,
|
$this->classAliases,
|
||||||
$this->getReturnTypeNormalizers($reflection)
|
$this->getReturnTypeNormalizers($reflection)
|
||||||
);
|
);
|
||||||
$this->usedMethods[] = $macro_name;
|
$this->usedMethods[$macro_name] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -594,12 +589,13 @@ class Alias
|
|||||||
*/
|
*/
|
||||||
protected function removeDuplicateMethodsFromPhpDoc()
|
protected function removeDuplicateMethodsFromPhpDoc()
|
||||||
{
|
{
|
||||||
$methodNames = array_map(function (Method $method) {
|
$methodNames = [];
|
||||||
return $method->getName();
|
foreach ($this->getMethods() as $method) {
|
||||||
}, $this->getMethods());
|
$methodNames[$method->getName()] = true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->phpdoc->getTags() as $tag) {
|
foreach ($this->phpdoc->getTags() as $tag) {
|
||||||
if ($tag instanceof MethodTag && in_array($tag->getMethodName(), $methodNames)) {
|
if ($tag instanceof MethodTag && isset($methodNames[$tag->getMethodName()])) {
|
||||||
$this->phpdoc->deleteTag($tag);
|
$this->phpdoc->deleteTag($tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Console;
|
namespace Barryvdh\LaravelIdeHelper\Console;
|
||||||
|
|
||||||
use Barryvdh\LaravelIdeHelper\Factories;
|
|
||||||
use Dotenv\Parser\Entry;
|
use Dotenv\Parser\Entry;
|
||||||
use Dotenv\Parser\Parser;
|
use Dotenv\Parser\Parser;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
@@ -108,9 +107,6 @@ class MetaCommand extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
// Needs to run before exception handler is registered
|
|
||||||
$factories = $this->config->get('ide-helper.include_factory_builders') ? Factories::all() : [];
|
|
||||||
|
|
||||||
$ourAutoloader = $this->registerClassAutoloadExceptions();
|
$ourAutoloader = $this->registerClassAutoloadExceptions();
|
||||||
|
|
||||||
$bindings = [];
|
$bindings = [];
|
||||||
@@ -149,7 +145,6 @@ class MetaCommand extends Command
|
|||||||
$content = $this->view->make('ide-helper::meta', [
|
$content = $this->view->make('ide-helper::meta', [
|
||||||
'bindings' => $bindings,
|
'bindings' => $bindings,
|
||||||
'methods' => $this->methods,
|
'methods' => $this->methods,
|
||||||
'factories' => $factories,
|
|
||||||
'configMethods' => $this->configMethods,
|
'configMethods' => $this->configMethods,
|
||||||
'configValues' => $configValues,
|
'configValues' => $configValues,
|
||||||
'expectedArgumentSets' => $this->getExpectedArgumentSets(),
|
'expectedArgumentSets' => $this->getExpectedArgumentSets(),
|
||||||
@@ -200,6 +195,18 @@ class MetaCommand extends Command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't throw when class existence is being checked via class_exists(),
|
||||||
|
// interface_exists(), trait_exists(), or enum_exists(). These functions
|
||||||
|
// expect the autoloader to return gracefully when the class doesn't exist.
|
||||||
|
// Throwing here would break libraries that use class_exists() to check for
|
||||||
|
// optional dependencies (e.g. Doctrine ORM checking for removed classes).
|
||||||
|
$existsFunctions = ['class_exists', 'interface_exists', 'trait_exists', 'enum_exists'];
|
||||||
|
foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3) as $frame) {
|
||||||
|
if (isset($frame['function']) && in_array($frame['function'], $existsFunctions, true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw new \ReflectionException("Class '$class' not found.");
|
throw new \ReflectionException("Class '$class' not found.");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,14 @@ class ModelsCommand extends Command
|
|||||||
protected $reset;
|
protected $reset;
|
||||||
protected $phpstorm_noinspections;
|
protected $phpstorm_noinspections;
|
||||||
protected $write_model_external_builder_methods;
|
protected $write_model_external_builder_methods;
|
||||||
|
/**
|
||||||
|
* @var array<string, \SplFileObject>
|
||||||
|
*/
|
||||||
|
protected $fileCache = [];
|
||||||
|
/**
|
||||||
|
* @var array<string, Context>
|
||||||
|
*/
|
||||||
|
protected $contextCache = [];
|
||||||
/**
|
/**
|
||||||
* @var array<string, true>
|
* @var array<string, true>
|
||||||
*/
|
*/
|
||||||
@@ -526,7 +534,7 @@ class ModelsCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($isNullable) {
|
if ($isNullable) {
|
||||||
$type .= '|null';
|
$type = $this->wrapIntersectionType($type) . '|null';
|
||||||
} else {
|
} else {
|
||||||
$type = str_replace($nullString, '', $type);
|
$type = str_replace($nullString, '', $type);
|
||||||
}
|
}
|
||||||
@@ -534,6 +542,22 @@ class ModelsCommand extends Command
|
|||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a bare intersection type in parentheses for correct DNF syntax.
|
||||||
|
*
|
||||||
|
* For example, `A&B` becomes `(A&B)` so that adding `|null` produces
|
||||||
|
* `(A&B)|null` instead of the ambiguous `A&B|null`.
|
||||||
|
* Types that are already parenthesized or contain union types are returned as-is.
|
||||||
|
*/
|
||||||
|
protected function wrapIntersectionType(string $type): string
|
||||||
|
{
|
||||||
|
if (str_contains($type, '&') && !str_contains($type, '|') && $type[0] !== '(') {
|
||||||
|
return '(' . $type . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the override type for the give type.
|
* Returns the override type for the give type.
|
||||||
*
|
*
|
||||||
@@ -696,13 +720,16 @@ class ModelsCommand extends Command
|
|||||||
);
|
);
|
||||||
$this->setMethod($name, $builder . '<static>|' . $modelName, $args, $comment);
|
$this->setMethod($name, $builder . '<static>|' . $modelName, $args, $comment);
|
||||||
}
|
}
|
||||||
} elseif (in_array($method, ['query', 'newQuery', 'newModelQuery'])) {
|
} elseif (in_array($method, ['query', 'newQuery', 'newModelQuery'])
|
||||||
$builder = $this->getClassNameInDestinationFile($model, get_class($model->newModelQuery()));
|
) {
|
||||||
|
if ($this->laravel['config']->get('ide-helper.write_query_methods', true)) {
|
||||||
|
$builder = $this->getClassNameInDestinationFile($model, get_class($model->newModelQuery()));
|
||||||
|
|
||||||
$this->setMethod(
|
$this->setMethod(
|
||||||
$method,
|
$method,
|
||||||
$builder . '<static>|' . $this->getClassNameInDestinationFile($model, get_class($model))
|
$builder . '<static>|' . $this->getClassNameInDestinationFile($model, get_class($model))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->write_model_external_builder_methods) {
|
if ($this->write_model_external_builder_methods) {
|
||||||
$this->writeModelExternalBuilderMethods($model);
|
$this->writeModelExternalBuilderMethods($model);
|
||||||
@@ -721,14 +748,19 @@ class ModelsCommand extends Command
|
|||||||
$type = (string)$this->getReturnTypeFromDocBlock($reflection);
|
$type = (string)$this->getReturnTypeFromDocBlock($reflection);
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = new \SplFileObject($reflection->getFileName());
|
$fileName = $reflection->getFileName();
|
||||||
|
if (!isset($this->fileCache[$fileName])) {
|
||||||
|
$this->fileCache[$fileName] = new \SplFileObject($fileName);
|
||||||
|
}
|
||||||
|
$file = $this->fileCache[$fileName];
|
||||||
$file->seek($reflection->getStartLine() - 1);
|
$file->seek($reflection->getStartLine() - 1);
|
||||||
|
|
||||||
$code = '';
|
$lines = [];
|
||||||
while ($file->key() < $reflection->getEndLine()) {
|
while ($file->key() < $reflection->getEndLine()) {
|
||||||
$code .= $file->current();
|
$lines[] = $file->current();
|
||||||
$file->next();
|
$file->next();
|
||||||
}
|
}
|
||||||
|
$code = implode('', $lines);
|
||||||
$code = trim(preg_replace('/\s\s+/', '', $code));
|
$code = trim(preg_replace('/\s\s+/', '', $code));
|
||||||
$begin = strpos($code, 'function(');
|
$begin = strpos($code, 'function(');
|
||||||
$code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
|
$code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
|
||||||
@@ -982,7 +1014,7 @@ class ModelsCommand extends Command
|
|||||||
if ($type !== null) {
|
if ($type !== null) {
|
||||||
$newType = $this->getTypeOverride($type);
|
$newType = $this->getTypeOverride($type);
|
||||||
if ($nullable) {
|
if ($nullable) {
|
||||||
$newType .= '|null';
|
$newType = $this->wrapIntersectionType($newType) . '|null';
|
||||||
}
|
}
|
||||||
$this->properties[$name]['type'] = $newType;
|
$this->properties[$name]['type'] = $newType;
|
||||||
}
|
}
|
||||||
@@ -1133,6 +1165,7 @@ class ModelsCommand extends Command
|
|||||||
|
|
||||||
$serializer = new DocBlockSerializer();
|
$serializer = new DocBlockSerializer();
|
||||||
$docComment = $serializer->getDocComment($phpdoc);
|
$docComment = $serializer->getDocComment($phpdoc);
|
||||||
|
$mixinClassName = null;
|
||||||
|
|
||||||
if ($this->write_mixin) {
|
if ($this->write_mixin) {
|
||||||
$phpdocMixin = new DocBlock($reflection, new Context($namespace));
|
$phpdocMixin = new DocBlock($reflection, new Context($namespace));
|
||||||
@@ -1169,6 +1202,14 @@ class ModelsCommand extends Command
|
|||||||
$replace = "{$modelDocComment}\n";
|
$replace = "{$modelDocComment}\n";
|
||||||
$pos = strpos($contents, "final class {$classname}") ?: strpos($contents, "class {$classname}");
|
$pos = strpos($contents, "final class {$classname}") ?: strpos($contents, "class {$classname}");
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
|
// If PHP 8 attributes (e.g. #[ObservedBy(...)]) precede the class
|
||||||
|
// declaration, insert the docblock before the first attribute so that
|
||||||
|
// the resulting order is: docblock → attributes → class.
|
||||||
|
$before = substr($contents, 0, $pos);
|
||||||
|
if (preg_match('/((?:#\[.+?\]\s*)+)$/s', $before, $matches)) {
|
||||||
|
$pos -= strlen($matches[1]);
|
||||||
|
$replace = "{$modelDocComment}\n";
|
||||||
|
}
|
||||||
$contents = substr_replace($contents, $replace, $pos, 0);
|
$contents = substr_replace($contents, $replace, $pos, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1274,13 +1315,18 @@ class ModelsCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ?array $cachedRelationTypes = null;
|
||||||
|
protected ?array $cachedRelationReturnTypes = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the available relation types
|
* Returns the available relation types
|
||||||
*/
|
*/
|
||||||
protected function getRelationTypes(): array
|
protected function getRelationTypes(): array
|
||||||
{
|
{
|
||||||
$configuredRelations = $this->laravel['config']->get('ide-helper.additional_relation_types', []);
|
return $this->cachedRelationTypes ??= array_merge(
|
||||||
return array_merge(self::RELATION_TYPES, $configuredRelations);
|
self::RELATION_TYPES,
|
||||||
|
$this->laravel['config']->get('ide-helper.additional_relation_types', [])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1288,7 +1334,7 @@ class ModelsCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected function getRelationReturnTypes(): array
|
protected function getRelationReturnTypes(): array
|
||||||
{
|
{
|
||||||
return $this->laravel['config']->get('ide-helper.additional_relation_return_types', []);
|
return $this->cachedRelationReturnTypes ??= $this->laravel['config']->get('ide-helper.additional_relation_return_types', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1363,11 +1409,7 @@ class ModelsCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected function getCommentFromDocBlock(\ReflectionMethod $reflection)
|
protected function getCommentFromDocBlock(\ReflectionMethod $reflection)
|
||||||
{
|
{
|
||||||
$phpDocContext = (new ContextFactory())->createFromReflector($reflection);
|
$context = $this->getDocBlockContext($reflection);
|
||||||
$context = new Context(
|
|
||||||
$phpDocContext->getNamespace(),
|
|
||||||
$phpDocContext->getNamespaceAliases()
|
|
||||||
);
|
|
||||||
$comment = '';
|
$comment = '';
|
||||||
$phpdoc = new DocBlock($reflection, $context);
|
$phpdoc = new DocBlock($reflection, $context);
|
||||||
|
|
||||||
@@ -1388,11 +1430,7 @@ class ModelsCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected function getReturnTypeFromDocBlock(\ReflectionMethod $reflection, ?\Reflector $reflectorForContext = null)
|
protected function getReturnTypeFromDocBlock(\ReflectionMethod $reflection, ?\Reflector $reflectorForContext = null)
|
||||||
{
|
{
|
||||||
$phpDocContext = (new ContextFactory())->createFromReflector($reflectorForContext ?? $reflection);
|
$context = $this->getDocBlockContext($reflectorForContext ?? $reflection);
|
||||||
$context = new Context(
|
|
||||||
$phpDocContext->getNamespace(),
|
|
||||||
$phpDocContext->getNamespaceAliases()
|
|
||||||
);
|
|
||||||
$type = null;
|
$type = null;
|
||||||
$phpdoc = new DocBlock($reflection, $context);
|
$phpdoc = new DocBlock($reflection, $context);
|
||||||
|
|
||||||
@@ -1410,6 +1448,31 @@ class ModelsCommand extends Command
|
|||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getDocBlockContext(\Reflector $reflector): Context
|
||||||
|
{
|
||||||
|
if ($reflector instanceof \ReflectionMethod) {
|
||||||
|
$key = $reflector->getDeclaringClass()->getName();
|
||||||
|
} elseif ($reflector instanceof ReflectionClass) {
|
||||||
|
$key = $reflector->getName();
|
||||||
|
} else {
|
||||||
|
$phpDocContext = (new ContextFactory())->createFromReflector($reflector);
|
||||||
|
return new Context(
|
||||||
|
$phpDocContext->getNamespace(),
|
||||||
|
$phpDocContext->getNamespaceAliases()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($this->contextCache[$key])) {
|
||||||
|
$phpDocContext = (new ContextFactory())->createFromReflector($reflector);
|
||||||
|
$this->contextCache[$key] = new Context(
|
||||||
|
$phpDocContext->getNamespace(),
|
||||||
|
$phpDocContext->getNamespaceAliases()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->contextCache[$key];
|
||||||
|
}
|
||||||
|
|
||||||
protected function getReturnTypeFromReflection(\ReflectionMethod $reflection): ?string
|
protected function getReturnTypeFromReflection(\ReflectionMethod $reflection): ?string
|
||||||
{
|
{
|
||||||
$returnType = $reflection->getReturnType();
|
$returnType = $reflection->getReturnType();
|
||||||
@@ -1615,9 +1678,10 @@ class ModelsCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected function getUsedClassNames(ReflectionClass $reflection): array
|
protected function getUsedClassNames(ReflectionClass $reflection): array
|
||||||
{
|
{
|
||||||
|
$context = $this->getDocBlockContext($reflection);
|
||||||
$namespaceAliases = array_flip(array_map(function ($alias) {
|
$namespaceAliases = array_flip(array_map(function ($alias) {
|
||||||
return ltrim($alias, '\\');
|
return ltrim($alias, '\\');
|
||||||
}, (new ContextFactory())->createFromReflector($reflection)->getNamespaceAliases()));
|
}, $context->getNamespaceAliases()));
|
||||||
$namespaceAliases[$reflection->getName()] = $reflection->getShortName();
|
$namespaceAliases[$reflection->getName()] = $reflection->getShortName();
|
||||||
|
|
||||||
return $namespaceAliases;
|
return $namespaceAliases;
|
||||||
@@ -1680,7 +1744,7 @@ class ModelsCommand extends Command
|
|||||||
|
|
||||||
preg_match(
|
preg_match(
|
||||||
'/@param ((?:(?:[\w?|\\\\<>])+(?:\[])?)+)/',
|
'/@param ((?:(?:[\w?|\\\\<>])+(?:\[])?)+)/',
|
||||||
$docComment ?? '',
|
$docComment,
|
||||||
$matches
|
$matches
|
||||||
);
|
);
|
||||||
$type = $matches[1] ?? '';
|
$type = $matches[1] ?? '';
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Database\Eloquent\Factory;
|
|
||||||
use ReflectionClass;
|
|
||||||
|
|
||||||
class Factories
|
|
||||||
{
|
|
||||||
public static function all()
|
|
||||||
{
|
|
||||||
$factories = [];
|
|
||||||
|
|
||||||
if (static::isLaravelSevenOrLower()) {
|
|
||||||
$factory = app(Factory::class);
|
|
||||||
|
|
||||||
$definitions = (new ReflectionClass(Factory::class))->getProperty('definitions');
|
|
||||||
|
|
||||||
foreach ($definitions->getValue($factory) as $factory_target => $config) {
|
|
||||||
try {
|
|
||||||
$factories[] = new ReflectionClass($factory_target);
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $factories;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function isLaravelSevenOrLower()
|
|
||||||
{
|
|
||||||
return class_exists('Illuminate\Database\Eloquent\Factory');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-2
@@ -74,7 +74,7 @@ class Generator
|
|||||||
/**
|
/**
|
||||||
* Generate the helper file contents;
|
* Generate the helper file contents;
|
||||||
*
|
*
|
||||||
* @return string;
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function generate()
|
public function generate()
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,6 @@ class Generator
|
|||||||
->with('real_time_facades', $this->getRealTimeFacades())
|
->with('real_time_facades', $this->getRealTimeFacades())
|
||||||
->with('helpers', $this->detectHelpers())
|
->with('helpers', $this->detectHelpers())
|
||||||
->with('include_fluent', $this->config->get('ide-helper.include_fluent', true))
|
->with('include_fluent', $this->config->get('ide-helper.include_fluent', true))
|
||||||
->with('factories', $this->config->get('ide-helper.include_factory_builders') ? Factories::all() : [])
|
|
||||||
->render();
|
->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -15,7 +15,6 @@ class Macro extends Method
|
|||||||
* Macro constructor.
|
* Macro constructor.
|
||||||
*
|
*
|
||||||
* @param \ReflectionFunctionAbstract $method
|
* @param \ReflectionFunctionAbstract $method
|
||||||
* @param string $alias
|
|
||||||
* @param \ReflectionClass $class
|
* @param \ReflectionClass $class
|
||||||
* @param null $methodName
|
* @param null $methodName
|
||||||
* @param array $interfaces
|
* @param array $interfaces
|
||||||
@@ -24,14 +23,13 @@ class Macro extends Method
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$method,
|
$method,
|
||||||
$alias,
|
|
||||||
$class,
|
$class,
|
||||||
$methodName = null,
|
$methodName = null,
|
||||||
$interfaces = [],
|
$interfaces = [],
|
||||||
$classAliases = [],
|
$classAliases = [],
|
||||||
$returnTypeNormalizers = []
|
$returnTypeNormalizers = []
|
||||||
) {
|
) {
|
||||||
parent::__construct($method, $alias, $class, $methodName, $interfaces, $classAliases, $returnTypeNormalizers);
|
parent::__construct($method, $class, $methodName, $interfaces, $classAliases, $returnTypeNormalizers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setDefaultReturnTypes(array $map = [])
|
public static function setDefaultReturnTypes(array $map = [])
|
||||||
@@ -75,8 +73,8 @@ class Macro extends Method
|
|||||||
|
|
||||||
$type = $this->concatReflectionTypes($return);
|
$type = $this->concatReflectionTypes($return);
|
||||||
|
|
||||||
/** @psalm-suppress UndefinedClass */
|
|
||||||
if (!$return instanceof \ReflectionUnionType) {
|
if (!$return instanceof \ReflectionUnionType) {
|
||||||
|
/** @phpstan-ignore method.notFound */
|
||||||
$type .= $this->root === "\\{$builder}" && $return->getName() === $builder ? '|static' : '';
|
$type .= $this->root === "\\{$builder}" && $return->getName() === $builder ? '|static' : '';
|
||||||
$type .= $return->allowsNull() ? '|null' : '';
|
$type .= $return->allowsNull() ? '|null' : '';
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -44,7 +44,6 @@ class Method
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \ReflectionMethod|\ReflectionFunctionAbstract $method
|
* @param \ReflectionMethod|\ReflectionFunctionAbstract $method
|
||||||
* @param string $alias
|
|
||||||
* @param \ReflectionClass $class
|
* @param \ReflectionClass $class
|
||||||
* @param string|null $methodName
|
* @param string|null $methodName
|
||||||
* @param array $interfaces
|
* @param array $interfaces
|
||||||
@@ -52,7 +51,7 @@ class Method
|
|||||||
* @param array $returnTypeNormalizers
|
* @param array $returnTypeNormalizers
|
||||||
* @param string[] $templateNames
|
* @param string[] $templateNames
|
||||||
*/
|
*/
|
||||||
public function __construct($method, $alias, $class, $methodName = null, $interfaces = [], array $classAliases = [], array $returnTypeNormalizers = [], array $templateNames = [])
|
public function __construct($method, $class, $methodName = null, $interfaces = [], array $classAliases = [], array $returnTypeNormalizers = [], array $templateNames = [])
|
||||||
{
|
{
|
||||||
$this->method = $method;
|
$this->method = $method;
|
||||||
$this->interfaces = $interfaces;
|
$this->interfaces = $interfaces;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\MorphToIntersection\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
abstract class BaseModel extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\MorphToIntersection\Models;
|
||||||
|
|
||||||
|
interface CanBeAssigned
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\MorphToIntersection\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
|
||||||
|
class MorphToIntersection extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'morphs';
|
||||||
|
|
||||||
|
/** @return MorphTo<(BaseModel&CanBeAssigned), $this> */
|
||||||
|
public function assigneeWithParens(): MorphTo
|
||||||
|
{
|
||||||
|
return $this->morphTo(type: 'nullable_relation_morph_to_type', id: 'nullable_relation_morph_to_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return MorphTo<BaseModel&CanBeAssigned, $this> */
|
||||||
|
public function assigneeWithoutParens(): MorphTo
|
||||||
|
{
|
||||||
|
return $this->morphTo(type: 'nullable_relation_morph_to_type', id: 'nullable_relation_morph_to_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return MorphTo<(BaseModel&CanBeAssigned), $this> */
|
||||||
|
public function nonNullableAssignee(): MorphTo
|
||||||
|
{
|
||||||
|
return $this->morphTo(type: 'relation_morph_to_type', id: 'relation_morph_to_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\MorphToIntersection;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
public function test(): void
|
||||||
|
{
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
||||||
|
$this->assertMatchesMockedSnapshot();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\MorphToIntersection\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property string $relation_morph_to_type
|
||||||
|
* @property int $relation_morph_to_id
|
||||||
|
* @property string|null $nullable_relation_morph_to_type
|
||||||
|
* @property int|null $nullable_relation_morph_to_id
|
||||||
|
* @property-read (BaseModel&CanBeAssigned)|null $assigneeWithParens
|
||||||
|
* @property-read (BaseModel&CanBeAssigned)|null $assigneeWithoutParens
|
||||||
|
* @property-read (BaseModel&CanBeAssigned) $nonNullableAssignee
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MorphToIntersection newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MorphToIntersection newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MorphToIntersection query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MorphToIntersection whereNullableRelationMorphToId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MorphToIntersection whereNullableRelationMorphToType($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MorphToIntersection whereRelationMorphToId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MorphToIntersection whereRelationMorphToType($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class MorphToIntersection extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'morphs';
|
||||||
|
|
||||||
|
/** @return MorphTo<(BaseModel&CanBeAssigned), $this> */
|
||||||
|
public function assigneeWithParens(): MorphTo
|
||||||
|
{
|
||||||
|
return $this->morphTo(type: 'nullable_relation_morph_to_type', id: 'nullable_relation_morph_to_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return MorphTo<BaseModel&CanBeAssigned, $this> */
|
||||||
|
public function assigneeWithoutParens(): MorphTo
|
||||||
|
{
|
||||||
|
return $this->morphTo(type: 'nullable_relation_morph_to_type', id: 'nullable_relation_morph_to_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return MorphTo<(BaseModel&CanBeAssigned), $this> */
|
||||||
|
public function nonNullableAssignee(): MorphTo
|
||||||
|
{
|
||||||
|
return $this->morphTo(type: 'relation_morph_to_type', id: 'relation_morph_to_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
// Tests: final class + attribute with nested array argument (e.g. ObservedBy([...]))
|
||||||
|
#[ObservedByStub([StubObserver::class])]
|
||||||
|
final class FinalWithNested extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'simples';
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
// Tests: multiple consecutive PHP 8 attributes before the class declaration
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
|
#[SecondAttribute]
|
||||||
|
class MultipleAttributes extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'simples';
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
public function test(): void
|
||||||
|
{
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
||||||
|
$this->assertMatchesMockedSnapshot();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
// Tests: final class + attribute with nested array argument (e.g. ObservedBy([...]))
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|FinalWithNested newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|FinalWithNested newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|FinalWithNested query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|FinalWithNested whereId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
#[ObservedByStub([StubObserver::class])]
|
||||||
|
final class FinalWithNested extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'simples';
|
||||||
|
}
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
// Tests: multiple consecutive PHP 8 attributes before the class declaration
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MultipleAttributes newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MultipleAttributes newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MultipleAttributes query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|MultipleAttributes whereId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
|
#[SecondAttribute]
|
||||||
|
class MultipleAttributes extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'simples';
|
||||||
|
}
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple whereId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\QueryMethods\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Post extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\QueryMethods;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
parent::getEnvironmentSetUp($app);
|
||||||
|
|
||||||
|
$app['config']->set('ide-helper.write_query_methods', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test(): void
|
||||||
|
{
|
||||||
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|
||||||
|
$tester = $this->runCommand($command, [
|
||||||
|
'--write' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
|
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
||||||
|
$this->assertMatchesMockedSnapshot();
|
||||||
|
$this->assertStringNotContainsString("@method static \Illuminate\Database\Eloquent\Builder<static>|Post query()", $this->mockFilesystemOutput);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\QueryMethods\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string|null $char_nullable
|
||||||
|
* @property string $char_not_nullable
|
||||||
|
* @property string|null $string_nullable
|
||||||
|
* @property string $string_not_nullable
|
||||||
|
* @property string|null $text_nullable
|
||||||
|
* @property string $text_not_nullable
|
||||||
|
* @property string|null $medium_text_nullable
|
||||||
|
* @property string $medium_text_not_nullable
|
||||||
|
* @property string|null $long_text_nullable
|
||||||
|
* @property string $long_text_not_nullable
|
||||||
|
* @property int|null $integer_nullable
|
||||||
|
* @property int $integer_not_nullable
|
||||||
|
* @property int|null $tiny_integer_nullable
|
||||||
|
* @property int $tiny_integer_not_nullable
|
||||||
|
* @property int|null $small_integer_nullable
|
||||||
|
* @property int $small_integer_not_nullable
|
||||||
|
* @property int|null $medium_integer_nullable
|
||||||
|
* @property int $medium_integer_not_nullable
|
||||||
|
* @property int|null $big_integer_nullable
|
||||||
|
* @property int $big_integer_not_nullable
|
||||||
|
* @property int|null $unsigned_integer_nullable
|
||||||
|
* @property int $unsigned_integer_not_nullable
|
||||||
|
* @property int|null $unsigned_tiny_integer_nullable
|
||||||
|
* @property int $unsigned_tiny_integer_not_nullable
|
||||||
|
* @property int|null $unsigned_small_integer_nullable
|
||||||
|
* @property int $unsigned_small_integer_not_nullable
|
||||||
|
* @property int|null $unsigned_medium_integer_nullable
|
||||||
|
* @property int $unsigned_medium_integer_not_nullable
|
||||||
|
* @property int|null $unsigned_big_integer_nullable
|
||||||
|
* @property int $unsigned_big_integer_not_nullable
|
||||||
|
* @property float|null $float_nullable
|
||||||
|
* @property float $float_not_nullable
|
||||||
|
* @property float|null $double_nullable
|
||||||
|
* @property float $double_not_nullable
|
||||||
|
* @property numeric|null $decimal_nullable
|
||||||
|
* @property numeric $decimal_not_nullable
|
||||||
|
* @property int|null $boolean_nullable
|
||||||
|
* @property int $boolean_not_nullable
|
||||||
|
* @property string|null $enum_nullable
|
||||||
|
* @property string $enum_not_nullable
|
||||||
|
* @property string|null $json_nullable
|
||||||
|
* @property string $json_not_nullable
|
||||||
|
* @property string|null $jsonb_nullable
|
||||||
|
* @property string $jsonb_not_nullable
|
||||||
|
* @property string|null $date_nullable
|
||||||
|
* @property string $date_not_nullable
|
||||||
|
* @property string|null $datetime_nullable
|
||||||
|
* @property string $datetime_not_nullable
|
||||||
|
* @property string|null $datetimetz_nullable
|
||||||
|
* @property string $datetimetz_not_nullable
|
||||||
|
* @property string|null $time_nullable
|
||||||
|
* @property string $time_not_nullable
|
||||||
|
* @property string|null $timetz_nullable
|
||||||
|
* @property string $timetz_not_nullable
|
||||||
|
* @property string|null $timestamp_nullable
|
||||||
|
* @property string $timestamp_not_nullable
|
||||||
|
* @property string|null $timestamptz_nullable
|
||||||
|
* @property string $timestamptz_not_nullable
|
||||||
|
* @property int|null $year_nullable
|
||||||
|
* @property int $year_not_nullable
|
||||||
|
* @property string|null $binary_nullable
|
||||||
|
* @property string $binary_not_nullable
|
||||||
|
* @property string|null $uuid_nullable
|
||||||
|
* @property string $uuid_not_nullable
|
||||||
|
* @property string|null $ipaddress_nullable
|
||||||
|
* @property string $ipaddress_not_nullable
|
||||||
|
* @property string|null $macaddress_nullable
|
||||||
|
* @property string $macaddress_not_nullable
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereBigIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereBigIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereBinaryNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereBinaryNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereBooleanNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereBooleanNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereCharNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereCharNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDateNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDateNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDatetimeNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDatetimeNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDatetimetzNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDatetimetzNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDecimalNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDecimalNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDoubleNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereDoubleNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereEnumNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereEnumNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereFloatNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereFloatNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereIpaddressNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereIpaddressNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereJsonNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereJsonNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereJsonbNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereJsonbNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereLongTextNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereLongTextNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereMacaddressNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereMacaddressNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereMediumIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereMediumIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereMediumTextNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereMediumTextNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereSmallIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereSmallIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereStringNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereStringNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTextNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTextNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTimeNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTimeNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTimestampNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTimestampNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTimestamptzNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTimestamptzNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTimetzNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTimetzNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTinyIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereTinyIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedBigIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedBigIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedMediumIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedMediumIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedSmallIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedSmallIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedTinyIntegerNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUnsignedTinyIntegerNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUuidNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereUuidNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereYearNotNullable($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Post whereYearNullable($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class Post extends Model
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Factories;
|
|
||||||
|
|
||||||
use Barryvdh\LaravelIdeHelper\Factories;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
class AllTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testAll(): void
|
|
||||||
{
|
|
||||||
$factories = Factories::all();
|
|
||||||
|
|
||||||
self::assertEmpty($factories);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-3
@@ -284,7 +284,7 @@ class MacroTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reflectionMethod = new \ReflectionMethod(UrlGeneratorMacroClass::class, '__invoke');
|
$reflectionMethod = new \ReflectionMethod(UrlGeneratorMacroClass::class, '__invoke');
|
||||||
|
|
||||||
$macro = new Macro($reflectionMethod, UrlGenerator::class, new ReflectionClass(UrlGenerator::class), 'macroName');
|
$macro = new Macro($reflectionMethod, new ReflectionClass(UrlGenerator::class), 'macroName');
|
||||||
|
|
||||||
$this->assertInstanceOf(Macro::class, $macro);
|
$this->assertInstanceOf(Macro::class, $macro);
|
||||||
}
|
}
|
||||||
@@ -296,7 +296,7 @@ class MacroTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reflectionMethod = new \ReflectionMethod(UrlGeneratorMacroClass::class, '__invoke');
|
$reflectionMethod = new \ReflectionMethod(UrlGeneratorMacroClass::class, '__invoke');
|
||||||
|
|
||||||
$macro = new Macro($reflectionMethod, 'URL', new ReflectionClass(UrlGenerator::class), 'macroName');
|
$macro = new Macro($reflectionMethod, new ReflectionClass(UrlGenerator::class), 'macroName');
|
||||||
$output = <<<'DOC'
|
$output = <<<'DOC'
|
||||||
/**
|
/**
|
||||||
* @param string $foo
|
* @param string $foo
|
||||||
@@ -331,7 +331,7 @@ class MacroMock extends Macro
|
|||||||
|
|
||||||
public function getPhpDoc(ReflectionFunctionAbstract $method, ?ReflectionClass $class = null): DocBlock
|
public function getPhpDoc(ReflectionFunctionAbstract $method, ?ReflectionClass $class = null): DocBlock
|
||||||
{
|
{
|
||||||
return (new Macro($method, '', $class ?? $method->getClosureScopeClass()))->phpdoc;
|
return (new Macro($method, $class ?? $method->getClosureScopeClass()))->phpdoc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class MethodTest extends TestCase
|
|||||||
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
||||||
$reflectionMethod = $reflectionClass->getMethod('setName');
|
$reflectionMethod = $reflectionClass->getMethod('setName');
|
||||||
|
|
||||||
$method = new Method($reflectionMethod, 'Example', $reflectionClass);
|
$method = new Method($reflectionMethod, $reflectionClass);
|
||||||
|
|
||||||
$this->assertInstanceOf(Method::class, $method);
|
$this->assertInstanceOf(Method::class, $method);
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ class MethodTest extends TestCase
|
|||||||
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
||||||
$reflectionMethod = $reflectionClass->getMethod('setName');
|
$reflectionMethod = $reflectionClass->getMethod('setName');
|
||||||
|
|
||||||
$method = new Method($reflectionMethod, 'Example', $reflectionClass);
|
$method = new Method($reflectionMethod, $reflectionClass);
|
||||||
|
|
||||||
$output = <<<'DOC'
|
$output = <<<'DOC'
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +60,7 @@ DOC;
|
|||||||
$reflectionClass = new \ReflectionClass(EloquentBuilder::class);
|
$reflectionClass = new \ReflectionClass(EloquentBuilder::class);
|
||||||
$reflectionMethod = $reflectionClass->getMethod('upsert');
|
$reflectionMethod = $reflectionClass->getMethod('upsert');
|
||||||
|
|
||||||
$method = new Method($reflectionMethod, 'Builder', $reflectionClass);
|
$method = new Method($reflectionMethod, $reflectionClass);
|
||||||
|
|
||||||
$output = <<<'DOC'
|
$output = <<<'DOC'
|
||||||
/**
|
/**
|
||||||
@@ -92,7 +92,7 @@ DOC;
|
|||||||
$reflectionClass = new \ReflectionClass(EloquentBuilder::class);
|
$reflectionClass = new \ReflectionClass(EloquentBuilder::class);
|
||||||
$reflectionMethod = $reflectionClass->getMethod('where');
|
$reflectionMethod = $reflectionClass->getMethod('where');
|
||||||
|
|
||||||
$method = new Method($reflectionMethod, 'Builder', $reflectionClass, null, [], [], ['$this' => '\\' . EloquentBuilder::class . '<static>']);
|
$method = new Method($reflectionMethod, $reflectionClass, null, [], [], ['$this' => '\\' . EloquentBuilder::class . '<static>']);
|
||||||
|
|
||||||
$output = <<<'DOC'
|
$output = <<<'DOC'
|
||||||
/**
|
/**
|
||||||
@@ -123,7 +123,7 @@ DOC;
|
|||||||
$reflectionClass = new \ReflectionClass(QueryBuilder::class);
|
$reflectionClass = new \ReflectionClass(QueryBuilder::class);
|
||||||
$reflectionMethod = $reflectionClass->getMethod('whereNull');
|
$reflectionMethod = $reflectionClass->getMethod('whereNull');
|
||||||
|
|
||||||
$method = new Method($reflectionMethod, 'Builder', $reflectionClass, null, [], [], ['$this' => '\\' . EloquentBuilder::class . '<static>']);
|
$method = new Method($reflectionMethod, $reflectionClass, null, [], [], ['$this' => '\\' . EloquentBuilder::class . '<static>']);
|
||||||
|
|
||||||
$output = <<<'DOC'
|
$output = <<<'DOC'
|
||||||
/**
|
/**
|
||||||
@@ -154,7 +154,7 @@ DOC;
|
|||||||
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
||||||
$reflectionMethod = $reflectionClass->getMethod('setSpecialChars');
|
$reflectionMethod = $reflectionClass->getMethod('setSpecialChars');
|
||||||
|
|
||||||
$method = new Method($reflectionMethod, 'Example', $reflectionClass);
|
$method = new Method($reflectionMethod, $reflectionClass);
|
||||||
$this->assertSame('$chars', $method->getParams(true));
|
$this->assertSame('$chars', $method->getParams(true));
|
||||||
$this->assertSame(['$chars'], $method->getParams(false));
|
$this->assertSame(['$chars'], $method->getParams(false));
|
||||||
$this->assertSame('$chars = \'$\\\'\\\\\'', $method->getParamsWithDefault(true));
|
$this->assertSame('$chars = \'$\\\'\\\\\'', $method->getParamsWithDefault(true));
|
||||||
@@ -169,7 +169,7 @@ DOC;
|
|||||||
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
||||||
$reflectionMethod = $reflectionClass->getMethod('getApplication');
|
$reflectionMethod = $reflectionClass->getMethod('getApplication');
|
||||||
|
|
||||||
$method = new Method($reflectionMethod, 'Example', $reflectionClass, null, [], [
|
$method = new Method($reflectionMethod, $reflectionClass, null, [], [
|
||||||
'Application' => '\\Illuminate\\Foundation\\Application',
|
'Application' => '\\Illuminate\\Foundation\\Application',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ DOC;
|
|||||||
$reflectionClass = new \ReflectionClass(EloquentBuilder::class);
|
$reflectionClass = new \ReflectionClass(EloquentBuilder::class);
|
||||||
$reflectionMethod = $reflectionClass->getMethod('firstOr');
|
$reflectionMethod = $reflectionClass->getMethod('firstOr');
|
||||||
|
|
||||||
$method = new Method($reflectionMethod, 'Builder', $reflectionClass, null, [], [], [], ['TModel']);
|
$method = new Method($reflectionMethod, $reflectionClass, null, [], [], [], ['TModel']);
|
||||||
|
|
||||||
$output = <<<'DOC'
|
$output = <<<'DOC'
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user