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

Update to PHP_CodeSniffer version 3.6 via CC beta channel #3717

Merged
merged 11 commits into from
Mar 21, 2022
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: 2
plugins:
phpcodesniffer:
enabled: true
channel: beta
config:
standard: "Drupal,DrupalPractice"
exclude_patterns:
Expand Down
2 changes: 1 addition & 1 deletion dkan.module
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

function dkan_update_8001() {
/* @var $metastoreService \Drupal\metastore\Service */
/** @var $metastoreService \Drupal\metastore\Service */
$metastoreService = \Drupal::service('dkan.metastore.service');
foreach ($metastoreService->getAll('dataset') as $dataset) {
$metastoreService->publish('dataset', $dataset->identifier);
Expand Down
2 changes: 1 addition & 1 deletion modules/common/src/CacheableResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait CacheableResponseTrait {
/**
* Adds cache headers to the response.
*
* TODO: implement more flexible caching and move the code out of the trait.
* @todo implement more flexible caching and move the code out of the trait.
*
* @param \Symfony\Component\HttpFoundation\Response $response
* Symfony response.
Expand Down
5 changes: 1 addition & 4 deletions modules/common/src/Events/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
use Drupal\Component\EventDispatcher\Event as SymfonyEvent;

/**
* Class Event.
* Custom DKAN extension of the Drupal Event class.
*
* @package Drupal\common\Events
*/
class Event extends SymfonyEvent {
private $data;
private $exception;
private $validator;

/**
* Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\common\Exception;

/**
* Class DataNodeLifeCycleEntityValidationException.
* Class Metastore item object validation exception.
*/
class DataNodeLifeCycleEntityValidationException extends \Exception {

Expand Down
15 changes: 13 additions & 2 deletions modules/common/src/FileFetcher/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@
use FileFetcher\FileFetcher;

/**
* FileFetcher Factory.
* File fetcher Factory.
*/
class Factory implements FactoryInterface {

/**
* Job store factory service.
*
* @var \Drupal\common\Storage\JobStoreFactory
*/
private $factory;

/**
* Default file fetcher config.
*
* @var array
*/
private $configDefault = [
'keep_original_filename' => TRUE,
];
Expand All @@ -37,7 +48,7 @@ public function getInstance(string $identifier, array $config = []) {
* Private.
*/
private function getFileFetcherJobStore() {
/* @var \Drupal\common\Storage\JobStoreFactory $jobStoreFactory */
/** @var \Drupal\common\Storage\JobStoreFactory $jobStoreFactory */
$jobStoreFactory = $this->factory;
return $jobStoreFactory->getInstance(FileFetcher::class);
}
Expand Down
7 changes: 6 additions & 1 deletion modules/common/src/LoggerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Psr\Log\LogLevel;

/**
* LoggerTrait.
* DKAN logger channel trait.
*/
trait LoggerTrait {

Expand All @@ -27,6 +27,11 @@ trait LoggerTrait {
*/
private $loggerService;

/**
* Whether to enable debug messages logged by the debug method.
*
* @var bool
*/
private $debug = FALSE;

/**
Expand Down
6 changes: 6 additions & 0 deletions modules/common/src/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class Resource implements \JsonSerializable {
* @var int
*/
private $version;

/**
* Resource object checksum.
*
* @var string
*/
private $checksum;

/**
Expand Down
5 changes: 5 additions & 0 deletions modules/common/src/Storage/JobStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
*/
class JobStore extends AbstractDatabaseTable {

/**
* Procrastinator job class.
*
* @var string
*/
private $jobClass;

/**
Expand Down
14 changes: 13 additions & 1 deletion modules/common/src/Storage/JobStoreFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@
use Drupal\Core\Database\Connection;

/**
* Class JobStoreFactory.
* DKAN JobStore Factory.
*/
class JobStoreFactory implements FactoryInterface {

/**
* JobStore instances keyed by unique identifiers.
*
* @var \Drupal\common\Storage\JobStore[]
*/
private $instances = [];

/**
* Drupal database connection.
*
* @var \Drupal\Core\Database\Connection
*/
private $connection;

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/common/src/Storage/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Contracts\LimiterInterface;

/**
* Query class.
* DKAN API Query data object.
*/
class Query implements
SorterInterface,
Expand Down
7 changes: 5 additions & 2 deletions modules/common/src/StreamWrapper/DkanStreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,29 @@
use Drupal\Core\StreamWrapper\LocalReadOnlyStream;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Core\Url;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
* DKAN stream wrapper for creating domain-agnostic URLs to DKAN API endpoints.
*/
class DkanStreamWrapper extends LocalReadOnlyStream implements StreamWrapperInterface {

use StringTranslationTrait;

const DKAN_API_VERSION = 1;

/**
* {@inheritdoc}
*/
public function getName() {
return t('DKAN documents');
return $this->t('DKAN documents');
}

/**
* {@inheritdoc}
*/
public function getDescription() {
return t('Simple way to request DKAN schemas and other documents as URIs.');
return $this->t('Simple way to request DKAN schemas and other documents as URIs.');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/common/src/UrlHostTokenResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\common;

/**
* UrlHostTokenResolver.
* Convert between local file paths and public file URLs.
*
* @todo Convert to service with Dependency Injection.
*/
Expand Down
13 changes: 12 additions & 1 deletion modules/common/src/Util/DrupalFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Class DrupalFiles.
* Provide custom DKAN file storage system functionality.
*
* It wraps a few file related Drupal functions, it provides
* a mechanism to bring remote files locally, and to move local files to a
Expand All @@ -18,7 +18,18 @@
*/
class DrupalFiles implements ContainerInjectionInterface {

/**
* Drupal file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
private $filesystem;

/**
* Drupal stream wrapper manager.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManager
*/
private $streamWrapperManager;

/**
Expand Down
14 changes: 13 additions & 1 deletion modules/common/src/Util/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
namespace Drupal\common\Util;

/**
* Class Timer.
* Timer utility object.
*/
class Timer {

/**
* Start times in microseconds.
*
* @var float[]
*/
private $starts = [];

/**
* End times in microseconds.
*
* @var float[]
*/
private $ends = [];

/**
Expand Down
12 changes: 6 additions & 6 deletions modules/common/tests/src/Traits/CleanUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait CleanUp {
*
*/
private function removeHarvests() {
/* @var \Drupal\harvest\Service $service */
/** @var \Drupal\harvest\Service $service */
$service = \Drupal::service('dkan.harvest.service');
foreach ($service->getAllHarvestIds() as $id) {
$service->deregisterHarvest($id);
Expand All @@ -35,7 +35,7 @@ private function removeAllNodes() {
*
*/
private function removeAllMappedFiles() {
/* @var \Drupal\metastore\Storage\ResourceMapperDatabaseTable $filemappertable */
/** @var \Drupal\metastore\Storage\ResourceMapperDatabaseTable $filemappertable */
$filemappertable = \Drupal::service('dkan.metastore.resource_mapper_database_table');
foreach ($filemappertable->retrieveAll() as $id) {
$filemappertable->remove($id);
Expand All @@ -46,10 +46,10 @@ private function removeAllMappedFiles() {
*
*/
private function removeAllFileFetchingJobs() {
/* @var \Drupal\common\Storage\JobStoreFactory $jobStoreFactory */
/** @var \Drupal\common\Storage\JobStoreFactory $jobStoreFactory */
$jobStoreFactory = \Drupal::service('dkan.common.job_store');

/* @var \Drupal\common\Storage\JobStore $jobStore */
/** @var \Drupal\common\Storage\JobStore $jobStore */
$jobStore = $jobStoreFactory->getInstance(FileFetcher::class);
foreach ($jobStore->retrieveAll() as $id) {
$jobStore->remove($id);
Expand All @@ -62,7 +62,7 @@ private function removeAllFileFetchingJobs() {
private function flushQueues() {
$dkanQueues = ['orphan_reference_processor', 'datastore_import', 'resource_purger'];
foreach ($dkanQueues as $queueName) {
/* @var \Drupal\Core\Queue\QueueFactory $queueFactory */
/** @var \Drupal\Core\Queue\QueueFactory $queueFactory */
$queueFactory = \Drupal::service('queue');
$queue = $queueFactory->get($queueName);
$queue->deleteQueue();
Expand All @@ -87,7 +87,7 @@ private function removeFiles() {
*
*/
private function removeDatastoreTables() {
/* @var \Drupal\Core\Database\Connection $connection */
/** @var \Drupal\Core\Database\Connection $connection */
$connection = \Drupal::service('database');
$tables = $connection->schema()->findTables("datastore_%");
foreach ($tables as $table) {
Expand Down
9 changes: 7 additions & 2 deletions modules/datastore/src/Commands/PurgeCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public function __construct(ResourcePurger $resourcePurger) {
*
* @command dkan:datastore:purge
*/
public function purge(string $csvUuids, array $options = ['deferred' => FALSE, 'prior' => FALSE]) {
public function purge(
string $csvUuids,
array $options = ['deferred' => FALSE, 'prior' => FALSE]
) {
try {
$uuids = StringUtils::csvToArray($csvUuids);
$this->resourcePurger->schedule($uuids, $options['deferred'], $options['prior']);
Expand Down Expand Up @@ -79,7 +82,9 @@ public function purge(string $csvUuids, array $options = ['deferred' => FALSE, '
*
* @command dkan:datastore:purge-all
*/
public function purgeAll(array $options = ['deferred' => FALSE, 'prior' => FALSE]) {
public function purgeAll(
array $options = ['deferred' => FALSE, 'prior' => FALSE]
) {
try {
$this->resourcePurger->scheduleAllUuids($options['deferred'], $options['prior']);
$messagePrefix = $options['deferred'] ? 'Queued the purging of' : 'Purged';
Expand Down
6 changes: 0 additions & 6 deletions modules/datastore/src/Drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public function __construct(
*
* @todo pass configurable options for csv delimiter, quite, and escape characters.
* @command dkan:datastore:import
* @aliases dkan-datastore:import
* @deprecated dkan-datastore:import is deprecated and will be removed in a future Dkan release. Use dkan:datastore:import instead.
*/
public function import($uuid, $deferred = FALSE) {

Expand Down Expand Up @@ -90,8 +88,6 @@ public function import($uuid, $deferred = FALSE) {
* @options uuid-only Only the list of uuids.
*
* @command dkan:datastore:list
* @aliases dkan-datastore:list
* @deprecated dkan-datastore:list is deprecated and will be removed in a future Dkan release. Use dkan:datastore:list instead.
*/
public function list($options = [
'format' => 'table',
Expand Down Expand Up @@ -147,8 +143,6 @@ private function createRow($uuid, $item) {
* The uuid of a dataset resource.
*
* @command dkan:datastore:drop
* @aliases dkan-datastore:drop
* @deprecated dkan-datastore:drop is deprecated and will be removed in a future Dkan release. Use dkan:datastore:drop instead.
*/
public function drop($uuid) {
try {
Expand Down
2 changes: 1 addition & 1 deletion modules/datastore/src/Form/ResourceSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Drupal\Core\Form\FormStateInterface;

/**
* Class ResourceSettingsForm.
* DKAN resource settings form.
*
* @package Drupal\datastore\Form
* @codeCoverageIgnore
Expand Down
2 changes: 1 addition & 1 deletion modules/datastore/src/Service/DatastoreQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use RootedData\RootedJsonData;

/**
* DatastoreQuery.
* Datastore query data object.
*/
class DatastoreQuery extends RootedJsonData {

Expand Down
17 changes: 17 additions & 0 deletions modules/datastore/src/Service/Factory/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@
* @codeCoverageIgnore
*/
class Import implements ImportFactoryInterface {

/**
* Job store factory.
*
* @var \Drupal\common\Storage\JobStoreFactory
*/
private $jobStoreFactory;

/**
* Database table factory.
*
* @var \Drupal\datastore\Storage\DatabaseTableFactory
*/
private $databaseTableFactory;

/**
* Import services.
*
* @var \Drupal\datastore\Service\Import[]
*/
private $services = [];

/**
Expand Down
Loading