Skip to content

Commit c4252a1

Browse files
committed
apply rector rule \Rector\Php80\Rector\Identical\StrEndsWithRector
1 parent 2904649 commit c4252a1

14 files changed

+14
-14
lines changed

lib/form/sfForm.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public function getValue($field)
400400
*/
401401
public function getName()
402402
{
403-
if ('[%s]' != substr($nameFormat = $this->widgetSchema->getNameFormat(), -4)) {
403+
if (!str_ends_with($nameFormat = $this->widgetSchema->getNameFormat(), '[%s]')) {
404404
return false;
405405
}
406406

lib/routing/sfRoute.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ protected function fixRequirements()
756756
if ('^' == $regex[0]) {
757757
$regex = substr($regex, 1);
758758
}
759-
if ('$' == substr($regex, -1)) {
759+
if (str_ends_with($regex, '$')) {
760760
$regex = substr($regex, 0, -1);
761761
}
762762

lib/task/project/sfProjectDeployTask.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected function execute($arguments = [], $options = [])
136136
$dir = $properties['dir'];
137137
$user = isset($properties['user']) ? $properties['user'].'@' : '';
138138

139-
if ('/' != substr($dir, -1)) {
139+
if (!str_ends_with($dir, '/')) {
140140
$dir .= '/';
141141
}
142142

lib/task/sfTask.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function getName()
257257
$name = substr($name, 2);
258258
}
259259

260-
if ('Task' == substr($name, -4)) {
260+
if (str_ends_with($name, 'Task')) {
261261
$name = substr($name, 0, -4);
262262
}
263263

lib/util/sfBrowserBase.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ protected function parseArgumentAsArray($name, $value, &$vars)
893893
foreach ($tmps as $tmp) {
894894
$var = &$var[$tmp];
895895
}
896-
if ($var && '[]' === substr($name, -2)) {
896+
if ($var && str_ends_with($name, '[]')) {
897897
if (!is_array($var)) {
898898
$var = [$var];
899899
}

lib/util/sfDomCssSelector.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ protected function getElementsForNode($selector, $root_node)
259259
break;
260260

261261
case '$': // Match ends with value
262-
$ok = $attrValue == substr($found->getAttribute($attrName), -strlen($attrValue));
262+
$ok = str_ends_with($found->getAttribute($attrName), $attrValue);
263263

264264
break;
265265

lib/util/sfInflector.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static function classify($table_name)
103103
*/
104104
public static function humanize($lower_case_and_underscored_word)
105105
{
106-
if ('_id' === substr($lower_case_and_underscored_word, -3)) {
106+
if (str_ends_with($lower_case_and_underscored_word, '_id')) {
107107
$lower_case_and_underscored_word = substr($lower_case_and_underscored_word, 0, -3);
108108
}
109109

lib/widget/sfWidgetFormChoice.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function render($name, $value = null, $attributes = [], $errors = [])
4747
if ($this->getOption('multiple')) {
4848
$attributes['multiple'] = 'multiple';
4949

50-
if ('[]' != substr($name, -2)) {
50+
if (!str_ends_with($name, '[]')) {
5151
$name .= '[]';
5252
}
5353
}

lib/widget/sfWidgetFormInputFileEditable.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function render($name, $value = null, $attributes = [], $errors = [])
3737
}
3838

3939
if ($this->getOption('with_delete')) {
40-
$deleteName = ']' == substr($name, -1) ? substr($name, 0, -1).'_delete]' : $name.'_delete';
40+
$deleteName = str_ends_with($name, ']') ? substr($name, 0, -1).'_delete]' : $name.'_delete';
4141

4242
$delete = $this->renderTag('input', array_merge(['type' => 'checkbox', 'name' => $deleteName], $attributes));
4343
$deleteLabel = $this->translate($this->getOption('delete_label'));

lib/widget/sfWidgetFormSchema.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public function generateName($name)
599599
{
600600
$format = $this->getNameFormat();
601601

602-
if ('[%s]' == substr($format, -4) && preg_match('/^(.+?)\[(.+)\]$/', $name, $match)) {
602+
if (str_ends_with($format, '[%s]') && preg_match('/^(.+?)\[(.+)\]$/', $name, $match)) {
603603
$name = sprintf('%s[%s][%s]', substr($format, 0, -4), $match[1], $match[2]);
604604
} elseif (false !== $format) {
605605
$name = sprintf($format, $name);

lib/widget/sfWidgetFormSchemaFormatter.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function generateLabelName($name)
168168
$label = $this->widgetSchema->getLabel($name);
169169

170170
if (!$label && false !== $label) {
171-
$label = str_replace('_', ' ', ucfirst('_id' == substr($name, -3) ? substr($name, 0, -3) : $name));
171+
$label = str_replace('_', ' ', ucfirst(str_ends_with($name, '_id') ? substr($name, 0, -3) : $name));
172172
}
173173

174174
return $this->translate($label);

lib/widget/sfWidgetFormSelect.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function render($name, $value = null, $attributes = [], $errors = [])
3232
if ($this->getOption('multiple')) {
3333
$attributes['multiple'] = 'multiple';
3434

35-
if ('[]' != substr($name, -2)) {
35+
if (!str_ends_with($name, '[]')) {
3636
$name .= '[]';
3737
}
3838
}

lib/widget/sfWidgetFormSelectCheckbox.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class sfWidgetFormSelectCheckbox extends sfWidgetFormChoiceBase
2929
*/
3030
public function render($name, $value = null, $attributes = [], $errors = [])
3131
{
32-
if ('[]' != substr($name, -2)) {
32+
if (!str_ends_with($name, '[]')) {
3333
$name .= '[]';
3434
}
3535

lib/widget/sfWidgetFormSelectRadio.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class sfWidgetFormSelectRadio extends sfWidgetFormChoiceBase
2929
*/
3030
public function render($name, $value = null, $attributes = [], $errors = [])
3131
{
32-
if ('[]' != substr($name, -2)) {
32+
if (!str_ends_with($name, '[]')) {
3333
$name .= '[]';
3434
}
3535

0 commit comments

Comments
 (0)