Skip to content

Commit 28d2978

Browse files
authored
Merge pull request #152 from cakephp/ide-helper
add ide helper + PHPStan
2 parents 4cbaeea + b4778ba commit 28d2978

File tree

23 files changed

+299
-36
lines changed

23 files changed

+299
-36
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,6 @@ jobs:
8282

8383
- name: Run PHP CodeSniffer
8484
run: vendor/bin/phpcs --report=checkstyle | cs2pr
85+
86+
- name: Run PHPStan
87+
run: vendor/bin/phpstan analyse -c phpstan.neon --error-format=checkstyle | cs2pr

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
"mobiledetect/mobiledetectlib": "^4.8.03"
1818
},
1919
"require-dev": {
20+
"cakedc/cakephp-phpstan": "^4.0",
2021
"cakephp/bake": "^3.0.0",
2122
"cakephp/cakephp-codesniffer": "^5.0",
2223
"cakephp/debug_kit": "^5.0.0",
24+
"dereuromark/cakephp-ide-helper": "dev-master",
2325
"josegonzalez/dotenv": "^4.0",
2426
"phpunit/phpunit": "^10.5.5 || ^11.1.3 || ^12.1"
2527
},
@@ -58,6 +60,10 @@
5860
],
5961
"cs-check": "phpcs --colors -p",
6062
"cs-fix": "phpcbf --colors -p",
61-
"test": "phpunit --colors=always"
63+
"test": "phpunit --colors=always",
64+
"annotate": "bin/cake annotate all",
65+
"illuminate": "bin/cake illuminate code",
66+
"phpstan": "phpstan analyse",
67+
"phpstan-baseline": "phpstan --generate-baseline"
6268
}
6369
}

composer.lock

Lines changed: 199 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/.env.ddev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ export DATABASE_URL="mysql://db:db@db:3306/db"
3636
# Uncomment these to define logging configuration via environment variables.
3737
#export LOG_DEBUG_URL="file:///path/to/logs/?levels[]=notice&levels[]=info&levels[]=debug&file=debug"
3838
#export LOG_ERROR_URL="file:///path/to/logs/?levels[]=warning&levels[]=error&levels[]=critical&levels[]=alert&levels[]=emergency&file=error"
39-
export DEBUG_KIT_SAFE_TLD="site"
4039
export APP_FULL_BASE_URL="https://plugins.cakephp.org.ddev.site"
40+
export DEBUG_KIT_SAFE_TLD="site"

config/app.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,11 @@
479479
'Migrations' => [
480480
'add_timestamps_use_datetime' => true,
481481
],
482+
483+
'IdeHelper' => [
484+
'tableBehaviors' => true,
485+
'arrayAsGenerics' => true,
486+
'objectAsGenerics' => true,
487+
'assocsAsGenerics' => true,
488+
],
482489
];

config/plugins.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@
3737
'Tags',
3838
'ADmad/SocialAuth',
3939
'Authentication',
40+
'IdeHelper',
4041
];

phpstan.neon

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
includes:
2+
- vendor/cakedc/cakephp-phpstan/extension.neon
3+
14
parameters:
2-
level: 8
5+
level: 5
36
treatPhpDocTypesAsCertain: false
4-
checkGenericClassInNonGenericObjectType: false
57
bootstrapFiles:
68
- config/bootstrap.php
79
paths:

src/Command/SyncPackagesCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public function execute(Arguments $args, ConsoleIo $io)
127127
}
128128

129129
// Remove packages that were not touched
130+
/** @var \Cake\ORM\ResultSet<array-key, \App\Model\Entity\Package> $toDeletePackages */
130131
$toDeletePackages = $packagesTable->find()->where(['id NOT IN' => $touchedIds])->all();
131132
foreach ($toDeletePackages as $package) {
132133
if (!$packagesTable->delete($package)) {
@@ -241,7 +242,7 @@ private function hasExplicitCakePhpDependency(array $tags): bool
241242
* @param array $meta The meta array to adjust
242243
* @param string $packageConstraint The meta array which contains the current version strings
243244
* @param string $tagPrefix The prefix which should be used for the tag
244-
* @param array<string, array<int>> $versions The versions to check
245+
* @param array<array-key, array<int>> $versions The versions to check
245246
* @return array
246247
*/
247248
private function appendVersionTags(

src/Controller/AppController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* will inherit them.
2626
*
2727
* @link https://book.cakephp.org/5/en/controllers.html#the-app-controller
28+
* @property \Search\Controller\Component\SearchComponent $Search
29+
* @property \Authentication\Controller\Component\AuthenticationComponent $Authentication
2830
*/
2931
class AppController extends Controller
3032
{

src/Controller/ErrorController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class ErrorController extends AppController
2727
{
28+
protected ?string $defaultTable = '';
29+
2830
/**
2931
* Initialization hook method.
3032
*

0 commit comments

Comments
 (0)