Skip to content

Commit

Permalink
apply rector rule \Rector\Php80\Rector\Identical\StrEndsWithRector
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu committed Apr 4, 2024
1 parent 2904649 commit c4252a1
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/form/sfForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/routing/sfRoute.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/task/project/sfProjectDeployTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '/';
}

Expand Down
2 changes: 1 addition & 1 deletion lib/task/sfTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/util/sfBrowserBase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util/sfDomCssSelector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/util/sfInflector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/widget/sfWidgetFormChoice.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '[]';
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/sfWidgetFormInputFileEditable.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/sfWidgetFormSchema.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/sfWidgetFormSchemaFormatter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/sfWidgetFormSelect.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '[]';
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/sfWidgetFormSelectCheckbox.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '[]';
}

Expand Down
2 changes: 1 addition & 1 deletion lib/widget/sfWidgetFormSelectRadio.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '[]';
}

Expand Down

0 comments on commit c4252a1

Please sign in to comment.