Skip to content

Commit 32ea83c

Browse files
authored
[5.3] Use str_ends_with for components code (#44874)
1 parent b69c4c5 commit 32ea83c

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

administrator/components/com_config/src/Model/ApplicationModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ public function storePermissions($permission = null)
884884
}
885885

886886
// We are creating a new item so we don't have an item id so don't allow.
887-
if (substr($permission['component'], -6) === '.false') {
887+
if (str_ends_with($permission['component'], '.false')) {
888888
$app->enqueueMessage(Text::_('JLIB_RULES_SAVE_BEFORE_CHANGE_PERMISSIONS'), 'error');
889889

890890
return false;

administrator/components/com_joomlaupdate/extract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ private function setCorrectPermissions(string $path): void
13161316
*/
13171317
private function isIgnoredDirectory(string $shortFilename): bool
13181318
{
1319-
$check = substr($shortFilename, -1) == '/' ? rtrim($shortFilename, '/') : \dirname($shortFilename);
1319+
$check = str_ends_with($shortFilename, '/') ? rtrim($shortFilename, '/') : \dirname($shortFilename);
13201320

13211321
return \in_array($check, $this->ignoreDirectories);
13221322
}
@@ -1375,7 +1375,7 @@ private function processTypeLink(): bool
13751375
}
13761376

13771377
// Remove any trailing slash
1378-
if (substr($filename, -1) == '/') {
1378+
if (str_ends_with($filename, '/')) {
13791379
$filename = substr($filename, 0, -1);
13801380
}
13811381

administrator/components/com_joomlaupdate/finalisation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public static function exists(string $folderName): bool
201201
*/
202202
public static function delete(string $folderName): bool
203203
{
204-
if (substr($folderName, -1) == '/') {
204+
if (str_ends_with($folderName, '/')) {
205205
$folderName = substr($folderName, 0, -1);
206206
}
207207

administrator/components/com_templates/src/Model/TemplateModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ public function getOverridesList()
11011101
$path = $folder . '/' . $view . '/tmpl';
11021102

11031103
// The new scheme, the views are directly in the component/tmpl folder
1104-
if (!is_dir($path) && substr($folder, -4) == 'tmpl') {
1104+
if (!is_dir($path) && str_ends_with($folder, 'tmpl')) {
11051105
$path = $folder . '/' . $view;
11061106
}
11071107

0 commit comments

Comments
 (0)