Skip to content

Commit 00f7180

Browse files
committed
qa: fix CS issues
- Fixes issues flagged by CS - Updates data providers and test methods using data providers to use proper types Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
1 parent 1577e67 commit 00f7180

File tree

5 files changed

+41
-58
lines changed

5 files changed

+41
-58
lines changed

psalm-baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@
153153
<code>$routeMatch</code>
154154
<code>$routeMatch</code>
155155
</MixedAssignment>
156-
<MixedInferredReturnType occurrences="4">
157-
<code>array</code>
158-
<code>array</code>
159-
<code>array</code>
160-
<code>array</code>
161-
</MixedInferredReturnType>
162156
<MixedMethodCall occurrences="36">
163157
<code>addHeaderLine</code>
164158
<code>addHeaderLine</code>

src/ContentTypeListener.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ protected function parseHeaderForMatches($value)
131131
*
132132
* @param RouteMatch|V2RouteMatch $routeMatches
133133
* @param array $matches
134-
*
135-
* @return void
136134
*/
137135
protected function injectRouteMatches($routeMatches, array $matches): void
138136
{

test/ContentTypeListenerTest.php

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,15 @@ public function testInjectsNothingIfContentTypeHeaderIsMissing(): void
5757
$this->assertNull($this->listener->onRoute($this->event));
5858
}
5959

60-
/** @return array */
61-
public function validDefaultContentTypes()
60+
/**
61+
* @psalm-return array<array-key, array{
62+
* 0: string,
63+
* 1: string,
64+
* 2: int,
65+
* 3: string
66+
* }>
67+
*/
68+
public function validDefaultContentTypes(): array
6269
{
6370
return [
6471
[
@@ -78,16 +85,13 @@ public function validDefaultContentTypes()
7885

7986
/**
8087
* @dataProvider validDefaultContentTypes
81-
*
82-
* @param string $header
83-
* @param string $vendor
84-
* @param int $version
85-
* @param string $resource
86-
*
87-
* @return void
8888
*/
89-
public function testInjectsRouteMatchesWhenContentTypeMatchesDefaultRegexp($header, $vendor, $version, $resource): void
90-
{
89+
public function testInjectsRouteMatchesWhenContentTypeMatchesDefaultRegexp(
90+
string $header,
91+
string $vendor,
92+
int $version,
93+
string $resource
94+
): void {
9195
$request = $this->event->getRequest();
9296
$headers = $request->getHeaders();
9397
$headers->addHeaderLine('Content-Type', $header);
@@ -99,8 +103,8 @@ public function testInjectsRouteMatchesWhenContentTypeMatchesDefaultRegexp($head
99103
$this->assertEquals($resource, $routeMatch->getParam('laminas_ver_resource', false));
100104
}
101105

102-
/** @return array */
103-
public function invalidDefaultContentTypes()
106+
/** @psalm-return array<string, array{0: string}> */
107+
public function invalidDefaultContentTypes(): array
104108
{
105109
return [
106110
'bad-prefix' => ['application/vendor.mwop.v1.status'],
@@ -112,12 +116,8 @@ public function invalidDefaultContentTypes()
112116

113117
/**
114118
* @dataProvider invalidDefaultContentTypes
115-
*
116-
* @param string $header
117-
*
118-
* @return void
119119
*/
120-
public function testInjectsNothingIntoRouteMatchesWhenContentTypeDoesNotMatchDefaultRegexp($header): void
120+
public function testInjectsNothingIntoRouteMatchesWhenContentTypeDoesNotMatchDefaultRegexp(string $header): void
121121
{
122122
$request = $this->event->getRequest();
123123
$headers = $request->getHeaders();
@@ -130,8 +130,15 @@ public function testInjectsNothingIntoRouteMatchesWhenContentTypeDoesNotMatchDef
130130
$this->assertFalse($routeMatch->getParam('laminas_ver_resource', false));
131131
}
132132

133-
/** @return array */
134-
public function validCustomContentTypes()
133+
/**
134+
* @psalm-return array<array-key, array{
135+
* 0: string,
136+
* 1: string,
137+
* 2: int,
138+
* 3: string
139+
* }>
140+
*/
141+
public function validCustomContentTypes(): array
135142
{
136143
return [
137144
[
@@ -151,16 +158,13 @@ public function validCustomContentTypes()
151158

152159
/**
153160
* @dataProvider validCustomContentTypes
154-
*
155-
* @param string $header
156-
* @param string $vendor
157-
* @param int $version
158-
* @param string $resource
159-
*
160-
* @return void
161161
*/
162-
public function testWillInjectRouteMatchesWhenContentTypeMatchesCustomRegexp($header, $vendor, $version, $resource): void
163-
{
162+
public function testWillInjectRouteMatchesWhenContentTypeMatchesCustomRegexp(
163+
string $header,
164+
string $vendor,
165+
int $version,
166+
string $resource
167+
): void {
164168
$this->listener->addRegexp(
165169
'#application/vendor\.(?<vendor>mwop)\.(?<version>\d+)\.(?<resource>(?:user|status))#'
166170
);
@@ -176,8 +180,13 @@ public function testWillInjectRouteMatchesWhenContentTypeMatchesCustomRegexp($he
176180
$this->assertEquals($resource, $routeMatch->getParam('resource', false));
177181
}
178182

179-
/** @return array */
180-
public function mixedContentTypes()
183+
/**
184+
* @psalm-return array<string, array{
185+
* 0: string,
186+
* 1: array<string, string|int>
187+
* }>
188+
*/
189+
public function mixedContentTypes(): array
181190
{
182191
return [
183192
'default' => [
@@ -201,13 +210,8 @@ public function mixedContentTypes()
201210

202211
/**
203212
* @dataProvider mixedContentTypes
204-
*
205-
* @param string $header
206-
* @param array $matches
207-
*
208-
* @return void
209213
*/
210-
public function testWillInjectRouteMatchesForFirstRegexpToMatch($header, array $matches): void
214+
public function testWillInjectRouteMatchesForFirstRegexpToMatch(string $header, array $matches): void
211215
{
212216
$this->listener->addRegexp('#application/vnd\.(?<vendor>mwop)\.(?<version>\d+)\.(?<resource>(?:user|status))#');
213217

test/PrototypeRouteListenerTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ public function routesWithoutPrototype()
6969

7070
/**
7171
* @dataProvider routesWithoutPrototype
72-
*
7372
* @param array $routes
74-
*
75-
* @return void
7673
*/
7774
public function testEmptyConfigurationDoesNotInjectPrototypes(array $routes): void
7875
{
@@ -105,11 +102,8 @@ public function routesForWhichToVerifyPrototype()
105102

106103
/**
107104
* @dataProvider routesForWhichToVerifyPrototype
108-
*
109105
* @param int|null $apiVersion
110106
* @param int $position
111-
*
112-
* @return void
113107
*/
114108
public function testPrototypeAddedToRoutesProvidedToListener(array $routes, $apiVersion = null, $position = 0): void
115109
{
@@ -163,10 +157,7 @@ public function defaultVersionValues()
163157

164158
/**
165159
* @dataProvider defaultVersionValues
166-
*
167160
* @param int|null $apiVersion
168-
*
169-
* @return void
170161
*/
171162
public function testPrototypeAddedToRoutesWithDefaultVersion($apiVersion = null): void
172163
{
@@ -216,8 +207,6 @@ public function specificDefaultVersionForWhichToVerifyPrototype()
216207

217208
/**
218209
* @dataProvider specificDefaultVersionForWhichToVerifyPrototype
219-
*
220-
* @return void
221210
*/
222211
public function testPrototypeAddedToRoutesWithSpecificDefaultVersion(array $defaultVersions): void
223212
{

test/VersionListenerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ public function testAltersControllerVersionNamespaceToReflectVersion(): void
8585

8686
/**
8787
* @group 12
88-
*
89-
* @return void
9088
*/
9189
public function testAltersControllerVersionNamespaceToReflectVersionForOptionsRequests(): void
9290
{

0 commit comments

Comments
 (0)