Skip to content

Commit 2904649

Browse files
committed
apply rector rule \Rector\Php80\Rector\Identical\StrStartsWithRector
1 parent c4652cf commit 2904649

13 files changed

+18
-18
lines changed

Diff for: lib/command/sfCommandManager.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function process($arguments = null)
132132
break;
133133
}
134134

135-
if ('--' == substr($argument, 0, 2)) {
135+
if (str_starts_with($argument, '--')) {
136136
$this->parseLongOption(substr($argument, 2));
137137
} elseif ('-' == $argument[0]) {
138138
$this->parseShortOption(substr($argument, 1));

Diff for: lib/command/sfCommandOption.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class sfCommandOption
4040
*/
4141
public function __construct($name, $shortcut = null, $mode = null, $help = '', $default = null)
4242
{
43-
if ('--' == substr($name, 0, 2)) {
43+
if (str_starts_with($name, '--')) {
4444
$name = substr($name, 2);
4545
}
4646

Diff for: lib/escaper/sfOutputEscaperObjectDecorator.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __call($method, $args)
4444
{
4545
if (count($args) > 0) {
4646
$escapingMethod = $args[count($args) - 1];
47-
if (is_string($escapingMethod) && 'esc_' === substr($escapingMethod, 0, 4)) {
47+
if (is_string($escapingMethod) && str_starts_with($escapingMethod, 'esc_')) {
4848
array_pop($args);
4949
} else {
5050
$escapingMethod = $this->escapingMethod;

Diff for: lib/helper/UrlHelper.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function url_for()
108108
{
109109
// for BC with 1.1
110110
$arguments = func_get_args();
111-
if (is_array($arguments[0]) || '@' == substr($arguments[0], 0, 1) || str_contains($arguments[0], '/')) {
111+
if (is_array($arguments[0]) || str_starts_with($arguments[0], '@') || str_contains($arguments[0], '/')) {
112112
return call_user_func_array('url_for1', $arguments);
113113
}
114114

@@ -156,7 +156,7 @@ function link_to()
156156
{
157157
// for BC with 1.1
158158
$arguments = func_get_args();
159-
if (empty($arguments[1]) || is_array($arguments[1]) || '@' == substr($arguments[1], 0, 1) || str_contains($arguments[1], '/')) {
159+
if (empty($arguments[1]) || is_array($arguments[1]) || str_starts_with($arguments[1], '@') || str_contains($arguments[1], '/')) {
160160
return call_user_func_array('link_to1', $arguments);
161161
}
162162

@@ -215,7 +215,7 @@ function form_tag_for(sfForm $form, $routePrefix, $attributes = [])
215215
function link_to_if()
216216
{
217217
$arguments = func_get_args();
218-
if (empty($arguments[2]) || '@' == substr($arguments[2], 0, 1) || str_contains($arguments[2], '/')) {
218+
if (empty($arguments[2]) || str_starts_with($arguments[2], '@') || str_contains($arguments[2], '/')) {
219219
list($condition, $name, $params, $options) = array_pad($arguments, 4, null);
220220
} else {
221221
list($condition, $name, $routeName, $params, $options) = array_pad($arguments, 5, null);
@@ -294,7 +294,7 @@ function public_path($path, $absolute = false)
294294
$source = $root;
295295
}
296296

297-
if ('/' != substr($path, 0, 1)) {
297+
if (!str_starts_with($path, '/')) {
298298
$path = '/'.$path;
299299
}
300300

Diff for: lib/log/sfWebDebugLogger.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function filterResponseContent(sfEvent $event, $content)
151151
|| !$this->context->has('controller')
152152
|| $request->isXmlHttpRequest()
153153
|| !str_contains($response->getContentType(), 'html')
154-
|| '3' == substr($response->getStatusCode(), 0, 1)
154+
|| str_starts_with($response->getStatusCode(), '3')
155155
|| sfView::RENDER_CLIENT != $this->context->getController()->getRenderMode()
156156
|| $response->isHeaderOnly()
157157
) {

Diff for: lib/plugins/sfDoctrinePlugin/lib/test/sfTesterDoctrine.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function check($model, $query, $value = true)
6161
}
6262

6363
$operator = '=';
64-
if (strlen($condition) && '!' == substr($condition, 0, 1)) {
64+
if (strlen($condition) && str_starts_with($condition, '!')) {
6565
$operator = str_contains($condition, '%') ? 'NOT LIKE' : '!=';
6666
$condition = substr($condition, 1);
6767
} elseif (str_contains($condition, '%')) {

Diff for: lib/plugins/sfDoctrinePlugin/test/functional/AdminGenBrowser.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function runTests()
2626

2727
$methods = get_class_methods($this);
2828
foreach ($methods as $method) {
29-
if ('_test' == substr($method, 0, 5)) {
29+
if (str_starts_with($method, '_test')) {
3030
$this->{$method}();
3131
}
3232
}

Diff for: lib/response/sfWebResponse.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public function sendHttpHeaders()
332332
$status = $this->options['http_protocol'].' '.$this->statusCode.' '.$this->statusText;
333333
header($status);
334334

335-
if ('cgi' == substr(php_sapi_name(), 0, 3)) {
335+
if (str_starts_with(php_sapi_name(), 'cgi')) {
336336
// fastcgi servers cannot send this status information because it was sent by them already due to the HTT/1.0 line
337337
// so we can safely unset them. see ticket #3191
338338
unset($this->headers['Status']);

Diff for: lib/routing/sfPatternRouting.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ protected function getRouteThatMatchesParameters($parameters)
500500
protected function normalizeUrl($url)
501501
{
502502
// an URL should start with a '/', mod_rewrite doesn't respect that, but no-mod_rewrite version does.
503-
if ('/' != substr($url, 0, 1)) {
503+
if (!str_starts_with($url, '/')) {
504504
$url = '/'.$url;
505505
}
506506

Diff for: lib/task/sfTask.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function getName()
253253

254254
$name = get_class($this);
255255

256-
if ('sf' == substr($name, 0, 2)) {
256+
if (str_starts_with($name, 'sf')) {
257257
$name = substr($name, 2);
258258
}
259259

Diff for: lib/util/sfFinder.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function setType($name)
100100
{
101101
$name = strtolower($name);
102102

103-
if ('dir' === substr($name, 0, 3)) {
103+
if (str_starts_with($name, 'dir')) {
104104
$this->type = 'directory';
105105

106106
return $this;

Diff for: lib/vendor/lime/lime.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function ok($exp, $message = '')
179179
}
180180
$this->results['tests'][$this->test_nb]['message'] = $message;
181181
$this->results['tests'][$this->test_nb]['status'] = $result;
182-
$this->output->echoln(sprintf("%s %d%s", $result ? 'ok' : 'not ok', $this->test_nb, $message = $message ? sprintf('%s %s', 0 === strpos($message, '#') ? '' : ' -', $message) : ''));
182+
$this->output->echoln(sprintf("%s %d%s", $result ? 'ok' : 'not ok', $this->test_nb, $message = $message ? sprintf('%s %s', str_starts_with($message, '#') ? '' : ' -', $message) : ''));
183183

184184
if (!$result)
185185
{

Diff for: lib/yaml/sfYamlParser.class.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function parse($value)
106106
$key = sfYamlInline::parseScalar($values['key']);
107107

108108
if ('<<' === $key) {
109-
if (isset($values['value']) && '*' === substr($values['value'], 0, 1)) {
109+
if (isset($values['value']) && str_starts_with($values['value'], '*')) {
110110
$isInPlace = substr($values['value'], 1);
111111
if (!array_key_exists($isInPlace, $this->refs)) {
112112
throw new InvalidArgumentException(sprintf('Reference "%s" does not exist at line %s (%s).', $isInPlace, $this->getRealCurrentLineNb() + 1, $this->currentLine));
@@ -174,7 +174,7 @@ public function parse($value)
174174
$value = sfYamlInline::load($this->lines[0]);
175175
if (is_array($value)) {
176176
$first = reset($value);
177-
if ('*' === substr($first, 0, 1)) {
177+
if (str_starts_with($first, '*')) {
178178
$data = [];
179179
foreach ($value as $alias) {
180180
$data[] = $this->refs[substr($alias, 1)];
@@ -337,7 +337,7 @@ protected function moveToPreviousLine()
337337
*/
338338
protected function parseValue($value)
339339
{
340-
if ('*' === substr($value, 0, 1)) {
340+
if (str_starts_with($value, '*')) {
341341
if (false !== $pos = strpos($value, '#')) {
342342
$value = substr($value, 1, $pos - 2);
343343
} else {

0 commit comments

Comments
 (0)