diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 2e5cc541915e6..b188dd552c400 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -97,6 +97,8 @@ 'combine_consecutive_issets' => true, // Calling unset on multiple items should be done in one call 'combine_consecutive_unsets' => true, + // There must be no sprintf calls with only the first argument + 'no_useless_sprintf' => true, ] ) ->setFinder($finder); diff --git a/administrator/components/com_actionlogs/src/Model/ActionlogModel.php b/administrator/components/com_actionlogs/src/Model/ActionlogModel.php index 611e7578fd2c3..0a1ac8b1cd9ff 100644 --- a/administrator/components/com_actionlogs/src/Model/ActionlogModel.php +++ b/administrator/components/com_actionlogs/src/Model/ActionlogModel.php @@ -58,7 +58,7 @@ public function addLog($messages, $messageLanguageKey, $context, $userId = 0) try { $user = $userId ? $this->getUserFactory()->loadUserById($userId) : $this->getCurrentUser(); } catch (\UnexpectedValueException $e) { - @trigger_error(\sprintf('UserFactory must be set, this will not be caught anymore in 7.0.'), E_USER_DEPRECATED); + @trigger_error('UserFactory must be set, this will not be caught anymore in 7.0.', E_USER_DEPRECATED); $user = Factory::getUser($userId); } diff --git a/administrator/components/com_fields/src/Model/FieldModel.php b/administrator/components/com_fields/src/Model/FieldModel.php index db44abc384813..cdb173524567c 100644 --- a/administrator/components/com_fields/src/Model/FieldModel.php +++ b/administrator/components/com_fields/src/Model/FieldModel.php @@ -330,7 +330,7 @@ private function checkDefaultValue($data) try { $rule->setDatabase($this->getDatabase()); } catch (DatabaseNotFoundException) { - @trigger_error(\sprintf('Database must be set, this will not be caught anymore in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database must be set, this will not be caught anymore in 5.0.', E_USER_DEPRECATED); $rule->setDatabase(Factory::getContainer()->get(DatabaseInterface::class)); } } diff --git a/administrator/components/com_finder/src/Indexer/Indexer.php b/administrator/components/com_finder/src/Indexer/Indexer.php index 6aec4b6572342..1ed61b79faf90 100644 --- a/administrator/components/com_finder/src/Indexer/Indexer.php +++ b/administrator/components/com_finder/src/Indexer/Indexer.php @@ -122,7 +122,7 @@ class Indexer public function __construct(?DatabaseInterface $db = null) { if ($db === null) { - @trigger_error(\sprintf('Database will be mandatory in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database will be mandatory in 5.0.', E_USER_DEPRECATED); $db = Factory::getContainer()->get(DatabaseInterface::class); } diff --git a/administrator/components/com_finder/src/Indexer/Query.php b/administrator/components/com_finder/src/Indexer/Query.php index 61b1bd4cd9b5f..17838e033bdc2 100644 --- a/administrator/components/com_finder/src/Indexer/Query.php +++ b/administrator/components/com_finder/src/Indexer/Query.php @@ -208,7 +208,7 @@ class Query public function __construct($options, ?DatabaseInterface $db = null) { if ($db === null) { - @trigger_error(\sprintf('Database will be mandatory in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database will be mandatory in 5.0.', E_USER_DEPRECATED); $db = Factory::getContainer()->get(DatabaseInterface::class); } diff --git a/libraries/src/Categories/Categories.php b/libraries/src/Categories/Categories.php index 7205c7e563db2..018717fc719f6 100644 --- a/libraries/src/Categories/Categories.php +++ b/libraries/src/Categories/Categories.php @@ -237,7 +237,7 @@ protected function _load($id) try { $db = $this->getDatabase(); } catch (DatabaseNotFoundException) { - @trigger_error(\sprintf('Database must be set, this will not be caught anymore in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database must be set, this will not be caught anymore in 5.0.', E_USER_DEPRECATED); $db = Factory::getContainer()->get(DatabaseInterface::class); } diff --git a/libraries/src/Form/Form.php b/libraries/src/Form/Form.php index 5d7f949ef449c..db61578b72694 100644 --- a/libraries/src/Form/Form.php +++ b/libraries/src/Form/Form.php @@ -1466,7 +1466,7 @@ protected function loadField($element, $group = null, $value = null) try { $field->setDatabase($this->getDatabase()); } catch (DatabaseNotFoundException) { - @trigger_error(\sprintf('Database must be set, this will not be caught anymore in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database must be set, this will not be caught anymore in 5.0.', E_USER_DEPRECATED); $field->setDatabase(Factory::getContainer()->get(DatabaseInterface::class)); } } diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index 7e369ad7fe344..ae60376c7af0c 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -1218,7 +1218,7 @@ public function validate($value, $group = null, ?Registry $input = null) try { $rule->setDatabase($this->getDatabase()); } catch (DatabaseNotFoundException) { - @trigger_error(\sprintf('Database must be set, this will not be caught anymore in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database must be set, this will not be caught anymore in 5.0.', E_USER_DEPRECATED); $rule->setDatabase(Factory::getContainer()->get(DatabaseInterface::class)); } } @@ -1243,7 +1243,7 @@ public function validate($value, $group = null, ?Registry $input = null) try { $rule->setDatabase($this->getDatabase()); } catch (DatabaseNotFoundException) { - @trigger_error(\sprintf('Database must be set, this will not be caught anymore in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database must be set, this will not be caught anymore in 5.0.', E_USER_DEPRECATED); $rule->setDatabase(Factory::getContainer()->get(DatabaseInterface::class)); } } diff --git a/libraries/src/MVC/Factory/MVCFactory.php b/libraries/src/MVC/Factory/MVCFactory.php index 35fe905b69ee0..b21b3a1021f54 100644 --- a/libraries/src/MVC/Factory/MVCFactory.php +++ b/libraries/src/MVC/Factory/MVCFactory.php @@ -171,7 +171,7 @@ public function createModel($name, $prefix = '', array $config = []) try { $model->setDatabase($this->getDatabase()); } catch (DatabaseNotFoundException) { - @trigger_error(\sprintf('Database must be set, this will not be caught anymore in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database must be set, this will not be caught anymore in 5.0.', E_USER_DEPRECATED); $model->setDatabase(Factory::getContainer()->get(DatabaseInterface::class)); } } @@ -267,7 +267,7 @@ public function createTable($name, $prefix = '', array $config = []) try { $db = \array_key_exists('dbo', $config) ? $config['dbo'] : $this->getDatabase(); } catch (DatabaseNotFoundException) { - @trigger_error(\sprintf('Database must be set, this will not be caught anymore in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database must be set, this will not be caught anymore in 5.0.', E_USER_DEPRECATED); $db = Factory::getContainer()->get(DatabaseInterface::class); } diff --git a/libraries/src/MVC/Model/BaseDatabaseModel.php b/libraries/src/MVC/Model/BaseDatabaseModel.php index e7dbc8e27dfa2..1970f16a1e26c 100644 --- a/libraries/src/MVC/Model/BaseDatabaseModel.php +++ b/libraries/src/MVC/Model/BaseDatabaseModel.php @@ -105,7 +105,7 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null) $db = \array_key_exists('dbo', $config) ? $config['dbo'] : Factory::getDbo(); if ($db) { - @trigger_error(\sprintf('Database is not available in constructor in 6.0.'), E_USER_DEPRECATED); + @trigger_error('Database is not available in constructor in 6.0.', E_USER_DEPRECATED); $this->setDatabase($db); // Is needed, when models use the deprecated MVC DatabaseAwareTrait, as the trait is overriding the local functions diff --git a/libraries/src/Menu/SiteMenu.php b/libraries/src/Menu/SiteMenu.php index 8abedbe60af73..f99f6015006e8 100644 --- a/libraries/src/Menu/SiteMenu.php +++ b/libraries/src/Menu/SiteMenu.php @@ -72,7 +72,7 @@ public function __construct($options = []) $this->language = isset($options['language']) && $options['language'] instanceof Language ? $options['language'] : Factory::getLanguage(); if (!isset($options['db']) || !($options['db'] instanceof DatabaseDriver)) { - @trigger_error(\sprintf('Database will be mandatory in 5.0.'), E_USER_DEPRECATED); + @trigger_error('Database will be mandatory in 5.0.', E_USER_DEPRECATED); $options['db'] = Factory::getContainer()->get(DatabaseDriver::class); } diff --git a/libraries/src/Table/ContentType.php b/libraries/src/Table/ContentType.php index aedc87f793bbe..06afe016015a9 100644 --- a/libraries/src/Table/ContentType.php +++ b/libraries/src/Table/ContentType.php @@ -57,13 +57,13 @@ public function check() // Check for valid name. if (trim($this->type_title) === '') { - throw new \UnexpectedValueException(\sprintf('The title is empty')); + throw new \UnexpectedValueException('The title is empty'); } $this->type_title = ucfirst($this->type_title); if (empty($this->type_alias)) { - throw new \UnexpectedValueException(\sprintf('The type_alias is empty')); + throw new \UnexpectedValueException('The type_alias is empty'); } return true;