Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# 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
run: phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,yml .

phpunit:
runs-on: ubuntu-latest
container: quantcdn/drupal-ci:9.4.x-dev
container: quantcdn/drupal-ci:11.0.x-dev

services:
mariadb:
image: mariadb:10.11
ports:
- 3306:3306
env:
MYSQL_DATABASE: drupal9
MYSQL_DATABASE: drupal
MYSQL_ROOT_PASSWORD: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_api/src/Client/QuantClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_api/src/Client/QuantClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 7 additions & 6 deletions modules/quant_api/tests/src/Unit/QuantClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_search/src/Form/ConfirmIndexClearForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/QuantNodeViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Event/ConfigFormEventBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Event/ConfigFormEventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ExpiredTokenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidTokenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/StrictTokenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 = '/';
Expand Down Expand Up @@ -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'];
Expand Down