Skip to content

Commit 66d138e

Browse files
authored
Merge pull request #15 from LordSimal/3.next-cake5
3.next: Multiple cleanups
2 parents 89a0b1f + 4856b75 commit 66d138e

27 files changed

+284
-323
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ jobs:
7070

7171
- name: Run phpstan
7272
if: always()
73-
run: vendor/bin/phpstan analyse --error-format=github
73+
run: vendor/bin/phpstan analyse --error-format=github src/

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
"role": "Author"
1111
}
1212
],
13-
"minimum-stability": "dev",
1413
"require": {
1514
"php": ">=8.1.0",
1615
"phpstan/phpstan": "^1.0",
17-
"cakephp/cakephp": "5.x-dev"
16+
"cakephp/cakephp": "^5.0.0"
1817
},
1918
"require-dev": {
2019
"phpstan/phpstan-phpunit": "^1.0",
@@ -41,8 +40,8 @@
4140
}
4241
},
4342
"scripts": {
44-
"cs-check": "phpcs -p --standard=PSR12 src/ tests",
45-
"cs-fix": "phpcbf -p --standard=PSR12 src/ tests",
43+
"cs-check": "phpcs -p src/ tests",
44+
"cs-fix": "phpcbf -p src/ tests",
4645
"test": "phpunit --stderr",
4746
"stan-integration": [
4847
"phpstan analyse tests/test_app/",

extension.neon

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ services:
6666
tags:
6767
- phpstan.broker.dynamicMethodReturnTypeExtension
6868
-
69-
class: CakeDC\PHPStan\Type\ShellHelperLoadDynamicReturnTypeExtension
70-
tags:
71-
- phpstan.broker.dynamicMethodReturnTypeExtension
72-
-
73-
factory: CakeDC\PHPStan\Type\ShellHelperLoadDynamicReturnTypeExtension(Cake\Console\ConsoleIo)
69+
class: CakeDC\PHPStan\Type\ConsoleHelperLoadDynamicReturnTypeExtension
7470
tags:
7571
- phpstan.broker.dynamicMethodReturnTypeExtension

phpcs.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="CakePHP Core">
3+
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />
4+
5+
<rule ref="CakePHP" />
6+
7+
<arg value="s"/>
8+
</ruleset>

src/Method/AssociationTableMixinClassReflectionExtension.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
/**
45
* @source https://github.com/cakephp/cakephp
@@ -24,10 +25,10 @@ class AssociationTableMixinClassReflectionExtension implements
2425
/**
2526
* @var \PHPStan\Broker\Broker
2627
*/
27-
private $broker;
28+
private Broker $broker;
2829

2930
/**
30-
* @param Broker $broker Class reflection broker
31+
* @param \PHPStan\Broker\Broker $broker Class reflection broker
3132
* @return void
3233
*/
3334
public function setBroker(Broker $broker): void
@@ -36,16 +37,16 @@ public function setBroker(Broker $broker): void
3637
}
3738

3839
/**
39-
* @return ClassReflection
40+
* @return \PHPStan\Reflection\ClassReflection
4041
*/
4142
protected function getTableReflection(): ClassReflection
4243
{
4344
return $this->broker->getClass(Table::class);
4445
}
4546

4647
/**
47-
* @param ClassReflection $classReflection Class reflection
48-
* @param string $methodName Method name
48+
* @param \PHPStan\Reflection\ClassReflection $classReflection Class reflection
49+
* @param string $methodName Method name
4950
* @return bool
5051
*/
5152
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
@@ -63,9 +64,9 @@ public function hasMethod(ClassReflection $classReflection, string $methodName):
6364
}
6465

6566
/**
66-
* @param ClassReflection $classReflection Class reflection
67-
* @param string $methodName Method name
68-
* @return MethodReflection
67+
* @param \PHPStan\Reflection\ClassReflection $classReflection Class reflection
68+
* @param string $methodName Method name
69+
* @return \PHPStan\Reflection\MethodReflection
6970
*/
7071
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
7172
{
@@ -78,8 +79,8 @@ public function getMethod(ClassReflection $classReflection, string $methodName):
7879
}
7980

8081
/**
81-
* @param ClassReflection $classReflection Class reflection
82-
* @param string $propertyName Method name
82+
* @param \PHPStan\Reflection\ClassReflection $classReflection Class reflection
83+
* @param string $propertyName Method name
8384
* @return bool
8485
*/
8586
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
@@ -92,9 +93,9 @@ public function hasProperty(ClassReflection $classReflection, string $propertyNa
9293
}
9394

9495
/**
95-
* @param ClassReflection $classReflection Class reflection
96-
* @param string $propertyName Method name
97-
* @return PropertyReflection
96+
* @param \PHPStan\Reflection\ClassReflection $classReflection Class reflection
97+
* @param string $propertyName Method name
98+
* @return \PHPStan\Reflection\PropertyReflection
9899
*/
99100
public function getProperty(ClassReflection $classReflection, string $propertyName): PropertyReflection
100101
{

src/Method/TableFindByPropertyMethodReflection.php

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
/**
45
* @source https://github.com/cakephp/cakephp
@@ -9,71 +10,108 @@
910
use PHPStan\Reflection\ClassMemberReflection;
1011
use PHPStan\Reflection\ClassReflection;
1112
use PHPStan\Reflection\MethodReflection;
13+
use PHPStan\Reflection\TrivialParametersAcceptor;
1214
use PHPStan\TrinaryLogic;
1315
use PHPStan\Type\ObjectType;
16+
use PHPStan\Type\Type;
1417

1518
class TableFindByPropertyMethodReflection implements MethodReflection
1619
{
17-
/** @var string */
18-
private $name;
20+
/**
21+
* @var string
22+
*/
23+
private string $name;
1924

20-
/** @var \PHPStan\Reflection\ClassReflection */
21-
private $declaringClass;
25+
/**
26+
* @var \PHPStan\Reflection\ClassReflection
27+
*/
28+
private ClassReflection $declaringClass;
2229

30+
/**
31+
* @param string $name
32+
* @param \PHPStan\Reflection\ClassReflection $declaringClass
33+
*/
2334
public function __construct(string $name, ClassReflection $declaringClass)
2435
{
2536
$this->name = $name;
2637
$this->declaringClass = $declaringClass;
2738
}
2839

40+
/**
41+
* @return \PHPStan\Reflection\ClassReflection
42+
*/
2943
public function getDeclaringClass(): ClassReflection
3044
{
3145
return $this->declaringClass;
3246
}
3347

48+
/**
49+
* @return \PHPStan\Reflection\ClassMemberReflection
50+
*/
3451
public function getPrototype(): ClassMemberReflection
3552
{
3653
return $this;
3754
}
3855

56+
/**
57+
* @return bool
58+
*/
3959
public function isStatic(): bool
4060
{
4161
return false;
4262
}
4363

4464
/**
45-
* @return \PHPStan\Reflection\ParameterReflection[]
65+
* @return array<\PHPStan\Reflection\ParameterReflection>
4666
*/
4767
public function getParameters(): array
4868
{
4969
return [];
5070
}
5171

72+
/**
73+
* @return bool
74+
*/
5275
public function isVariadic(): bool
5376
{
5477
return false;
5578
}
5679

80+
/**
81+
* @return bool
82+
*/
5783
public function isPrivate(): bool
5884
{
5985
return false;
6086
}
6187

88+
/**
89+
* @return bool
90+
*/
6291
public function isPublic(): bool
6392
{
6493
return true;
6594
}
6695

96+
/**
97+
* @return string
98+
*/
6799
public function getName(): string
68100
{
69101
return $this->name;
70102
}
71103

72-
public function getReturnType(): \PHPStan\Type\ObjectType
104+
/**
105+
* @return \PHPStan\Type\ObjectType
106+
*/
107+
public function getReturnType(): ObjectType
73108
{
74109
return new ObjectType('\Cake\ORM\Query');
75110
}
76111

112+
/**
113+
* @return string|null
114+
*/
77115
public function getDocComment(): ?string
78116
{
79117
return null;
@@ -84,35 +122,53 @@ public function getDocComment(): ?string
84122
*/
85123
public function getVariants(): array
86124
{
87-
return [new \PHPStan\Reflection\TrivialParametersAcceptor()];
125+
return [new TrivialParametersAcceptor()];
88126
}
89127

90-
public function isDeprecated(): \PHPStan\TrinaryLogic
128+
/**
129+
* @return \PHPStan\TrinaryLogic
130+
*/
131+
public function isDeprecated(): TrinaryLogic
91132
{
92133
return TrinaryLogic::createNo();
93134
}
94135

136+
/**
137+
* @return string|null
138+
*/
95139
public function getDeprecatedDescription(): ?string
96140
{
97141
return null;
98142
}
99143

100-
public function isFinal(): \PHPStan\TrinaryLogic
144+
/**
145+
* @return \PHPStan\TrinaryLogic
146+
*/
147+
public function isFinal(): TrinaryLogic
101148
{
102149
return TrinaryLogic::createNo();
103150
}
104151

105-
public function isInternal(): \PHPStan\TrinaryLogic
152+
/**
153+
* @return \PHPStan\TrinaryLogic
154+
*/
155+
public function isInternal(): TrinaryLogic
106156
{
107157
return TrinaryLogic::createNo();
108158
}
109159

110-
public function getThrowType(): ?\PHPStan\Type\Type
160+
/**
161+
* @return \PHPStan\Type\Type|null
162+
*/
163+
public function getThrowType(): ?Type
111164
{
112165
return null;
113166
}
114167

115-
public function hasSideEffects(): \PHPStan\TrinaryLogic
168+
/**
169+
* @return \PHPStan\TrinaryLogic
170+
*/
171+
public function hasSideEffects(): TrinaryLogic
116172
{
117173
return TrinaryLogic::createNo();
118174
}

0 commit comments

Comments
 (0)