diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7bca0ad9..da07d8a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,11 @@ +# To add new Drupal versions, update quant-ci-images repo. name: Test and code coverage on: - push jobs: lint: runs-on: ubuntu-latest - container: quantcdn/drupal-ci:9.4.x-dev + container: quantcdn/drupal-ci:11.0.x-dev steps: - uses: actions/checkout@v2 - name: Lint @@ -12,7 +13,7 @@ jobs: phpunit: runs-on: ubuntu-latest - container: quantcdn/drupal-ci:9.4.x-dev + container: quantcdn/drupal-ci:11.0.x-dev services: mariadb: @@ -20,7 +21,7 @@ jobs: ports: - 3306:3306 env: - MYSQL_DATABASE: drupal9 + MYSQL_DATABASE: drupal MYSQL_ROOT_PASSWORD: drupal MYSQL_USER: drupal MYSQL_PASSWORD: drupal @@ -32,7 +33,7 @@ jobs: steps: - name: Install Drupal - run: drush si --db-url=mysql://root:drupal@mariadb:3306/drupal9 -y + run: drush si --db-url=mysql://root:drupal@mariadb:3306/drupal -y working-directory: /var/www/drupal - name: Install module dependencies diff --git a/modules/quant_api/src/Client/QuantClient.php b/modules/quant_api/src/Client/QuantClient.php index 1f03c168..534ad18a 100644 --- a/modules/quant_api/src/Client/QuantClient.php +++ b/modules/quant_api/src/Client/QuantClient.php @@ -270,7 +270,7 @@ public function sendRedirect(array $data) : array { /** * {@inheritdoc} */ - public function sendFile(string $file, string $url, int $rid = NULL) : array { + public function sendFile(string $file, string $url, ?int $rid = NULL) : array { // Ensure the file is accessible before attempting to send to the API. if (!file_exists($file) || !is_readable($file) || !is_file($file)) { diff --git a/modules/quant_api/src/Client/QuantClientInterface.php b/modules/quant_api/src/Client/QuantClientInterface.php index cc7a40fc..7266618b 100644 --- a/modules/quant_api/src/Client/QuantClientInterface.php +++ b/modules/quant_api/src/Client/QuantClientInterface.php @@ -65,7 +65,7 @@ public function send(array $data) : array; * @throws \Drupal\quant_api\Exception\InvalidPayload * @throws \Drupal\quant_api\Exception\InvalidResposne */ - public function sendFile(string $file, string $url, int $rid = NULL) : array; + public function sendFile(string $file, string $url, ?int $rid = NULL) : array; /** * Send a redirect to the API. diff --git a/modules/quant_api/tests/src/Unit/QuantClientTest.php b/modules/quant_api/tests/src/Unit/QuantClientTest.php index 31dd205a..184d50fb 100644 --- a/modules/quant_api/tests/src/Unit/QuantClientTest.php +++ b/modules/quant_api/tests/src/Unit/QuantClientTest.php @@ -2,12 +2,13 @@ namespace Drupal\Tests\quant_api\Unit; -use Drupal\Tests\UnitTestCase; -use Drupal\quant_api\Client\QuantClient; -use GuzzleHttp\Client; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ImmutableConfig; +use Drupal\quant_api\Client\QuantClient; +use Drupal\quant_api\Exception\InvalidPayload; +use Drupal\Tests\UnitTestCase; +use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\Response; use GuzzleHttp\RequestOptions; @@ -201,7 +202,7 @@ public function testSendValid() { * Ensure that send handles server errors. */ public function testSendError() { - $this->expectException(\GuzzleHttp\Exception\RequestException::class); + $this->expectException(RequestException::class); $http = $this->prophesize(Client::class); $logger = $this->prophesize(LoggerChannelFactoryInterface::class); $config = $this->getConfigStub(); @@ -255,7 +256,7 @@ public function testSendRedirectValid() { * Ensure a valid redirect response is sent. */ public function testSendRedirectError() { - $this->expectException(\GuzzleHttp\Exception\RequestException::class); + $this->expectException(RequestException::class); $http = $this->prophesize(Client::class); $logger = $this->prophesize(LoggerChannelFactoryInterface::class); $config = $this->getConfigStub(); @@ -278,7 +279,7 @@ public function testSendRedirectError() { * Ensure files are validated before sending. */ public function testSendFileFileNoExist() { - $this->expectException(\Drupal\quant_api\Exception\InvalidPayload::class); + $this->expectException(InvalidPayload::class); // phpcs:ignore global $exists_return; // phpcs:ignore diff --git a/modules/quant_search/src/Form/ConfirmIndexClearForm.php b/modules/quant_search/src/Form/ConfirmIndexClearForm.php index 43c32954..e97a16e1 100644 --- a/modules/quant_search/src/Form/ConfirmIndexClearForm.php +++ b/modules/quant_search/src/Form/ConfirmIndexClearForm.php @@ -14,7 +14,7 @@ class ConfirmIndexClearForm extends ConfirmFormBase { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, string $id = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ?string $id = NULL) { return parent::buildForm($form, $form_state); } diff --git a/src/Controller/QuantNodeViewController.php b/src/Controller/QuantNodeViewController.php index 7ab518b2..871ca147 100644 --- a/src/Controller/QuantNodeViewController.php +++ b/src/Controller/QuantNodeViewController.php @@ -53,7 +53,7 @@ class QuantNodeViewController extends NodeViewController { * @param \Drupal\Core\Session\AccountSwitcherInterface $account_switcher * The account switcher interface. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, AccountInterface $current_user = NULL, EntityRepositoryInterface $entity_repository = NULL, RequestStack $request_stack, CurrentRouteMatch $route_match, AccountSwitcherInterface $account_switcher) { + public function __construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, ?AccountInterface $current_user = NULL, ?EntityRepositoryInterface $entity_repository = NULL, RequestStack $request_stack, CurrentRouteMatch $route_match, AccountSwitcherInterface $account_switcher) { parent::__construct($entity_type_manager, $renderer, $current_user, $entity_repository); $this->accountSwitcher = $account_switcher; diff --git a/src/Event/ConfigFormEventBase.php b/src/Event/ConfigFormEventBase.php index 43a06fa2..a8fa651c 100644 --- a/src/Event/ConfigFormEventBase.php +++ b/src/Event/ConfigFormEventBase.php @@ -36,7 +36,7 @@ class ConfigFormEventBase extends Event implements ConfigFormEventInterface { /** * {@inheritdoc} */ - public function __construct(FormStateInterface $form_state = NULL) { + public function __construct(?FormStateInterface $form_state = NULL) { $this->formState = $form_state; } diff --git a/src/Event/ConfigFormEventInterface.php b/src/Event/ConfigFormEventInterface.php index 7bdc3640..1cdea35e 100644 --- a/src/Event/ConfigFormEventInterface.php +++ b/src/Event/ConfigFormEventInterface.php @@ -15,7 +15,7 @@ interface ConfigFormEventInterface { * @param Drupal\Core\Form\FormStateInterface $form_state * The configuration values. */ - public function __construct(FormStateInterface $form_state = NULL); + public function __construct(?FormStateInterface $form_state = NULL); /** * Accessor for the form state. diff --git a/src/Exception/ExpiredTokenException.php b/src/Exception/ExpiredTokenException.php index 8fd3e46b..3780c286 100644 --- a/src/Exception/ExpiredTokenException.php +++ b/src/Exception/ExpiredTokenException.php @@ -31,7 +31,7 @@ class ExpiredTokenException extends \Exception { /** * {@inheritdoc} */ - public function __construct(string $token, int $time = 0, $sTime = 0, string $message = "The token has expired", int $code = 0, \Throwable $previous = NULL) { + public function __construct(string $token, int $time = 0, $sTime = 0, string $message = "The token has expired", int $code = 0, ?\Throwable $previous = NULL) { $this->token = $token; $this->time = $time; $this->sTime = $sTime; diff --git a/src/Exception/InvalidTokenException.php b/src/Exception/InvalidTokenException.php index 4591f82d..19a5df5e 100644 --- a/src/Exception/InvalidTokenException.php +++ b/src/Exception/InvalidTokenException.php @@ -24,7 +24,7 @@ class InvalidTokenException extends \Exception { /** * {@inheritdoc} */ - public function __construct(string $token, int $time = 0, string $message = "Invalid request token", int $code = 0, \Throwable $previous = NULL) { + public function __construct(string $token, int $time = 0, string $message = "Invalid request token", int $code = 0, ?\Throwable $previous = NULL) { $this->token = $token; $this->time = $time; diff --git a/src/Exception/StrictTokenException.php b/src/Exception/StrictTokenException.php index e6352187..39e9d8c9 100644 --- a/src/Exception/StrictTokenException.php +++ b/src/Exception/StrictTokenException.php @@ -31,7 +31,7 @@ class StrictTokenException extends \Exception { /** * {@inheritdoc} */ - public function __construct(string $token, $token_route = NULL, $expected_route = NULL, string $message = "The token routes do not match", int $code = 0, \Throwable $previous = NULL) { + public function __construct(string $token, $token_route = NULL, $expected_route = NULL, string $message = "The token routes do not match", int $code = 0, ?\Throwable $previous = NULL) { $this->token = $token; $this->tokenRoute = $token_route; $this->expectedRoute = $expected_route; diff --git a/src/Utility.php b/src/Utility.php index 44efaf51..ed57fa8b 100644 --- a/src/Utility.php +++ b/src/Utility.php @@ -45,7 +45,7 @@ public static function usesLanguagePathPrefixes() : bool { * @return string * The URL adjusted for multilingual settings. Defaults to current url. */ - public static function getUrl(string $url = NULL, string $langcode = NULL) : string { + public static function getUrl(?string $url = NULL, ?string $langcode = NULL) : string { // Default to current URL. if (!$url) { @@ -77,7 +77,7 @@ public static function getUrl(string $url = NULL, string $langcode = NULL) : str * @return string * The path prefix based on multilingual settings. Defaults to '/'. */ - public static function getPathPrefix(string $langcode = NULL) : string { + public static function getPathPrefix(?string $langcode = NULL) : string { // Always start with a slash. $prefix = '/'; @@ -200,7 +200,7 @@ public static function getSpecialPages() { * @return string * The markup with the page info. */ - public static function getPageInfo(array $urls = NULL) : string { + public static function getPageInfo(?array $urls = NULL) : string { try { // Only allow administrators and content editors access. $roles = ['administrator', 'content_editor', 'editor'];