Skip to content

Commit 30f8c9d

Browse files
authored
[5.3] Use str_starts_with function for components (#44868)
1 parent 32ea83c commit 30f8c9d

File tree

17 files changed

+20
-20
lines changed

17 files changed

+20
-20
lines changed

administrator/components/com_banners/src/Model/BannerModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public function save($data)
417417
if ($createCategory && $this->canCreateCategory()) {
418418
$category = [
419419
// Remove #new# prefix, if exists.
420-
'title' => strpos($data['catid'], '#new#') === 0 ? substr($data['catid'], 5) : $data['catid'],
420+
'title' => str_starts_with($data['catid'], '#new#') ? substr($data['catid'], 5) : $data['catid'],
421421
'parent_id' => 1,
422422
'extension' => 'com_banners',
423423
'language' => $data['language'],

administrator/components/com_config/src/Dispatcher/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function checkAccess(): void
4545
$view = $this->input->getCmd('view');
4646
$component = $this->input->getCmd('component');
4747

48-
if ($component && (substr($task, 0, 10) === 'component.' || $view === 'component')) {
48+
if ($component && (str_starts_with($task, 'component.') || $view === 'component')) {
4949
// User is changing component settings, check if he has permission to do that
5050
$canAccess = ConfigHelper::canChangeComponentConfig($component);
5151
} else {

administrator/components/com_contact/src/Model/ContactModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public function save($data)
292292
if ($createCategory && $this->canCreateCategory()) {
293293
$category = [
294294
// Remove #new# prefix, if exists.
295-
'title' => strpos($data['catid'], '#new#') === 0 ? substr($data['catid'], 5) : $data['catid'],
295+
'title' => str_starts_with($data['catid'], '#new#') ? substr($data['catid'], 5) : $data['catid'],
296296
'parent_id' => 1,
297297
'extension' => 'com_contact',
298298
'language' => $data['language'],

administrator/components/com_content/src/Model/ArticleModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ public function save($data)
682682
if ($createCategory && $this->canCreateCategory()) {
683683
$category = [
684684
// Remove #new# prefix, if exists.
685-
'title' => strpos($data['catid'], '#new#') === 0 ? substr($data['catid'], 5) : $data['catid'],
685+
'title' => str_starts_with($data['catid'], '#new#') ? substr($data['catid'], 5) : $data['catid'],
686686
'parent_id' => 1,
687687
'extension' => 'com_content',
688688
'language' => $data['language'],

administrator/components/com_cpanel/src/Controller/DisplayController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function addModule()
7575
$appendLink .= '&function=' . $function;
7676
}
7777

78-
if (substr($position, 0, 6) != 'cpanel') {
78+
if (!str_starts_with($position, 'cpanel')) {
7979
$position = 'cpanel';
8080
}
8181

administrator/components/com_fields/src/Plugin/FieldsPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function onContentPrepareForm(Form $form, $data)
343343
protected function getFormPath(Form $form, $data)
344344
{
345345
// Check if the field form is calling us
346-
if (strpos($form->getName(), 'com_fields.field') !== 0) {
346+
if (!str_starts_with($form->getName(), 'com_fields.field')) {
347347
return null;
348348
}
349349

administrator/components/com_login/src/Model/LoginModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static function getLoginModule($name = 'mod_login', $title = null)
9090
}
9191

9292
// If we didn't find it, and the name is mod_something, create a dummy object.
93-
if (\is_null($result) && substr($name, 0, 4) == 'mod_') {
93+
if (\is_null($result) && str_starts_with($name, 'mod_')) {
9494
$result = new \stdClass();
9595
$result->id = 0;
9696
$result->title = '';

administrator/components/com_menus/src/Helper/MenusHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function getLinkKey($request)
7272
if (\is_string($request)) {
7373
$args = [];
7474

75-
if (strpos($request, 'index.php') === 0) {
75+
if (str_starts_with($request, 'index.php')) {
7676
parse_str(parse_url(htmlspecialchars_decode($request), PHP_URL_QUERY), $args);
7777
} else {
7878
parse_str($request, $args);
@@ -480,7 +480,7 @@ protected static function installPresetItems($node, $menutype)
480480
];
481481
$table->load($keys);
482482
} elseif ($item->type == 'url' || $item->type == 'component') {
483-
if (substr($item->link, 0, 8) === 'special:') {
483+
if (str_starts_with($item->link, 'special:')) {
484484
$special = substr($item->link, 8);
485485

486486
if ($special === 'language-forum') {

administrator/components/com_menus/src/Model/MenutypesModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ protected function getTypeOptionsFromMvc($component)
279279
$view = basename($viewPath);
280280

281281
// Ignore private views.
282-
if (strpos($view, '_') !== 0) {
282+
if (!str_starts_with($view, '_')) {
283283
// Determine if a metadata file exists for the view.
284284
$file = $viewPath . '/metadata.xml';
285285

administrator/components/com_newsfeeds/src/Model/NewsfeedModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function save($data)
191191
if ($createCategory && $this->canCreateCategory()) {
192192
$category = [
193193
// Remove #new# prefix, if exists.
194-
'title' => strpos($data['catid'], '#new#') === 0 ? substr($data['catid'], 5) : $data['catid'],
194+
'title' => str_starts_with($data['catid'], '#new#') ? substr($data['catid'], 5) : $data['catid'],
195195
'parent_id' => 1,
196196
'extension' => 'com_newsfeeds',
197197
'language' => $data['language'],

0 commit comments

Comments
 (0)