diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index 112c18567677101f72d0a97c0439e4c9df4ec3e9..9968def98e342b8ebce8a731310745ea5ae4e0fb 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -31380,18 +31380,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/options/src/Hook/OptionsHooks.php', ]; -$ignoreErrors[] = [ - // identifier: return.missing - 'message' => '#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListFloatItem\\:\\:validateAllowedValue\\(\\) should return string but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php', -]; -$ignoreErrors[] = [ - // identifier: return.missing - 'message' => '#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListIntegerItem\\:\\:validateAllowedValue\\(\\) should return string but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php', -]; $ignoreErrors[] = [ // identifier: property.notFound 'message' => '#^Access to an undefined property Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListItemBase\\:\\:\\$value\\.$#', @@ -31428,24 +31416,12 @@ 'count' => 1, 'path' => __DIR__ . '/modules/options/src/Plugin/Field/FieldType/ListItemBase.php', ]; -$ignoreErrors[] = [ - // identifier: return.missing - 'message' => '#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListItemBase\\:\\:validateAllowedValue\\(\\) should return string but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/options/src/Plugin/Field/FieldType/ListItemBase.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListItemBase\\:\\:validateAllowedValues\\(\\) has no return type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/modules/options/src/Plugin/Field/FieldType/ListItemBase.php', ]; -$ignoreErrors[] = [ - // identifier: return.missing - 'message' => '#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListStringItem\\:\\:validateAllowedValue\\(\\) should return string but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/options/src/Plugin/Field/FieldType/ListStringItem.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\options\\\\Plugin\\\\views\\\\argument\\\\NumberListField\\:\\:buildOptionsForm\\(\\) has no return type specified\\.$#', diff --git a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php index 7467915ea53f1fed668abe7e5624a3ffd16907e2..d95bbf032702771a866e3caa557ef1301ad8702f 100644 --- a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php +++ b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php @@ -124,6 +124,7 @@ protected function handlePluginNotFound($plugin_id, array $configuration) { * @throws \BadMethodCallException * If the method is not implemented in the concrete plugin manager class. */ + // phpcs:ignore Drupal.Commenting.FunctionComment.InvalidNoReturn protected function getFallbackPluginId($plugin_id, array $configuration = []) { throw new \BadMethodCallException(static::class . '::getFallbackPluginId() not implemented.'); } diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 7a9de46a7d410ebc792743bf136adedbfd5f0b7c..830d923b29365c99716433bf41d34c4afdf7f21c 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -1110,6 +1110,7 @@ public function transactionManager(): TransactionManagerInterface { * @throws \LogicException * If the transaction manager is undefined or unavailable. */ + // phpcs:ignore Drupal.Commenting.FunctionComment.InvalidNoReturn protected function driverTransactionManager(): TransactionManagerInterface { throw new \LogicException('The database driver has no TransactionManager implementation'); } diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php index 7b5d585de940f8fb32c46de2fdf24ac47310d517..a22a449a10a0c185aefe88cb0634f5182ad8f81d 100644 --- a/core/lib/Drupal/Core/Database/Schema.php +++ b/core/lib/Drupal/Core/Database/Schema.php @@ -547,6 +547,7 @@ abstract public function dropIndex($table, $name); * @throws \RuntimeException * If the driver does not implement this method. */ + // phpcs:ignore Drupal.Commenting.FunctionComment.InvalidNoReturn protected function introspectIndexSchema($table) { if (!$this->tableExists($table)) { throw new SchemaObjectDoesNotExistException("The table $table doesn't exist."); @@ -667,6 +668,7 @@ public function createTable($name, $table) { * make it private for each driver, and ::createTable actually an abstract * method here for implementation in each driver. */ + // phpcs:ignore Drupal.Commenting.FunctionComment.InvalidNoReturn protected function createTableSql($name, $table) { throw new \BadMethodCallException(get_class($this) . '::createTableSql() not implemented.'); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php index 29a2041fd43749556e54ace0d77573e05db76bfc..60920fad60f554ec99851eea44224dc7a96d12aa 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php @@ -222,6 +222,8 @@ protected function sanitizeLabel(&$label) { * @return string|null * Either a label of the empty option, or NULL. */ - protected function getEmptyLabel() {} + protected function getEmptyLabel() { + return NULL; + } } diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php index af4951bfa46426edb465fa41a8c399fa8c1a67a5..cd0b7da274e94261506cb2d895a371ccf4b1952b 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php @@ -88,6 +88,7 @@ public function __construct($jail) { * * @throws \Drupal\Core\FileTransfer\FileTransferException */ + // phpcs:ignore Drupal.Commenting.FunctionComment.InvalidNoReturn public static function factory($jail, $settings) { throw new FileTransferException('FileTransfer::factory() static method not overridden by FileTransfer subclass.'); } diff --git a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php index 65e0d98a7fd96b96ba957336f172d2dfe44e865f..396227525506f381e4a37bd453e28476b95ae2d0 100644 --- a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php @@ -115,6 +115,7 @@ public function stream_open($uri, $mode, $options, &$opened_path) { * prevent static analysis errors. In D11, consider changing it to an * abstract method. */ + // phpcs:ignore Drupal.Commenting.FunctionComment.InvalidNoReturn protected function getLocalPath($uri = NULL) { throw new \BadMethodCallException(get_class($this) . '::getLocalPath() not implemented.'); } diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php index ec213b08876c930c3fe46cc1981c5b7fcc58b3f5..eff8072934520914b7541838975d72912ad3917f 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php @@ -89,6 +89,7 @@ protected static function validateAllowedValue($option) { if (!is_numeric($option)) { return new TranslatableMarkup('Allowed values list: each key must be a valid integer or decimal.'); } + return NULL; } /** diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php index f053b101039c2321d7ce6505981dbe88f6ae00a3..c4e9c7d0d363a5ffbce89414570c7f98dfc8481f 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php @@ -70,6 +70,7 @@ protected static function validateAllowedValue($option) { if (!preg_match('/^-?\d+$/', $option)) { return new TranslatableMarkup('Allowed values list: keys must be integers.'); } + return NULL; } /** diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php index 47f1705481b1272b60a6a90848eb330f964386b0..250fe8812eaf5d7ca8409824391a47a1ffa165eb 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php @@ -444,10 +444,12 @@ protected static function extractAllowedValues(array $list, bool $has_data) { * @param string $option * The option value entered by the user. * - * @return string + * @return \Drupal\Core\StringTranslation\TranslatableMarkup|string|null * The error message if the specified value is invalid, NULL otherwise. */ - protected static function validateAllowedValue($option) {} + protected static function validateAllowedValue($option) { + return NULL; + } /** * Generates a string representation of an array of 'allowed values'. diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php index 332a1768c23ee0d0e2fc9dac9b61aaa1f747d06e..c31f1bc13768c31a35a99f3aa705ee9e493b7fca 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php @@ -74,6 +74,7 @@ protected static function validateAllowedValue($option) { if (mb_strlen($option) > 255) { return new TranslatableMarkup('Allowed values list: each key must be a string at most 255 characters long.'); } + return NULL; } /** diff --git a/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php b/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php index 80cd882e24a456ee4e963be46fdac3384ea99d8f..fcb3618d5665944a1db61aa442fff041fff7f8e1 100644 --- a/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php +++ b/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php @@ -123,7 +123,9 @@ public function processSummaryArguments(&$args) {} * A context definition that represents the argument or NULL if that is * not possible. */ - public function getContextDefinition() {} + public function getContextDefinition() { + return NULL; + } } diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 733c8d5084eaaaa96447d3c900ed569e8e648e31..d7a66fe42aa4f00d37451c45569ceaaf82acde29 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -68,7 +68,6 @@ <rule ref="Drupal.Commenting.FileComment"/> <rule ref="Drupal.Commenting.FunctionComment"> - <exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/> <exclude name="Drupal.Commenting.FunctionComment.Missing"/> <exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/> <exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>