Skip to content

Commit b93c456

Browse files
authored
style(phpcs): Enable DrupalPractice coding standard checking (#1074)
1 parent 0ad5a8f commit b93c456

9 files changed

Lines changed: 36 additions & 18 deletions

File tree

examples/graphql_composable/graphql_composable.info.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ core: 8.x
66
dependencies:
77
- graphql:graphql
88
- node:node
9+
core_version_requirement: ^8 || ^9

examples/graphql_example/graphql_examples.info.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ core: 8.x
66
dependencies:
77
- graphql:graphql
88
- node:node
9+
core_version_requirement: ^8 || ^9

phpcs.xml.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66
<arg name="extensions" value="inc,install,module,php,profile,test,theme,yml"/>
77

88
<rule ref="Drupal"></rule>
9+
<rule ref="DrupalPractice"></rule>
10+
11+
<!-- TODO: check if we can fix those reported errors in code-->
12+
<rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable">
13+
<exclude-pattern>src/Plugin/GraphQL/DataProducer/DataProducerProxy.php</exclude-pattern>
14+
<exclude-pattern>src/Plugin/GraphQL/DataProducer/Field/EntityReference.php</exclude-pattern>
15+
<exclude-pattern>src/Plugin/GraphQL/DataProducer/Routing/RouteEntity.php</exclude-pattern>
16+
<exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLoadMultiple.php</exclude-pattern>
17+
<exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLoad.php</exclude-pattern>
18+
<exclude-pattern>tests/src/Kernel/DataProducer/MenuTest.php</exclude-pattern>
19+
</rule>
20+
21+
<rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis.UndefinedVariable">
22+
<exclude-pattern>src/Plugin/GraphQL/DataProducer/Field/EntityReference.php</exclude-pattern>
23+
<exclude-pattern>tests/src/Kernel/DataProducer/MenuTest.php</exclude-pattern>
24+
</rule>
925

1026
<!-- TODO: those rules are disabled for now until we fix the coding standards for them. -->
1127
<rule ref="Drupal.Commenting.ClassComment.Missing">

src/Form/ServerForm.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ public function form(array $form, FormStateInterface $formState) {
102102
}
103103

104104
$form['label'] = [
105-
'#title' => t('Label'),
105+
'#title' => $this->t('Label'),
106106
'#type' => 'textfield',
107107
'#default_value' => $server->label(),
108-
'#description' => t('The human-readable name of this server.'),
108+
'#description' => $this->t('The human-readable name of this server.'),
109109
'#required' => TRUE,
110110
'#size' => 30,
111111
];
@@ -118,15 +118,15 @@ public function form(array $form, FormStateInterface $formState) {
118118
'exists' => ['Drupal\graphql\Entity\Server', 'load'],
119119
'source' => ['label'],
120120
],
121-
'#description' => t('A unique machine-readable name for this server. It must only contain lowercase letters, numbers, and underscores.'),
121+
'#description' => $this->t('A unique machine-readable name for this server. It must only contain lowercase letters, numbers, and underscores.'),
122122
];
123123

124124
$form['schema'] = [
125-
'#title' => t('Schema'),
125+
'#title' => $this->t('Schema'),
126126
'#type' => 'select',
127127
'#options' => $schemas,
128128
'#default_value' => $schema,
129-
'#description' => t('The schema to use with this server.'),
129+
'#description' => $this->t('The schema to use with this server.'),
130130
'#ajax' => [
131131
'callback' => '::ajaxSchemaConfigurationForm',
132132
'progress' => [
@@ -158,34 +158,34 @@ public function form(array $form, FormStateInterface $formState) {
158158
}
159159

160160
$form['endpoint'] = [
161-
'#title' => t('Endpoint'),
161+
'#title' => $this->t('Endpoint'),
162162
'#type' => 'textfield',
163163
'#default_value' => $server->get('endpoint'),
164-
'#description' => t('The endpoint for http queries. Has to start with a forward slash. For example "/graphql".'),
164+
'#description' => $this->t('The endpoint for http queries. Has to start with a forward slash. For example "/graphql".'),
165165
'#required' => TRUE,
166166
'#size' => 30,
167167
'#field_prefix' => $this->requestContext->getCompleteBaseUrl(),
168168
];
169169

170170
$form['batching'] = [
171-
'#title' => t('Allow query batching'),
171+
'#title' => $this->t('Allow query batching'),
172172
'#type' => 'checkbox',
173173
'#default_value' => !!$server->get('batching'),
174-
'#description' => t('Whether batched queries are allowed.'),
174+
'#description' => $this->t('Whether batched queries are allowed.'),
175175
];
176176

177177
$form['caching'] = [
178-
'#title' => t('Enable caching'),
178+
'#title' => $this->t('Enable caching'),
179179
'#type' => 'checkbox',
180180
'#default_value' => !!$server->get('caching'),
181-
'#description' => t('Whether caching of queries and partial results is enabled.'),
181+
'#description' => $this->t('Whether caching of queries and partial results is enabled.'),
182182
];
183183

184184
$form['debug'] = [
185-
'#title' => t('Enable debugging'),
185+
'#title' => $this->t('Enable debugging'),
186186
'#type' => 'checkbox',
187187
'#default_value' => !!$server->get('debug'),
188-
'#description' => t('In debugging mode, error messages contain more verbose information in the query response.'),
188+
'#description' => $this->t('In debugging mode, error messages contain more verbose information in the query response.'),
189189
];
190190

191191
$form['actions'] = [

src/Plugin/GraphQL/DataProducer/DataProducerProxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use Drupal\graphql\Plugin\DataProducerPluginCachingInterface;
1515
use Drupal\graphql\Plugin\DataProducerPluginInterface;
1616
use Drupal\graphql\Plugin\DataProducerPluginManager;
17-
use GraphQL\Type\Definition\ResolveInfo;
1817
use Symfony\Component\HttpFoundation\RequestStack;
18+
use GraphQL\Type\Definition\ResolveInfo;
1919

2020
/**
2121
* Data producers proxy class.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Drupal\Core\Render\RendererInterface;
1212
use Drupal\graphql\GraphQL\Execution\ResolveContext;
1313
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
14-
use GraphQL\Type\Definition\ResolveInfo;
1514
use Symfony\Component\DependencyInjection\ContainerInterface;
1615

1716
/**

src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Drupal\Core\Path\PathValidatorInterface;
77
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
88
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
9-
use Drupal\redirect\RedirectRepository;
109
use Symfony\Component\DependencyInjection\ContainerInterface;
1110

1211
/**

src/Plugin/GraphQL/Schema/ComposableSchema.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Drupal\Core\Form\FormStateInterface;
88
use Drupal\Core\Plugin\PluginFormInterface;
99
use Drupal\graphql\GraphQL\ResolverRegistry;
10+
use Drupal\Core\StringTranslation\StringTranslationTrait;
1011

1112
/**
1213
* @Schema(
@@ -15,6 +16,7 @@
1516
* )
1617
*/
1718
class ComposableSchema extends SdlSchemaPluginBase implements ConfigurableInterface, PluginFormInterface {
19+
use StringTranslationTrait;
1820

1921
/**
2022
* {@inheritdoc}
@@ -76,7 +78,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
7678
$form['extensions'] = [
7779
'#type' => 'checkboxes',
7880
'#required' => FALSE,
79-
'#title' => t('Enabled extensions'),
81+
'#title' => $this->t('Enabled extensions'),
8082
'#options' => [],
8183
'#default_value' => $this->configuration['extensions'] ?? [],
8284
];

tests/modules/graphql_persisted_queries_test/graphql_persisted_queries_test.info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ package: Testing
55
core: 8.x
66
hidden: TRUE
77
dependencies:
8-
- graphql
8+
- graphql:graphql

0 commit comments

Comments
 (0)