Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PHP 8.2 #4085

Merged
merged 25 commits into from
Jan 30, 2024
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
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
parameters:
php_version:
description: 'PHP major.minor for DDev to use.'
default: '8.1'
default: '8.2'
type: string
dkan_recommended_branch:
description: 'Branch of getdkan/recommended-project to use.'
Expand Down Expand Up @@ -248,6 +248,11 @@ workflows:
parameters:
dkan_recommended_branch: [ '10.1.x-dev']
php_version: [ '8.1' ]
- phpunit:
matrix:
parameters:
dkan_recommended_branch: [ '10.1.x-dev']
php_version: [ '8.2' ]
- phpunit:
matrix:
parameters:
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"ext-json": "*",
"ezyang/htmlpurifier" : "^4.11",
"fmizzell/maquina": "^1.1.1",
"getdkan/contracts": "^1.0.0",
"getdkan/csv-parser": "^1.3.0",
"getdkan/file-fetcher" : "^5.0.2",
"getdkan/harvest": "^1.0.0",
"getdkan/contracts": "^1.1.2",
"getdkan/csv-parser": "^1.3.1",
"getdkan/file-fetcher" : "^5.0.3",
"getdkan/harvest": "^1.0.3",
"getdkan/procrastinator": "^5.0.0",
"getdkan/rooted-json-data": "^0.1",
"getdkan/rooted-json-data": "^0.2.1",
"guzzlehttp/guzzle" : "^6.5.8 || ^7.4.5",
"ilbee/csv-response": "^1.1.1",
"justinrainbow/json-schema": "^5.2",
Expand All @@ -32,7 +32,7 @@
"symfony/polyfill-php80": "^1.27"
},
"require-dev": {
"getdkan/mock-chain": "^1.3.0",
"getdkan/mock-chain": "^1.3.6",
"weitzman/drupal-test-traits": "^2.0.1",
"phpunit/phpunit": "^8.5.14 || ^9"
},
Expand Down
4 changes: 1 addition & 3 deletions modules/common/src/DataResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ public function getTableName() {
}

/**
* Inherited.
*
* @inheritdoc
* {@inheritDoc}
*/
#[\ReturnTypeWillChange]
public function jsonSerialize() {
Expand Down
27 changes: 25 additions & 2 deletions modules/common/src/Events/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,37 @@

namespace Drupal\common\Events;

use Drupal\Component\EventDispatcher\Event as SymfonyEvent;
use Drupal\Component\EventDispatcher\Event as DrupalEvent;

/**
* Custom DKAN extension of the Drupal Event class.
*
* @package Drupal\common\Events
*/
class Event extends SymfonyEvent {
class Event extends DrupalEvent {

/**
* Validation callback.
*
* @var \Closure|mixed|null
*/
private $validator;

/**
* Data.
*
* How this is used depends on the event we're responding to.
*
* @var mixed
*/
private $data;

/**
* Exception.
*
* @var \Exception|null
*/
private ?\Exception $exception;

/**
* Constructor.
Expand Down
5 changes: 3 additions & 2 deletions modules/common/src/Plugin/DkanApiDocsPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\common\Plugin;

use Drupal\common\Annotation\DkanApiDocs;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
Expand All @@ -26,10 +27,10 @@ class DkanApiDocsPluginManager extends DefaultPluginManager {
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
$subdir = 'Plugin/DkanApiDocs';
$plugin_interface = 'Drupal\common\Plugin\DkanApiDocsInterface';
$plugin_interface = DkanApiDocsInterface::class;

// The name of the annotation class that contains the plugin definition.
$plugin_definition_annotation_name = 'Drupal\common\Annotation\DkanApiDocs';
$plugin_definition_annotation_name = DkanApiDocs::class;

parent::__construct($subdir, $namespaces, $module_handler, $plugin_interface, $plugin_definition_annotation_name);

Expand Down
2 changes: 1 addition & 1 deletion modules/common/src/Storage/SelectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ private function addCondition($statementObj, $condition) {
$this->addMatchCondition($statementObj, $condition);
return;
}
$field = (isset($condition->collection) ? $condition->collection : $this->alias)
$field = ($condition->collection ?? $this->alias)
. '.'
. $condition->property;
$statementObj->condition($field, $condition->value, strtoupper($condition->operator));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
* @group dkan
* @group common
* @group kernel
* @group legacy
*
* @see @see \Drupal\Tests\common\Kernel\Storage\AbstractJobStoreFactoryTest
* @see \Drupal\Tests\common\Kernel\Storage\AbstractJobStoreFactoryTest
*/
class JobStoreFactoryTest extends KernelTestBase {

Expand Down
2 changes: 1 addition & 1 deletion modules/common/tests/src/Unit/Mocks/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
*
*/
class FileSystem extends DrupalFileSystem {
class FileSystem extends DrupalFilesystem {

/**
*
Expand Down
4 changes: 2 additions & 2 deletions modules/datastore/src/Controller/AbstractQueryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function create(ContainerInterface $container) {
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*
* @return Ilbee\CSVResponse\CSVResponse|Symfony\Component\HttpFoundation\JsonResponse
* @return \Ilbee\CSVResponse\CSVResponse|\Symfony\Component\HttpFoundation\JsonResponse
* The json or CSV response.
*/
public function query(Request $request) {
Expand Down Expand Up @@ -292,7 +292,7 @@ protected function getRowsLimit(): int {
* Normalized and type-casted JSON string.
*/
public static function getPayloadJson(Request $request, $schema = NULL) {
$schema = $schema ?? file_get_contents(__DIR__ . "/../../docs/query.json");
$schema ??= file_get_contents(__DIR__ . "/../../docs/query.json");
$payloadJson = static::getJson($request);
$payloadJson = static::fixTypes($payloadJson, $schema);
return $payloadJson;
Expand Down
15 changes: 11 additions & 4 deletions modules/datastore/src/Plugin/DkanApiDocs/DatastoreApiDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ class DatastoreApiDocs extends DkanApiDocsBase {
/**
* The DKAN metastore service.
*
* @var Drupal\metastore\Service
* @var \Drupal\metastore\Service
*/
private $metastore;

/**
* Import info service.
*
* @var \Drupal\datastore\Service\Info\ImportInfo
*/
private ImportInfo $importInfo;

/**
* Constructs a \Drupal\Component\Plugin\PluginBase object.
*
Expand All @@ -42,7 +49,7 @@ class DatastoreApiDocs extends DkanApiDocsBase {
* The module handler service.
* @param \Drupal\metastore\MetastoreService $metastore
* The module handler service.
* @param Drupal\datastore\Service\Info\ImportInfo $importInfo
* @param \Drupal\datastore\Service\Info\ImportInfo $importInfo
* Import info datastoer service.
*/
public function __construct(
Expand All @@ -62,7 +69,7 @@ public function __construct(
/**
* Container injection.
*
* @param \Drupal\common\Plugin\ContainerInterface $container
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The service container.
* @param array $configuration
* A configuration array containing information about the plugin instance.
Expand Down Expand Up @@ -100,7 +107,7 @@ public function spec() {
// Reformat definitions.
foreach ($querySchema["definitions"] as $key => $def) {
$schemaName = "datastoreQuery" . ucfirst($key);
$def["title"] = "Datastore Query: " . (isset($def["title"]) ? $def["title"] : $key);
$def["title"] = "Datastore Query: " . ($def["title"] ?? $key);
$spec["components"]["schemas"][$schemaName] = $def;
}
unset($querySchema["definitions"]);
Expand Down
2 changes: 1 addition & 1 deletion modules/datastore/src/Service/ImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ImportService {
*
* @see self::getImporter()
*/
private ?ImportJob $importJob;
private ?ImportJob $importJob = NULL;

/**
* Create a resource service instance.
Expand Down
11 changes: 9 additions & 2 deletions modules/datastore/src/SqlEndpoint/WebServiceApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class WebServiceApi implements ContainerInjectionInterface {
/**
* DKAN SQL Endpoint service.
*
* @var \Drupal\datastore\SqlEndpoint
* @var \Drupal\datastore\SqlEndpoint\DatastoreSqlEndpointService
*/
private $service;

Expand All @@ -36,10 +36,17 @@ class WebServiceApi implements ContainerInjectionInterface {
/**
* API request data.
*
* @var Symfony\Component\HttpFoundation\RequestStack
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
private $requestStack;

/**
* Metastore API response service.
*
* @var \Drupal\metastore\MetastoreApiResponse
*/
private MetastoreApiResponse $metastoreApiResponse;

/**
* {@inheritdoc}
*/
Expand Down
4 changes: 2 additions & 2 deletions modules/datastore/src/Storage/QueryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private function populateQuerySorts(Query $query) {
return;
}
foreach ($this->datastoreQuery->{"$.sorts"} as $sort) {
$query->sorts[] = (object) $this->resourceRename($sort);
$query->sorts[] = (object) self::resourceRename($sort);
}
}

Expand Down Expand Up @@ -257,7 +257,7 @@ private function populateQueryCondition($condition) {
$primaryAlias = $this->datastoreQuery->{"$.resources[0].alias"};
if (isset($condition["property"])) {
$return = (object) [
"collection" => isset($condition["resource"]) ? $condition["resource"] : $primaryAlias,
"collection" => $condition["resource"] ?? $primaryAlias,
"property" => $condition["property"],
"value" => $this->propertyConvert($condition["value"]),
];
Expand Down
25 changes: 22 additions & 3 deletions modules/datastore/src/Storage/TableSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,34 @@ class TableSummary implements \JsonSerializable {
*/
public $numOfRows;

/**
* Full text indexes.
*
* @var array|null
*/
private ?array $fulltextIndexes;

/**
* Constructor.
*
* @param int $numOfColumns
* Number of columns.
* @param array $columns
* Summary columns.
* @param array|null $indexes
* Summary indexes.
* @param array|null $fulltext_indexes
* Full text indexes.
* @param int $numOfRows
* Number of rows.
*/
public function __construct(
int $numOfColumns,
array $columns,
?array $indexes,
?array $fulltext_indexes,
int $numOfRows) {
int $numOfRows
) {
$this->numOfColumns = $numOfColumns;
$this->columns = $columns;
$this->indexes = $indexes;
Expand All @@ -54,9 +73,9 @@ public function __construct(
}

/**
* Inherited.
* Specify data which should be serialized to JSON.
*
* {@inheritdoc}
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class LocalizeQueueWorkerTest extends KernelTestBase {

const SOURCE_URL = 'https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv';
protected const SOURCE_URL = 'https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv';

/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ImportInfoTest extends KernelTestBase {
*/
const HOST = 'http://example.com';

const SOURCE_URL = 'https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv';
protected const SOURCE_URL = 'https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv';

public function testFileSize() {
$source_resource = new DataResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ResourceLocalizerTest extends KernelTestBase {
*/
const HOST = 'http://example.com';

const SOURCE_URL = 'https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv';
protected const SOURCE_URL = 'https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv';

public function testNoResourceFound() {
$service = $this->container->get('dkan.datastore.service.resource_localizer');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ public function primaryKey() { }

public function retrieve(string $id)
{
if (isset($this->storage[$id])) {
return $this->storage[$id];
}
return null;
return $this->storage[$id] ?? null;
}

public function retrieveAll(): array
Expand Down
8 changes: 4 additions & 4 deletions modules/dkan_js_frontend/dkan_js_frontend.module
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ function dkan_js_frontend_library_info_build() {
foreach(glob(\Drupal::root() . $js_path . '*.js') as $full_path) {
$basename = basename($full_path);
$libraries['dkan_js_frontend']['js'][$js_path . $basename] = [
"minified" => isset($minified) ? $minified : false,
"preprocess" => isset($preprocess) ? $preprocess : true,
"minified" => $minified ?? false,
"preprocess" => $preprocess ?? true,
];
}
foreach(glob(\Drupal::root() . $css_path . '*.css') as $full_path) {
$basename = basename($full_path);
$libraries['dkan_js_frontend']['css']['theme'][$css_path . $basename] = [
"minified" => isset($minified) ? $minified : false,
"preprocess" => isset($preprocess) ? $preprocess : true,
"minified" => $minified ?? false,
"preprocess" => $preprocess ?? true,
];
}
$libraries['dkan_js_frontend']['dependencies'] = [
Expand Down
Loading