diff --git a/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserText.php b/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserText.php index c057d38cc5d06b1ab4b7dc4313b23f418ec48a3c..0035ec13766428a81a935bae2f53e0febb32db2d 100644 --- a/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserText.php +++ b/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserText.php @@ -23,7 +23,7 @@ class ParagraphsDemoUserText extends ParagraphsConversionBase { /** * {@inheritdoc} */ - public function convert(array $settings, ParagraphInterface $original_paragraph, array $converted_paragraphs = NULL) { + public function convert(array $settings, ParagraphInterface $original_paragraph, ?array $converted_paragraphs = NULL) { $username = "Empty user field"; if ($original_paragraph->get('field_user_demo')->entity) { $username = $original_paragraph->get('field_user_demo')->entity->label(); diff --git a/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserToTextUser.php b/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserToTextUser.php index 533e892948ec3379888abe848638f64a6aec8e77..812a224cb048cafbfeddca7487df92a789502e5d 100644 --- a/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserToTextUser.php +++ b/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserToTextUser.php @@ -22,7 +22,7 @@ class ParagraphsDemoUserToTextUser extends ParagraphsConversionBase { /** * {@inheritdoc} */ - public function convert(array $settings, ParagraphInterface $original_paragraph, array $converted_paragraphs = NULL) { + public function convert(array $settings, ParagraphInterface $original_paragraph, ?array $converted_paragraphs = NULL) { $username = "Empty user field"; $user = NULL; if ($original_paragraph->get('field_user_demo')->entity) { diff --git a/modules/paragraphs_type_permissions/paragraphs_type_permissions.module b/modules/paragraphs_type_permissions/paragraphs_type_permissions.module index e3757416f9b1998f59fd96896aec3f913efcf5f3..216cd2e9cea9369eb674eabb71bc8383b53c60e0 100644 --- a/modules/paragraphs_type_permissions/paragraphs_type_permissions.module +++ b/modules/paragraphs_type_permissions/paragraphs_type_permissions.module @@ -69,7 +69,7 @@ function paragraphs_type_permissions_paragraph_access(ParagraphInterface $entity /** * Implements hook_ENTITY_TYPE_create_access() for entity type "paragraph". */ -function paragraphs_type_permissions_paragraph_create_access(AccountInterface $account = NULL, array $context = array(), $entity_bundle = NULL) { +function paragraphs_type_permissions_paragraph_create_access(?AccountInterface $account = NULL, array $context = array(), $entity_bundle = NULL) { $permissions = &drupal_static(__FUNCTION__, array()); // Set static cache id to use the type machine name. diff --git a/src/ParagraphsConversionBase.php b/src/ParagraphsConversionBase.php index 890aa2daff79fb2d62836472446b678c96f00a86..45fea15da9b8e380a8dedae53414b3263b2dc6b3 100644 --- a/src/ParagraphsConversionBase.php +++ b/src/ParagraphsConversionBase.php @@ -97,14 +97,14 @@ abstract class ParagraphsConversionBase extends PluginBase implements Paragraphs /** * {@inheritdoc} */ - public function convert(array $settings, ParagraphInterface $original_paragraph, array $converted_paragraph = NULL) { + public function convert(array $settings, ParagraphInterface $original_paragraph, ?array $converted_paragraph = NULL) { return NULL; } /** * {@inheritdoc} */ - public function supports(ParagraphInterface $paragraph, array $parent_allowed_types = NULL) { + public function supports(ParagraphInterface $paragraph, ?array $parent_allowed_types = NULL) { return $paragraph->getType() == $this->getPluginDefinition()['source_type']; } diff --git a/src/ParagraphsConversionInterface.php b/src/ParagraphsConversionInterface.php index 6fae7fa33d7b442d2de861fce4d5208a24229ed3..cc1954fa6de4b9a62415d052b05efd8ba93a5cd8 100644 --- a/src/ParagraphsConversionInterface.php +++ b/src/ParagraphsConversionInterface.php @@ -61,7 +61,7 @@ interface ParagraphsConversionInterface extends PluginFormInterface, Configurabl * @param array $converted_paragraphs * (optional) The array of converted paragraphs. */ - public function convert(array $settings, ParagraphInterface $original_paragraph, array $converted_paragraphs = NULL); + public function convert(array $settings, ParagraphInterface $original_paragraph, ?array $converted_paragraphs = NULL); /** * Check if the current plugin supports conversion for a paragraph. @@ -74,6 +74,6 @@ interface ParagraphsConversionInterface extends PluginFormInterface, Configurabl * @param array $parent_allowed_types * (optional) The allowed paragraph types on the parent field. */ - public function supports(ParagraphInterface $paragraph, array $parent_allowed_types = NULL); + public function supports(ParagraphInterface $paragraph, ?array $parent_allowed_types = NULL); } diff --git a/src/ParagraphsConversionManager.php b/src/ParagraphsConversionManager.php index 2317237119983e17dd4668597d17d8826e333b17..96f55026b630a05553018be584d94abf726701c4 100644 --- a/src/ParagraphsConversionManager.php +++ b/src/ParagraphsConversionManager.php @@ -66,7 +66,7 @@ class ParagraphsConversionManager extends DefaultPluginManager { * @return array * The applicable conversion plugins. */ - public function getApplicableDefinitions(ParagraphInterface $paragraph, array $allowed_types = NULL) { + public function getApplicableDefinitions(ParagraphInterface $paragraph, ?array $allowed_types = NULL) { $definitions = $this->getDefinitions(); $applicable_plugins = []; foreach ($definitions as $key => $definition) { @@ -92,7 +92,7 @@ class ParagraphsConversionManager extends DefaultPluginManager { * @return bool * TRUE if the plugin is applicable. Otherwise, FALSE. */ - protected function isApplicable(ParagraphsConversionInterface $plugin, ParagraphInterface $paragraph, array $allowed_types = NULL) { + protected function isApplicable(ParagraphsConversionInterface $plugin, ParagraphInterface $paragraph, ?array $allowed_types = NULL) { if (!$plugin->supports($paragraph, $allowed_types)) { return FALSE; } @@ -135,7 +135,7 @@ class ParagraphsConversionManager extends DefaultPluginManager { * @return bool * Whether the current paragraph supports conversion. */ - public function supportsConversion(ParagraphInterface $paragraph, array $allowed_types = NULL) { + public function supportsConversion(ParagraphInterface $paragraph, ?array $allowed_types = NULL) { $definitions = $this->getDefinitions(); foreach ($definitions as $key => $definition) { /** @var \Drupal\paragraphs\ParagraphsConversionInterface $plugin */ diff --git a/src/Plugin/Field/FieldWidget/ParagraphsWidget.php b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php index 42f823189cbfd64e245efbc30a1c534572d28455..c40afea6667c7080231348ccfaaa0648a8dfa534 100644 --- a/src/Plugin/Field/FieldWidget/ParagraphsWidget.php +++ b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php @@ -1250,7 +1250,7 @@ class ParagraphsWidget extends WidgetBase { * - label: The label of the paragraph type. * - weight: The weight of the paragraph type. */ - public function getAllowedTypes(FieldDefinitionInterface $field_definition = NULL) { + public function getAllowedTypes(?FieldDefinitionInterface $field_definition = NULL) { $return_bundles = array(); /** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface $selection_manager */ @@ -1533,7 +1533,7 @@ class ParagraphsWidget extends WidgetBase { * @return \Drupal\paragraphs\Entity\Paragraph[] * Child paragraphs. */ - protected function getChildParagraphs(FormStateInterface $form_state, $field_name, ParagraphInterface $paragraph = NULL, array $array_parents = []) { + protected function getChildParagraphs(FormStateInterface $form_state, $field_name, ?ParagraphInterface $paragraph = NULL, array $array_parents = []) { // Convert the parents structure which only includes field names and delta // to the full storage array key which includes a prefix and a subform. @@ -1592,7 +1592,7 @@ class ParagraphsWidget extends WidgetBase { * @return array * The built form structure. */ - protected function buildNestedParagraphsFoDragDrop(FormStateInterface $form_state, ParagraphInterface $paragraph = NULL, array $array_parents = []) { + protected function buildNestedParagraphsFoDragDrop(FormStateInterface $form_state, ?ParagraphInterface $paragraph = NULL, array $array_parents = []) { // Look for nested elements. $elements = []; $field_definitions = []; @@ -2349,7 +2349,7 @@ class ParagraphsWidget extends WidgetBase { $new_field_storage[$field_name] = $clear_paragraphs($new_field_storage[$field_name]); } - $reorder_paragraphs = function ($reorder_values, $parents = [], FieldableEntityInterface $parent_entity = NULL) use ($complete_field_storage, &$new_field_storage, &$reorder_paragraphs) { + $reorder_paragraphs = function ($reorder_values, $parents = [], ?FieldableEntityInterface $parent_entity = NULL) use ($complete_field_storage, &$new_field_storage, &$reorder_paragraphs) { foreach ($reorder_values as $field_name => $values) { foreach ($values['list'] as $delta => $item_values) { $old_keys = array_merge( diff --git a/src/Plugin/migrate/process/ParagraphsLookup.php b/src/Plugin/migrate/process/ParagraphsLookup.php index f9474810d8b5498aeb81259eae913478d94d1c41..1dc1852513b596d1ab5f5cd611509094a63b77d8 100644 --- a/src/Plugin/migrate/process/ParagraphsLookup.php +++ b/src/Plugin/migrate/process/ParagraphsLookup.php @@ -77,7 +77,7 @@ class ParagraphsLookup extends MigrationLookup { /** * {@inheritdoc} */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, ?MigrationInterface $migration = NULL) { return new static( $configuration, $plugin_id, diff --git a/tests/modules/paragraphs_test/src/Plugin/paragraphs/Conversion/ParagraphsTestTextToTextImage.php b/tests/modules/paragraphs_test/src/Plugin/paragraphs/Conversion/ParagraphsTestTextToTextImage.php index cb94712f09e1ad32b37c2a24f52ddf19d8dc08b4..2d48ef6e768003a9cde52c363311c3054503d8d7 100644 --- a/tests/modules/paragraphs_test/src/Plugin/paragraphs/Conversion/ParagraphsTestTextToTextImage.php +++ b/tests/modules/paragraphs_test/src/Plugin/paragraphs/Conversion/ParagraphsTestTextToTextImage.php @@ -21,7 +21,7 @@ class ParagraphsTestTextToTextImage extends ParagraphsConversionBase { /** * {@inheritdoc} */ - public function submitConversion(array $settings, ParagraphInterface $original_paragraph, array $converted_paragraphs = NULL) { + public function submitConversion(array $settings, ParagraphInterface $original_paragraph, ?array $converted_paragraphs = NULL) { $text = $original_paragraph->get('field_text_demo')->value; return [ [