Skip to content

Commit c686f34

Browse files
Code sniffer validations (#482)
* [#475] Adding http_client_proxy setting field - code sniffer validations and message strings. * Fixing code sniffer validations after update to drupal/coder 8.3.10
1 parent d8eac5e commit c686f34

7 files changed

+22
-20
lines changed

phpcs.xml.dist

+4
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
<rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName">
1919
<severity>0</severity>
2020
</rule>
21+
<!-- Ignore long array declaration lines. -->
22+
<rule ref="Drupal.Arrays.Array.LongLineDeclaration">
23+
<severity>0</severity>
24+
</rule>
2125

2226
</ruleset>

src/Exception/AuthenticationKeyValueMalformedException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Drupal\apigee_edge\Exception;
44

5-
use Throwable;
6-
75
/**
86
* Defines an exception for when a key value is malformed.
97
*/
@@ -30,7 +28,7 @@ class AuthenticationKeyValueMalformedException extends AuthenticationKeyExceptio
3028
* @param \Throwable|null $previous
3129
* Previous exception.
3230
*/
33-
public function __construct($problematic_field, $message = 'Apigee Edge API authentication key is malformed or not readable.', $code = 0, Throwable $previous = NULL) {
31+
public function __construct($problematic_field, $message = 'Apigee Edge API authentication key is malformed or not readable.', $code = 0, \Throwable $previous = NULL) {
3432
$this->problematicField = $problematic_field;
3533
$message = strtr($message, ['@field' => $problematic_field]);
3634
parent::__construct($message, $code, $previous);

src/Form/ConnectionConfigForm.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ public function buildForm(array $form, FormStateInterface $form_state) {
6767
'#required' => TRUE,
6868
];
6969

70-
$form['http_proxy'] = [
71-
'#type' => 'textfield',
72-
'#title' => $this->t('HTTP client proxy'),
73-
'#description' => $this->t('The Http proxy used to connect to Apigee Edge.'),
74-
'#default_value' => $this->config('apigee_edge.client')->get('http_client_proxy'),
75-
'#required' => FALSE,
76-
];
70+
$form['http_proxy'] = [
71+
'#type' => 'textfield',
72+
'#title' => $this->t('HTTP client proxy'),
73+
'#description' => $this->t('Leave empty unless an HTTP proxy is needed to connect to Apigee Edge.'),
74+
'#default_value' => $this->config('apigee_edge.client')->get('http_client_proxy'),
75+
'#required' => FALSE,
76+
];
7777

7878
return parent::buildForm($form, $form_state);
7979
}
@@ -85,7 +85,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
8585
$this->config('apigee_edge.client')
8686
->set('http_client_connect_timeout', $form_state->getValue('connect_timeout'))
8787
->set('http_client_timeout', $form_state->getValue('request_timeout'))
88-
->set('http_client_proxy', $form_state->getValue('http_proxy'))
88+
->set('http_client_proxy', trim($form_state->getValue('http_proxy')))
8989
->save();
9090
parent::submitForm($form, $form_state);
9191
}

src/KeyEntityFormEnhancer.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Apigee\Edge\Exception\HybridOauth2AuthenticationException;
2525
use Apigee\Edge\Exception\OauthAuthenticationException;
2626
use Apigee\Edge\HttpClient\Plugin\Authentication\Oauth;
27-
use DomainException;
2827
use Drupal\apigee_edge\Exception\AuthenticationKeyException;
2928
use Drupal\apigee_edge\Exception\InvalidArgumentException;
3029
use Drupal\apigee_edge\Exception\KeyProviderRequirementsException;
@@ -478,7 +477,7 @@ private function createSuggestion(\Exception $exception, KeyInterface $key): Mar
478477
]);
479478

480479
// Invalid key / OpenSSL unable to sign data.
481-
if ($exception->getPrevious() && $exception->getPrevious() instanceof DomainException) {
480+
if ($exception->getPrevious() && $exception->getPrevious() instanceof \DomainException) {
482481
$suggestion = $this->t('@fail_text The private key in the GCP service account key JSON is invalid.', [
483482
'@fail_text' => $fail_text,
484483
]);

src/Plugin/FieldStorageFormatManager.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Drupal\Core\Cache\CacheBackendInterface;
2424
use Drupal\Core\Extension\ModuleHandlerInterface;
2525
use Drupal\Core\Plugin\DefaultPluginManager;
26-
use Traversable;
2726

2827
/**
2928
* Provides a FieldStorageFormat plugin manager.
@@ -33,7 +32,7 @@ class FieldStorageFormatManager extends DefaultPluginManager implements FieldSto
3332
/**
3433
* {@inheritdoc}
3534
*/
36-
public function __construct(Traversable $namespaces, CacheBackendInterface $cache, ModuleHandlerInterface $module_handler) {
35+
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache, ModuleHandlerInterface $module_handler) {
3736
parent::__construct(
3837
'Plugin/ApigeeFieldStorageFormat',
3938
$namespaces,

tests/src/Functional/DeveloperAppUITest.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,10 @@ public function testWarningMessagesIfMultipleProductsDisabled() {
482482
->save();
483483
\Drupal::entityTypeManager()->clearCachedDefinitions();
484484

485-
$this->products[] = $product1 = $this->createProduct();;
486-
$this->products[] = $product2 = $this->createProduct();
485+
$product1 = $this->createProduct();
486+
$product2 = $this->createProduct();
487+
$this->products[] = $product1;
488+
$this->products[] = $product2;
487489
$app = $this->createDeveloperApp(['name' => $this->randomMachineName(), 'displayName' => $this->randomString()], $this->account, [$product1->id(), $product2->id()]);
488490
$app_edit_url = $app->toUrl('edit-form-for-developer');
489491

@@ -517,7 +519,8 @@ public function testCallbackUrlValidationServerSide() {
517519
->save();
518520

519521
$callback_url = $this->randomMachineName();
520-
$this->products[] = $product = $this->createProduct();;
522+
$product = $this->createProduct();
523+
$this->products[] = $product;
521524
$app = $this->createDeveloperApp([
522525
'name' => $callback_url,
523526
'displayName' => $this->randomString(),

tests/src/Unit/Command/Util/ApigeeEdgeManagementCliServiceTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
use GuzzleHttp\Psr7\Response;
3232
use Prophecy\Argument;
3333
use Psr\Http\Message\RequestInterface;
34-
use ReflectionClass;
3534
use Symfony\Component\Console\Style\StyleInterface;
3635

3736
/**
@@ -479,7 +478,7 @@ public function testSetDefaultPermissions() {
479478

480479
// Make method under test not private.
481480
$apigee_edge_management_cli_service = new ApigeeEdgeManagementCliService($this->httpClient->reveal());
482-
$apigee_edge_management_cli_service_reflection = new ReflectionClass($apigee_edge_management_cli_service);
481+
$apigee_edge_management_cli_service_reflection = new \ReflectionClass($apigee_edge_management_cli_service);
483482
$method_set_default_permissions = $apigee_edge_management_cli_service_reflection->getMethod('setDefaultPermissions');
484483
$method_set_default_permissions->setAccessible(TRUE);
485484

0 commit comments

Comments
 (0)