Skip to content

Commit 477dd46

Browse files
authored
tests(phpstan): Enable level 3 checking (#1098)
1 parent 69ccbbd commit 477dd46

12 files changed

Lines changed: 27 additions & 15 deletions

File tree

examples/graphql_composable/src/GraphQL/Response/ArticleResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ArticleResponse extends Response {
1313
/**
1414
* The article to be served.
1515
*
16-
* @var \Drupal\Core\Entity\ContentEntityInterface|null
16+
* @var \Drupal\Core\Entity\EntityInterface|null
1717
*/
1818
protected $article;
1919

@@ -30,7 +30,7 @@ public function setArticle(?EntityInterface $article): void {
3030
/**
3131
* Gets the article to be served.
3232
*
33-
* @return \Drupal\Core\Entity\ContentEntityInterface|null
33+
* @return \Drupal\Core\Entity\EntityInterface|null
3434
* The article to be served.
3535
*/
3636
public function article(): ?EntityInterface {

examples/graphql_composable/src/Wrappers/Response/ArticleResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ArticleResponse extends Response {
1515
/**
1616
* The article to be served.
1717
*
18-
* @var \Drupal\Core\Entity\ContentEntityInterface|null
18+
* @var \Drupal\Core\Entity\EntityInterface|null
1919
*/
2020
protected $article;
2121

@@ -32,7 +32,7 @@ public function setArticle(?EntityInterface $article): void {
3232
/**
3333
* Gets the article to be served.
3434
*
35-
* @return \Drupal\Core\Entity\ContentEntityInterface|null
35+
* @return \Drupal\Core\Entity\EntityInterface|null
3636
* The article to be served.
3737
*/
3838
public function article(): ?EntityInterface {

examples/graphql_example/src/Wrappers/QueryConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class QueryConnection {
99

1010
/**
11-
* @var \Drupal\Core\Entity\Query\Sql\Query
11+
* @var \Drupal\Core\Entity\Query\QueryInterface
1212
*/
1313
protected $query;
1414

phpstan.neon

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parameters:
88
# PHPStan cannot find files in this test directory automatically.
99
scanDirectories:
1010
- ../../core/tests/Drupal/Tests
11-
level: 2
11+
level: 3
1212
customRulesetUsed: true
1313
paths:
1414
- .
@@ -29,3 +29,11 @@ parameters:
2929
- "#deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event#"
3030
- "#deprecated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent#"
3131
- "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#"
32+
# Drupal allows object property access to custom fields, so we cannot fix
33+
# that.
34+
- "#^Property Drupal\\\\.+ \\(Drupal\\\\Core\\\\Field\\\\FieldItemListInterface\\) does not accept .+\\.$#"
35+
# Incomplete type doc comments in Drupal core that we have to ignore.
36+
-
37+
message: "#^Method Drupal\\\\graphql\\\\Plugin\\\\LanguageNegotiation\\\\OperationLanguageNegotiation\\:\\:getLangcode\\(\\) should return string but returns false\\.$#"
38+
count: 1
39+
path: src/Plugin/LanguageNegotiation/OperationLanguageNegotiation.php

src/Config/LanguageConfigOverride.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ public function getCacheSuffix() {
7373
* {@inheritdoc}
7474
*/
7575
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
76+
// The interface says we should return an object here, but we don't care and
77+
// this does not seem to break anything?
78+
// @phpstan-ignore-next-line
7679
return NULL;
7780
}
7881

src/Entity/Server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ class Server extends ConfigEntityBase implements ServerInterface {
134134
/**
135135
* Persisted query plugin instances available on this server.
136136
*
137-
* @var array
137+
* @var array|null
138138
*/
139139
protected $persisted_query_instances = NULL;
140140

141141
/**
142142
* The sorted persisted query plugin instances available on this server.
143143
*
144-
* @var array
144+
* @var array|null
145145
*/
146146
protected $sorted_persisted_query_instances = NULL;
147147

src/Plugin/GraphQL/DataProducer/Entity/EntityChanged.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class EntityChanged extends DataProducerPluginBase {
3232
* @param \Drupal\Core\Entity\EntityInterface $entity
3333
* @param string|null $format
3434
*
35-
* @return string
35+
* @return string|null
3636
* @throws \Exception
3737
*/
3838
public function resolve(EntityInterface $entity, $format = NULL) {

src/Plugin/GraphQL/DataProducer/Entity/EntityCreated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class EntityCreated extends DataProducerPluginBase {
3131
* @param \Drupal\Core\Entity\EntityInterface $entity
3232
* @param string|null $format
3333
*
34-
* @return string
34+
* @return string|null
3535
*/
3636
public function resolve(EntityInterface $entity, $format = NULL) {
3737
// `getCreatedTime` is on NodeInterface which feels weird, since there

src/Plugin/GraphQL/DataProducer/Entity/EntityDescription.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class EntityDescription extends DataProducerPluginBase {
2626
/**
2727
* @param \Drupal\Core\Entity\EntityInterface $entity
2828
*
29-
* @return string
29+
* @return string|null
3030
*/
3131
public function resolve(EntityInterface $entity) {
3232
if ($entity instanceof EntityDescriptionInterface) {

src/Plugin/GraphQL/DataProducer/Field/EntityReference.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class EntityReference extends DataProducerPluginBase implements ContainerFactory
6464
/**
6565
* The entity type manager service.
6666
*
67-
* @var \Drupal\Core\Entity\EntityTypeManager
67+
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
6868
*/
6969
protected $entityTypeManager;
7070

0 commit comments

Comments
 (0)