Skip to content

Commit 6f5e270

Browse files
authored
IBX-10507: Allowed nullable type declarations for method parameters across the codebase (#104)
1 parent 1b37f6f commit 6f5e270

File tree

67 files changed

+83
-468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+83
-468
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -588,18 +588,6 @@ parameters:
588588
count: 1
589589
path: src/lib/Gateway/EndpointResolver/NativeEndpointResolver.php
590590

591-
-
592-
message: '#^Method Ibexa\\Solr\\Gateway\\HttpClient\\Stream\:\:getResponseMessage\(\) has parameter \$method with no type specified\.$#'
593-
identifier: missingType.parameter
594-
count: 1
595-
path: src/lib/Gateway/HttpClient/Stream.php
596-
597-
-
598-
message: '#^Method Ibexa\\Solr\\Gateway\\HttpClient\\Stream\:\:getResponseMessage\(\) has parameter \$path with no type specified\.$#'
599-
identifier: missingType.parameter
600-
count: 1
601-
path: src/lib/Gateway/HttpClient/Stream.php
602-
603591
-
604592
message: '#^Method Ibexa\\Solr\\Gateway\\Message\:\:__construct\(\) has parameter \$headers with no value type specified in iterable type array\.$#'
605593
identifier: missingType.iterableValue
@@ -1014,36 +1002,6 @@ parameters:
10141002
count: 1
10151003
path: src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php
10161004

1017-
-
1018-
message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#'
1019-
identifier: method.nonObject
1020-
count: 1
1021-
path: src/lib/Query/Common/CriterionVisitor/LogicalAnd.php
1022-
1023-
-
1024-
message: '#^Method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\LogicalAnd\:\:visit\(\) should return string but returns false\.$#'
1025-
identifier: return.type
1026-
count: 1
1027-
path: src/lib/Query/Common/CriterionVisitor/LogicalAnd.php
1028-
1029-
-
1030-
message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#'
1031-
identifier: method.nonObject
1032-
count: 1
1033-
path: src/lib/Query/Common/CriterionVisitor/LogicalNot.php
1034-
1035-
-
1036-
message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#'
1037-
identifier: method.nonObject
1038-
count: 1
1039-
path: src/lib/Query/Common/CriterionVisitor/LogicalOr.php
1040-
1041-
-
1042-
message: '#^Method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\LogicalOr\:\:visit\(\) should return string but returns false\.$#'
1043-
identifier: return.type
1044-
count: 1
1045-
path: src/lib/Query/Common/CriterionVisitor/LogicalOr.php
1046-
10471005
-
10481006
message: '#^Method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\MapLocation\:\:getSearchFields\(\) return type has no value type specified in iterable type array\.$#'
10491007
identifier: missingType.iterableValue

src/contracts/Query/CriterionVisitor.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ abstract class CriterionVisitor
2222
abstract public function canVisit(Criterion $criterion);
2323

2424
/**
25-
* Map field value to a proper Solr representation.
26-
*
27-
* @param CriterionVisitor $subVisitor
28-
*
2925
* @return string
3026
*/
31-
abstract public function visit(Criterion $criterion, self $subVisitor = null);
27+
abstract public function visit(Criterion $criterion, ?self $subVisitor = null);
3228

3329
/**
3430
* Get Solr range.

src/lib/Gateway/HttpClient.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,7 @@
1111
*/
1212
interface HttpClient
1313
{
14-
/**
15-
* Execute a HTTP request to the remote server.
16-
*
17-
* Returns the result from the remote server.
18-
*
19-
* @param string $method
20-
* @param \Ibexa\Solr\Gateway\Endpoint $endpoint
21-
* @param string $path
22-
* @param \Ibexa\Solr\Gateway\Message $message
23-
*
24-
* @return \Ibexa\Solr\Gateway\Message
25-
*/
26-
public function request($method, Endpoint $endpoint, $path, Message $message = null);
14+
public function request(string $method, Endpoint $endpoint, string $path, ?Message $message = null): Message;
2715
}
2816

2917
class_alias(HttpClient::class, 'EzSystems\EzPlatformSolrSearchEngine\Gateway\HttpClient');

src/lib/Gateway/HttpClient/Stream.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,7 @@ public function __construct(HttpClientInterface $client, int $timeout = 10)
4040
$this->setLogger(new NullLogger());
4141
}
4242

43-
/**
44-
* Execute an HTTP request to the remote server.
45-
*
46-
* Returns the result from the remote server.
47-
*
48-
* @param string $method
49-
* @param string $path
50-
*
51-
* @return \Ibexa\Solr\Gateway\Message
52-
*/
53-
public function request($method, Endpoint $endpoint, $path, Message $message = null): Message
43+
public function request(string $method, Endpoint $endpoint, string $path, ?Message $message = null): Message
5444
{
5545
$message = $message ?? new Message();
5646

@@ -73,9 +63,9 @@ public function request($method, Endpoint $endpoint, $path, Message $message = n
7363
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
7464
*/
7565
private function getResponseMessage(
76-
$method,
66+
string $method,
7767
Endpoint $endpoint,
78-
$path,
68+
string $path,
7969
Message $message
8070
): Message {
8171
if ($endpoint->user !== null) {

src/lib/Handler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,11 @@ public function findLocations(LocationQuery $query, array $languageFilter = [])
232232
}
233233

234234
/**
235-
* Suggests a list of values for the given prefix.
236-
*
237235
* @param string $prefix
238236
* @param string[] $fieldPaths
239237
* @param int $limit
240-
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $filter
241238
*/
242-
public function suggest($prefix, $fieldPaths = [], $limit = 10, Criterion $filter = null)
239+
public function suggest($prefix, $fieldPaths = [], $limit = 10, ?Criterion $filter = null)
243240
{
244241
throw new \Exception('@todo: Not implemented yet.');
245242
}

src/lib/Query/Common/CriterionVisitor/Aggregate.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,9 @@ public function canVisit(Criterion $criterion)
5353
}
5454

5555
/**
56-
* Map field value to a proper Solr representation.
57-
*
5856
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException
59-
*
60-
* @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor
61-
*
62-
* @return string
6357
*/
64-
public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
58+
public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null): string
6559
{
6660
foreach ($this->visitors as $visitor) {
6761
if ($visitor->canVisit($criterion)) {

src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function canVisit(Criterion $criterion): bool
2424
return $criterion instanceof Criterion\IsContainer && $criterion->operator === Operator::EQ;
2525
}
2626

27-
public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string
27+
public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null): string
2828
{
2929
$value = $criterion->value;
3030

src/lib/Query/Common/CriterionVisitor/ContentIdIn.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ public function canVisit(Criterion $criterion)
3030
);
3131
}
3232

33-
/**
34-
* Map field value to a proper Solr representation.
35-
*
36-
* @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor
37-
*
38-
* @return string
39-
*/
40-
public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
33+
public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null): string
4134
{
4235
return '(' .
4336
implode(

src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ public function canVisit(Criterion $criterion)
3030
);
3131
}
3232

33-
/**
34-
* Map field value to a proper Solr representation.
35-
*
36-
* @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor
37-
*
38-
* @return string
39-
*/
40-
public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
33+
public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null): string
4134
{
4235
return '(' .
4336
implode(

src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ public function canVisit(Criterion $criterion)
3030
);
3131
}
3232

33-
/**
34-
* Map field value to a proper Solr representation.
35-
*
36-
* @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor
37-
*
38-
* @return string
39-
*/
40-
public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
33+
public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null): string
4134
{
4235
return '(' .
4336
implode(

0 commit comments

Comments
 (0)