Skip to content

Commit 50c7f8a

Browse files
author
slucero
committed
Issue #3293210 by slucero: Fix PHPCS, deprecations, and test failures to enable DrupalCI testing
1 parent 2f0d8c5 commit 50c7f8a

File tree

63 files changed

+1300
-892
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1300
-892
lines changed

composer.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@
1414
],
1515
"license": "MIT",
1616
"require": {
17-
"php": ">=7.1.3",
17+
"php": ">=7.4.0",
18+
"ext-json": "*",
1819
"swaggest/json-schema": "^0.12",
1920
"symfony/finder": "^3.4 || ^4.0",
2021
"symfony/yaml": "^3.4 || ^4.0"
2122
},
2223
"require-dev": {
23-
"drupal/core-recommended": "^8.8"
24-
},
25-
"config": {
26-
"platform": {
27-
"php": "7.1.3"
28-
}
24+
"drupal/core-recommended": "^9",
25+
"drupal/core-dev": "^9"
2926
},
3027
"extra": {
3128
"drush": {

modules/patternkit_media_library/patternkit_media_library.install

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function patternkit_media_library_requirements($phase) {
2323

2424
return $requirements;
2525
}
26+
2627
/**
2728
* Sets default value for new config item 'patternkit_media_library.settings'.
2829
*/
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
services:
22
patternkit.opener.jsonlibrary:
33
class: Drupal\patternkit_media_library\MediaLibraryJSONLibraryOpener
4-
arguments: ['@entity_type.manager']
4+
arguments: ['@entity_type.manager', '@file_url_generator']

modules/patternkit_media_library/src/Form/MediaLibrarySettingsForm.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
namespace Drupal\patternkit_media_library\Form;
44

5-
use Drupal\Core\Config\ConfigFactoryInterface;
6-
use Drupal\Core\Extension\ModuleHandlerInterface;
75
use Drupal\Core\Form\ConfigFormBase;
86
use Drupal\Core\Form\FormStateInterface;
9-
use Symfony\Component\DependencyInjection\ContainerInterface;
107

118
/**
129
* Settings form for configuring Patternkit's media library integration.
@@ -23,12 +20,12 @@ class MediaLibrarySettingsForm extends ConfigFormBase {
2320
/**
2421
* Implements buildForm().
2522
*
26-
* {@inheritDoc}
23+
* {@inheritdoc}
2724
*/
2825
public function buildForm(array $form, FormStateInterface $form_state) :array {
2926
$config = $this->config(static::SETTINGS);
3027

31-
$form['use_styles'] = array(
28+
$form['use_styles'] = [
3229
'#type' => 'checkbox',
3330
'#title' => t('Use bundled styles for the media library modal window'),
3431
'#description' => t('If checked, then Patternkit will load some styles for
@@ -37,20 +34,20 @@ public function buildForm(array $form, FormStateInterface $form_state) :array {
3734
Media Library Theme Reset</a>, so enable that module if you want to use
3835
these styles.'),
3936
'#default_value' => $config->get('use_styles') ?? FALSE,
40-
);
37+
];
4138

4239
return parent::buildForm($form, $form_state);
4340
}
4441

4542
/**
46-
* {@inheritDoc}
43+
* {@inheritdoc}
4744
*/
4845
protected function getEditableConfigNames() :array {
4946
return [static::SETTINGS];
5047
}
5148

5249
/**
53-
* {@inheritDoc}
50+
* {@inheritdoc}
5451
*/
5552
public function getFormId() :string {
5653
return 'patternkit_media_library_settings_form';
@@ -59,7 +56,7 @@ public function getFormId() :string {
5956
/**
6057
* {@inheritdoc}
6158
*/
62-
public function submitForm(array &$form, FormStateInterface $form_state) {
59+
public function submitForm(array &$form, FormStateInterface $form_state): void {
6360
$form_values = $form_state->getValues();
6461
$config = $this->config(self::SETTINGS);
6562

modules/patternkit_media_library/src/MediaLibraryJSONLibraryOpener.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Drupal\Core\Access\AccessResult;
66
use Drupal\Core\Ajax\AjaxResponse;
77
use Drupal\Core\Entity\EntityTypeManagerInterface;
8+
use Drupal\Core\File\FileUrlGeneratorInterface;
89
use Drupal\Core\Session\AccountInterface;
910
use Drupal\media_library\MediaLibraryOpenerInterface;
1011
use Drupal\media_library\MediaLibraryState;
@@ -22,14 +23,24 @@ class MediaLibraryJSONLibraryOpener implements MediaLibraryOpenerInterface {
2223
*/
2324
protected $entityTypeManager;
2425

26+
/**
27+
* The file url generator service.
28+
*
29+
* @var \Drupal\Core\File\FileUrlGeneratorInterface
30+
*/
31+
protected $fileUrlGenerator;
32+
2533
/**
2634
* MediaLibraryFieldWidgetOpener constructor.
2735
*
2836
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
2937
* The entity type manager.
38+
* @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
39+
* The file url generator service.
3040
*/
31-
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
41+
public function __construct(EntityTypeManagerInterface $entity_type_manager, FileUrlGeneratorInterface $file_url_generator) {
3242
$this->entityTypeManager = $entity_type_manager;
43+
$this->fileUrlGenerator = $file_url_generator;
3344
}
3445

3546
/**
@@ -71,7 +82,7 @@ public function getSelectionResponse(MediaLibraryState $state, array $selected_i
7182
$url = $file->toUrl()->setAbsolute(FALSE);
7283
}
7384
elseif ($file->access('download')) {
74-
$url = file_url_transform_relative(file_create_url($file->getFileUri()));
85+
$url = $this->fileUrlGenerator->generateString($file->getFileUri());
7586
}
7687
else {
7788
$url = $file->label();

patternkit.info.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ name: Patternkit
22
description: Adds Patternkit patterns as blocks.
33
type: module
44
package: Presentation Framework
5-
core: 8.x
6-
core_version_requirement: ^8 || ^9
5+
core_version_requirement: ^9
76
configure: patternkit.settings
87
dependencies:
98
- drupal:block_content
109
- drupal:ckeditor
11-
php: 7.3
10+
php: 7.4

patternkit.install

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use Drupal\views\EntityViewsData;
2222
/**
2323
* Implements hook_requirements().
2424
*/
25-
function patternkit_requirements($phase) {
25+
function patternkit_requirements($phase): array {
2626
$requirements = [];
2727

2828
if (version_compare(\Drupal::VERSION, 8.9, '<')) {
@@ -163,7 +163,8 @@ function patternkit_update_8003(&$sandbox) {
163163
*/
164164
function patternkit_update_8004(&$sandbox) {
165165
$config_key = 'patternkit.settings';
166-
$source = new FileStorage(drupal_get_path('module', 'patternkit') . '/config/install');
166+
$patternkit_module_path = \Drupal::service('extension.list.module')->getPath('patternkit');
167+
$source = new FileStorage($patternkit_module_path . '/config/install');
167168
$config_install = $source->read($config_key);
168169
$config_current = \Drupal::configFactory()->getEditable($config_key);
169170

patternkit.module

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function patternkit_help($route_name, RouteMatchInterface $route_match) {
3131
<dd>Users with the <em>Administer blocks</em> permission can add Patternkit blocks to the site block layout.</dd>
3232
</dl>
3333
HTML;
34+
// phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
3435
return t($output, [
3536
':patternkit_example' => $patternkit_example,
3637
':patternkit_media_library' => $patternkit_media_library,
@@ -44,7 +45,7 @@ HTML;
4445
/**
4546
* Implements hook_theme().
4647
*/
47-
function patternkit_theme($existing, $type, $theme, $path) {
48+
function patternkit_theme($existing, $type, $theme, $path): array {
4849
return [
4950
'patternkit_add_list' => [
5051
'variables' => ['content' => NULL],

patternkit.services.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ services:
88
- { name: path_processor_inbound, priority: 200 }
99
patternkit.asset.library:
1010
class: Drupal\patternkit\Asset\Library
11-
arguments: ['@cache.discovery', '@config.factory', '@plugin.manager.library.pattern', '@lock', '@module_handler', '@app.root', '@theme.manager']
11+
arguments: ['@cache.discovery', '@config.factory', '@plugin.manager.library.pattern', '@lock', '@module_handler', '%app.root%', '@theme.manager', '@extension.path.resolver']
12+
patternkit.asset.library.parser.base:
13+
abstract: true
14+
arguments: [ '@serialization.json', '%app.root%', '@module_handler', '@theme.manager', '@stream_wrapper_manager', '@library.libraries_directory_file_finder', '@extension.path.resolver' ]
1215
patternkit.asset.library.parser.file:
16+
parent: patternkit.asset.library.parser.base
1317
class: Drupal\patternkit\Asset\PatternLibraryParser\FilePatternLibraryParser
14-
arguments: ['@serialization.json', '@app.root', '@module_handler', '@theme.manager', '@stream_wrapper_manager']
1518
patternkit.asset.library.parser.json:
19+
parent: patternkit.asset.library.parser.base
1620
class: Drupal\patternkit\Asset\PatternLibraryParser\JSONPatternLibraryParser
17-
arguments: ['@serialization.json', '@app.root', '@module_handler', '@theme.manager', '@stream_wrapper_manager']
1821
patternkit.asset.library.parser.twig:
22+
parent: patternkit.asset.library.parser.base
1923
class: Drupal\patternkit\Asset\PatternLibraryParser\TwigPatternLibraryParser
20-
arguments: ['@serialization.json', '@app.root', '@module_handler', '@theme.manager', '@stream_wrapper_manager']
2124
plugin.manager.library.pattern:
2225
class: Drupal\patternkit\PatternLibraryPluginManager
2326
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler', '@theme_handler']

src/AJAX/PatternkitEditorUpdateCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct($selector, $value) {
4646
}
4747

4848
/**
49-
* {@inheritDoc}
49+
* {@inheritdoc}
5050
*/
5151
public function render(): array {
5252
return [

src/Annotation/PatternLibrary.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PatternLibrary extends Plugin {
2828
*
2929
* @var string
3030
*/
31-
public $id;
31+
public string $id;
3232

3333
/**
3434
* The human-readable name.
@@ -37,7 +37,7 @@ class PatternLibrary extends Plugin {
3737
*
3838
* @ingroup plugin_translatable
3939
*/
40-
public $label;
40+
public string $label;
4141

4242
/**
4343
* An optional description for advanced layouts.
@@ -51,7 +51,7 @@ class PatternLibrary extends Plugin {
5151
*
5252
* @ingroup plugin_translatable
5353
*/
54-
public $description;
54+
public string $description;
5555

5656
/**
5757
* The human-readable category.
@@ -62,7 +62,7 @@ class PatternLibrary extends Plugin {
6262
*
6363
* @ingroup plugin_translatable
6464
*/
65-
public $category;
65+
public string $category;
6666

6767
/**
6868
* The layout plugin class.
@@ -72,12 +72,12 @@ class PatternLibrary extends Plugin {
7272
*
7373
* @var string
7474
*/
75-
public $class = PatternLibraryPluginDefault::class;
75+
public string $class = PatternLibraryPluginDefault::class;
7676

7777
/**
7878
* {@inheritdoc}
7979
*/
80-
public function get() {
80+
public function get(): PatternLibraryPluginDefinition {
8181
return new PatternLibraryPluginDefinition($this->definition);
8282
}
8383

0 commit comments

Comments
 (0)