Skip to content

Commit e191702

Browse files
committed
add(phpcs) modern strpos
1 parent 8fa04a0 commit e191702

File tree

48 files changed

+93
-91
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+93
-91
lines changed

.php-cs-fixer.dist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
'import_symbols' => true,
3030
'leading_backslash_in_global_namespace' => true,
3131
],
32+
'modernize_strpos' => true,
3233
])
34+
->setRiskyAllowed(true)
3335
->setCacheFile('.php-cs-fixer.cache')
3436
->setFinder($finder)
3537
;

lib/autoload/sfCoreAutoload.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public static function make()
515515
$classes = '';
516516
foreach ($files as $file) {
517517
$file = str_replace(DIRECTORY_SEPARATOR, '/', $file);
518-
$class = basename($file, false === strpos($file, '.class.php') ? '.php' : '.class.php');
518+
$class = basename($file, !str_contains($file, '.class.php') ? '.php' : '.class.php');
519519

520520
$contents = file_get_contents($file);
521521
if (false !== stripos($contents, 'class '.$class)

lib/cache/sfEAcceleratorCache.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ public function clean($mode = \sfCache::ALL)
118118
$infos = eaccelerator_list_keys();
119119
if (is_array($infos)) {
120120
foreach ($infos as $info) {
121-
if (false !== strpos($info['name'], $this->getOption('prefix'))) {
121+
if (str_contains($info['name'], $this->getOption('prefix'))) {
122122
// eaccelerator bug (http://eaccelerator.net/ticket/287)
123-
$key = 0 === strpos($info['name'], ':') ? substr($info['name'], 1) : $info['name'];
123+
$key = str_starts_with($info['name'], ':') ? substr($info['name'], 1) : $info['name'];
124124
if (!eaccelerator_rm($key)) {
125125
return false;
126126
}

lib/cache/sfFileCache.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function remove($key)
103103
*/
104104
public function removePattern($pattern)
105105
{
106-
if (false !== strpos($pattern, '**')) {
106+
if (str_contains($pattern, '**')) {
107107
$pattern = str_replace(\sfCache::SEPARATOR, DIRECTORY_SEPARATOR, $pattern).self::EXTENSION;
108108

109109
$regexp = self::patternToRegexp($pattern);

lib/command/sfCommandApplication.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ protected function fixCgi()
559559
ini_set('html_errors', false);
560560
ini_set('magic_quotes_runtime', false);
561561

562-
if (false === strpos(PHP_SAPI, 'cgi')) {
562+
if (!str_contains(PHP_SAPI, 'cgi')) {
563563
return;
564564
}
565565

lib/command/sfCommandManager.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ protected function parseShortOption($argument)
318318
*/
319319
protected function parseLongOption($argument)
320320
{
321-
if (false !== strpos($argument, '=')) {
321+
if (str_contains($argument, '=')) {
322322
list($name, $value) = explode('=', $argument, 2);
323323

324324
if (!$this->optionSet->hasOption($name)) {

lib/config/sfRoutingConfigHandler.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function parse($configFiles)
9191
foreach ($config as $name => $params) {
9292
if (
9393
(isset($params['type']) && 'collection' == $params['type'])
94-
|| (isset($params['class']) && false !== strpos($params['class'], 'Collection'))
94+
|| (isset($params['class']) && str_contains($params['class'], 'Collection'))
9595
) {
9696
$options = isset($params['options']) ? $params['options'] : [];
9797
$options['name'] = $name;

lib/controller/sfWebController.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function genUrl($parameters = [], $absolute = false)
3939
}
4040

4141
// relative URL?
42-
if (0 === strpos($parameters, '/')) {
42+
if (str_starts_with($parameters, '/')) {
4343
return $parameters;
4444
}
4545

@@ -111,7 +111,7 @@ public function convertUrlStringToParameters($url)
111111
// routeName?
112112
if ($url && '@' == $url[0]) {
113113
$route = substr($url, 1);
114-
} elseif (false !== strpos($url, '/')) {
114+
} elseif (str_contains($url, '/')) {
115115
list($params['module'], $params['action']) = explode('/', $url);
116116
} elseif (!$queryString) {
117117
$route = $givenUrl;

lib/debug/sfDebug.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public static function shortenFilePath($file)
240240
}
241241

242242
foreach (['sf_root_dir', 'sf_symfony_lib_dir'] as $key) {
243-
if (0 === strpos($file, $value = \sfConfig::get($key))) {
243+
if (str_starts_with($file, $value = \sfConfig::get($key))) {
244244
$file = str_replace($value, strtoupper($key), $file);
245245

246246
break;

lib/debug/sfWebDebugPanel.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function getToggleableDebugStack($debugStack)
117117
$file = isset($trace['file']) ? $trace['file'] : null;
118118
$line = isset($trace['line']) ? $trace['line'] : null;
119119

120-
$isProjectFile = $file && 0 === strpos($file, \sfConfig::get('sf_root_dir')) && !preg_match('/(cache|plugins|vendor)/', $file);
120+
$isProjectFile = $file && str_starts_with($file, \sfConfig::get('sf_root_dir')) && !preg_match('/(cache|plugins|vendor)/', $file);
121121

122122
$html .= sprintf('<span%s>#%s &raquo; ', $isProjectFile ? ' class="sfWebDebugHighlight"' : '', $keys[$j] + 1);
123123

0 commit comments

Comments
 (0)