Skip to content

Commit

Permalink
[5.3] Remove useless sprintf function call (#45036)
Browse files Browse the repository at this point in the history
joomdonation authored Feb 28, 2025
1 parent 1ce0a30 commit 1bc1e8f
Showing 12 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
}

Original file line number Diff line number Diff line change
@@ -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));
}
}
Original file line number Diff line number Diff line change
@@ -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);
}

2 changes: 1 addition & 1 deletion administrator/components/com_finder/src/Indexer/Query.php
Original file line number Diff line number Diff line change
@@ -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);
}

2 changes: 1 addition & 1 deletion libraries/src/Categories/Categories.php
Original file line number Diff line number Diff line change
@@ -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);
}

2 changes: 1 addition & 1 deletion libraries/src/Form/Form.php
Original file line number Diff line number Diff line change
@@ -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));
}
}
4 changes: 2 additions & 2 deletions libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
@@ -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));
}
}
4 changes: 2 additions & 2 deletions libraries/src/MVC/Factory/MVCFactory.php
Original file line number Diff line number Diff line change
@@ -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);
}

2 changes: 1 addition & 1 deletion libraries/src/MVC/Model/BaseDatabaseModel.php
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion libraries/src/Menu/SiteMenu.php
Original file line number Diff line number Diff line change
@@ -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);
}

4 changes: 2 additions & 2 deletions libraries/src/Table/ContentType.php
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 1bc1e8f

Please sign in to comment.