From c4252a157c3f49496b89c2fefe22a0df0b81d314 Mon Sep 17 00:00:00 2001 From: connor Date: Thu, 4 Apr 2024 12:53:19 +0200 Subject: [PATCH] apply rector rule \Rector\Php80\Rector\Identical\StrEndsWithRector --- lib/form/sfForm.class.php | 2 +- lib/routing/sfRoute.class.php | 2 +- lib/task/project/sfProjectDeployTask.class.php | 2 +- lib/task/sfTask.class.php | 2 +- lib/util/sfBrowserBase.class.php | 2 +- lib/util/sfDomCssSelector.class.php | 2 +- lib/util/sfInflector.class.php | 2 +- lib/widget/sfWidgetFormChoice.class.php | 2 +- lib/widget/sfWidgetFormInputFileEditable.class.php | 2 +- lib/widget/sfWidgetFormSchema.class.php | 2 +- lib/widget/sfWidgetFormSchemaFormatter.class.php | 2 +- lib/widget/sfWidgetFormSelect.class.php | 2 +- lib/widget/sfWidgetFormSelectCheckbox.class.php | 2 +- lib/widget/sfWidgetFormSelectRadio.class.php | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/form/sfForm.class.php b/lib/form/sfForm.class.php index e3a9cc0a3..0b3935ab0 100644 --- a/lib/form/sfForm.class.php +++ b/lib/form/sfForm.class.php @@ -400,7 +400,7 @@ public function getValue($field) */ public function getName() { - if ('[%s]' != substr($nameFormat = $this->widgetSchema->getNameFormat(), -4)) { + if (!str_ends_with($nameFormat = $this->widgetSchema->getNameFormat(), '[%s]')) { return false; } diff --git a/lib/routing/sfRoute.class.php b/lib/routing/sfRoute.class.php index 3ec29e2aa..12d7afe6a 100644 --- a/lib/routing/sfRoute.class.php +++ b/lib/routing/sfRoute.class.php @@ -756,7 +756,7 @@ protected function fixRequirements() if ('^' == $regex[0]) { $regex = substr($regex, 1); } - if ('$' == substr($regex, -1)) { + if (str_ends_with($regex, '$')) { $regex = substr($regex, 0, -1); } diff --git a/lib/task/project/sfProjectDeployTask.class.php b/lib/task/project/sfProjectDeployTask.class.php index b9e9c6ed8..ea402f0d1 100644 --- a/lib/task/project/sfProjectDeployTask.class.php +++ b/lib/task/project/sfProjectDeployTask.class.php @@ -136,7 +136,7 @@ protected function execute($arguments = [], $options = []) $dir = $properties['dir']; $user = isset($properties['user']) ? $properties['user'].'@' : ''; - if ('/' != substr($dir, -1)) { + if (!str_ends_with($dir, '/')) { $dir .= '/'; } diff --git a/lib/task/sfTask.class.php b/lib/task/sfTask.class.php index 6efb22fd7..56ea9dcbd 100644 --- a/lib/task/sfTask.class.php +++ b/lib/task/sfTask.class.php @@ -257,7 +257,7 @@ public function getName() $name = substr($name, 2); } - if ('Task' == substr($name, -4)) { + if (str_ends_with($name, 'Task')) { $name = substr($name, 0, -4); } diff --git a/lib/util/sfBrowserBase.class.php b/lib/util/sfBrowserBase.class.php index 2eb9e5bbe..ea55e81c2 100755 --- a/lib/util/sfBrowserBase.class.php +++ b/lib/util/sfBrowserBase.class.php @@ -893,7 +893,7 @@ protected function parseArgumentAsArray($name, $value, &$vars) foreach ($tmps as $tmp) { $var = &$var[$tmp]; } - if ($var && '[]' === substr($name, -2)) { + if ($var && str_ends_with($name, '[]')) { if (!is_array($var)) { $var = [$var]; } diff --git a/lib/util/sfDomCssSelector.class.php b/lib/util/sfDomCssSelector.class.php index 462dd9235..ec8d63c10 100644 --- a/lib/util/sfDomCssSelector.class.php +++ b/lib/util/sfDomCssSelector.class.php @@ -259,7 +259,7 @@ protected function getElementsForNode($selector, $root_node) break; case '$': // Match ends with value - $ok = $attrValue == substr($found->getAttribute($attrName), -strlen($attrValue)); + $ok = str_ends_with($found->getAttribute($attrName), $attrValue); break; diff --git a/lib/util/sfInflector.class.php b/lib/util/sfInflector.class.php index 728d88773..97b33edda 100644 --- a/lib/util/sfInflector.class.php +++ b/lib/util/sfInflector.class.php @@ -103,7 +103,7 @@ public static function classify($table_name) */ public static function humanize($lower_case_and_underscored_word) { - if ('_id' === substr($lower_case_and_underscored_word, -3)) { + if (str_ends_with($lower_case_and_underscored_word, '_id')) { $lower_case_and_underscored_word = substr($lower_case_and_underscored_word, 0, -3); } diff --git a/lib/widget/sfWidgetFormChoice.class.php b/lib/widget/sfWidgetFormChoice.class.php index ca698f109..8d2acc4d1 100644 --- a/lib/widget/sfWidgetFormChoice.class.php +++ b/lib/widget/sfWidgetFormChoice.class.php @@ -47,7 +47,7 @@ public function render($name, $value = null, $attributes = [], $errors = []) if ($this->getOption('multiple')) { $attributes['multiple'] = 'multiple'; - if ('[]' != substr($name, -2)) { + if (!str_ends_with($name, '[]')) { $name .= '[]'; } } diff --git a/lib/widget/sfWidgetFormInputFileEditable.class.php b/lib/widget/sfWidgetFormInputFileEditable.class.php index 1adcb1881..ac78b6073 100644 --- a/lib/widget/sfWidgetFormInputFileEditable.class.php +++ b/lib/widget/sfWidgetFormInputFileEditable.class.php @@ -37,7 +37,7 @@ public function render($name, $value = null, $attributes = [], $errors = []) } if ($this->getOption('with_delete')) { - $deleteName = ']' == substr($name, -1) ? substr($name, 0, -1).'_delete]' : $name.'_delete'; + $deleteName = str_ends_with($name, ']') ? substr($name, 0, -1).'_delete]' : $name.'_delete'; $delete = $this->renderTag('input', array_merge(['type' => 'checkbox', 'name' => $deleteName], $attributes)); $deleteLabel = $this->translate($this->getOption('delete_label')); diff --git a/lib/widget/sfWidgetFormSchema.class.php b/lib/widget/sfWidgetFormSchema.class.php index f49ac13a9..21ca17c54 100644 --- a/lib/widget/sfWidgetFormSchema.class.php +++ b/lib/widget/sfWidgetFormSchema.class.php @@ -599,7 +599,7 @@ public function generateName($name) { $format = $this->getNameFormat(); - if ('[%s]' == substr($format, -4) && preg_match('/^(.+?)\[(.+)\]$/', $name, $match)) { + if (str_ends_with($format, '[%s]') && preg_match('/^(.+?)\[(.+)\]$/', $name, $match)) { $name = sprintf('%s[%s][%s]', substr($format, 0, -4), $match[1], $match[2]); } elseif (false !== $format) { $name = sprintf($format, $name); diff --git a/lib/widget/sfWidgetFormSchemaFormatter.class.php b/lib/widget/sfWidgetFormSchemaFormatter.class.php index 9c7a1e94b..b9d4383a6 100644 --- a/lib/widget/sfWidgetFormSchemaFormatter.class.php +++ b/lib/widget/sfWidgetFormSchemaFormatter.class.php @@ -168,7 +168,7 @@ public function generateLabelName($name) $label = $this->widgetSchema->getLabel($name); if (!$label && false !== $label) { - $label = str_replace('_', ' ', ucfirst('_id' == substr($name, -3) ? substr($name, 0, -3) : $name)); + $label = str_replace('_', ' ', ucfirst(str_ends_with($name, '_id') ? substr($name, 0, -3) : $name)); } return $this->translate($label); diff --git a/lib/widget/sfWidgetFormSelect.class.php b/lib/widget/sfWidgetFormSelect.class.php index 01578dd56..2ab2a57ab 100644 --- a/lib/widget/sfWidgetFormSelect.class.php +++ b/lib/widget/sfWidgetFormSelect.class.php @@ -32,7 +32,7 @@ public function render($name, $value = null, $attributes = [], $errors = []) if ($this->getOption('multiple')) { $attributes['multiple'] = 'multiple'; - if ('[]' != substr($name, -2)) { + if (!str_ends_with($name, '[]')) { $name .= '[]'; } } diff --git a/lib/widget/sfWidgetFormSelectCheckbox.class.php b/lib/widget/sfWidgetFormSelectCheckbox.class.php index b04dfe0cd..2e788b13c 100644 --- a/lib/widget/sfWidgetFormSelectCheckbox.class.php +++ b/lib/widget/sfWidgetFormSelectCheckbox.class.php @@ -29,7 +29,7 @@ class sfWidgetFormSelectCheckbox extends sfWidgetFormChoiceBase */ public function render($name, $value = null, $attributes = [], $errors = []) { - if ('[]' != substr($name, -2)) { + if (!str_ends_with($name, '[]')) { $name .= '[]'; } diff --git a/lib/widget/sfWidgetFormSelectRadio.class.php b/lib/widget/sfWidgetFormSelectRadio.class.php index 94bf92353..47d47aa75 100644 --- a/lib/widget/sfWidgetFormSelectRadio.class.php +++ b/lib/widget/sfWidgetFormSelectRadio.class.php @@ -29,7 +29,7 @@ class sfWidgetFormSelectRadio extends sfWidgetFormChoiceBase */ public function render($name, $value = null, $attributes = [], $errors = []) { - if ('[]' != substr($name, -2)) { + if (!str_ends_with($name, '[]')) { $name .= '[]'; }