mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 21:48:41 +00:00
replace stripos with str_starts_with
This commit is contained in:
parent
5d66591a55
commit
13bf197ac7
|
|
@ -263,7 +263,7 @@ final class ReadMapper extends DataMapperAbstract
|
||||||
$result = $this->executeGet($query);
|
$result = $this->executeGet($query);
|
||||||
|
|
||||||
if (\is_object($result)
|
if (\is_object($result)
|
||||||
&& (\stripos($class = \get_class($result), 'Null') === 0 || \stripos($class, '\Null') !== false)
|
&& (\str_starts_with($class = \get_class($result), 'Null') || \stripos($class, '\Null') !== false)
|
||||||
) {
|
) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,7 @@ class Grammar extends GrammarAbstract
|
||||||
$expression .= $element['column']();
|
$expression .= $element['column']();
|
||||||
} elseif ($element['column'] instanceof Where) {
|
} elseif ($element['column'] instanceof Where) {
|
||||||
$where = \rtrim($this->compileWhereQuery($element['column']), ';');
|
$where = \rtrim($this->compileWhereQuery($element['column']), ';');
|
||||||
$expression .= '(' . (\stripos($where, 'WHERE ') === 0 ? \substr($where, 6) : $where) . ')';
|
$expression .= '(' . (\str_starts_with($where, 'WHERE ') ? \substr($where, 6) : $where) . ')';
|
||||||
} elseif ($element['column'] instanceof Builder) {
|
} elseif ($element['column'] instanceof Builder) {
|
||||||
$expression .= '(' . \rtrim($element['column']->toSql(), ';') . ')';
|
$expression .= '(' . \rtrim($element['column']->toSql(), ';') . ')';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,12 +175,12 @@ final class EventManager implements \Countable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$groupIsRegex = \stripos($group, '/') === 0;
|
$groupIsRegex = \str_starts_with($group, '/');
|
||||||
$idIsRegex = \stripos($id, '/') === 0;
|
$idIsRegex = \str_starts_with($id, '/');
|
||||||
|
|
||||||
$groups = [];
|
$groups = [];
|
||||||
foreach ($this->groups as $groupName => $_) {
|
foreach ($this->groups as $groupName => $_) {
|
||||||
$groupNameIsRegex = \stripos($groupName, '/') === 0;
|
$groupNameIsRegex = \str_starts_with($groupName, '/');
|
||||||
|
|
||||||
if ($groupIsRegex) {
|
if ($groupIsRegex) {
|
||||||
if (\preg_match($group, $groupName) === 1) {
|
if (\preg_match($group, $groupName) === 1) {
|
||||||
|
|
@ -195,7 +195,7 @@ final class EventManager implements \Countable
|
||||||
|
|
||||||
foreach ($groups as $groupName => $_) {
|
foreach ($groups as $groupName => $_) {
|
||||||
foreach ($this->groups[$groupName] as $idName => $_2) {
|
foreach ($this->groups[$groupName] as $idName => $_2) {
|
||||||
$idNameIsRegex = \stripos($idName, '/') === 0;
|
$idNameIsRegex = \str_starts_with($idName, '/');
|
||||||
|
|
||||||
if ($idIsRegex) {
|
if ($idIsRegex) {
|
||||||
if (\preg_match($id, $idName) === 1) {
|
if (\preg_match($id, $idName) === 1) {
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ final class HttpRequest extends RequestAbstract
|
||||||
while (($lineRaw = \fgets($stream)) !== false) {
|
while (($lineRaw = \fgets($stream)) !== false) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
// Tested but coverage doesn't show up
|
// Tested but coverage doesn't show up
|
||||||
if (\strpos($lineRaw, '--') === 0) {
|
if (\str_starts_with($lineRaw, '--')) {
|
||||||
if ($boundary === null) {
|
if ($boundary === null) {
|
||||||
$boundary = \rtrim($lineRaw);
|
$boundary = \rtrim($lineRaw);
|
||||||
}
|
}
|
||||||
|
|
@ -254,7 +254,7 @@ final class HttpRequest extends RequestAbstract
|
||||||
$lastLine = null;
|
$lastLine = null;
|
||||||
while (($lineRaw = \fgets($stream, 4096)) !== false) {
|
while (($lineRaw = \fgets($stream, 4096)) !== false) {
|
||||||
if ($lastLine !== null) {
|
if ($lastLine !== null) {
|
||||||
if ($boundary === null || \strpos($lineRaw, $boundary) === 0) {
|
if ($boundary === null || \str_starts_with($lineRaw, $boundary)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,7 +284,7 @@ final class HttpRequest extends RequestAbstract
|
||||||
$fullValue = '';
|
$fullValue = '';
|
||||||
$lastLine = null;
|
$lastLine = null;
|
||||||
|
|
||||||
while (($lineRaw = \fgets($stream)) !== false && $boundary !== null && \strpos($lineRaw, $boundary) !== 0) {
|
while (($lineRaw = \fgets($stream)) !== false && $boundary !== null && !\str_starts_with($lineRaw, $boundary)) {
|
||||||
if ($lastLine !== null) {
|
if ($lastLine !== null) {
|
||||||
$fullValue .= $lastLine;
|
$fullValue .= $lastLine;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ final class Rest
|
||||||
if (\count($header) < 2) {
|
if (\count($header) < 2) {
|
||||||
$response->header->set('', $line = \trim($header[0]));
|
$response->header->set('', $line = \trim($header[0]));
|
||||||
|
|
||||||
if (\stripos(\strtoupper($line), 'HTTP/') === 0) {
|
if (\str_starts_with(\strtoupper($line), 'HTTP/')) {
|
||||||
$statusCode = \explode(' ', $line, 3);
|
$statusCode = \explode(' ', $line, 3);
|
||||||
$response->header->status = (int) $statusCode[1];
|
$response->header->status = (int) $statusCode[1];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2036,7 +2036,7 @@ class Email implements MessageInterface
|
||||||
|
|
||||||
if (!empty($basedir)
|
if (!empty($basedir)
|
||||||
&& (\strpos($url, '..') === false)
|
&& (\strpos($url, '..') === false)
|
||||||
&& \strpos($url, 'cid:') !== 0
|
&& !\str_starts_with($url, 'cid:')
|
||||||
&& !\preg_match('#^[a-z][a-z0-9+.-]*:?//#i', $url)
|
&& !\preg_match('#^[a-z][a-z0-9+.-]*:?//#i', $url)
|
||||||
) {
|
) {
|
||||||
$filename = FileUtils::mb_pathinfo($url, \PATHINFO_BASENAME);
|
$filename = FileUtils::mb_pathinfo($url, \PATHINFO_BASENAME);
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ class Smtp
|
||||||
|
|
||||||
// SMTP server can take longer to respond, give longer timeout for first read
|
// SMTP server can take longer to respond, give longer timeout for first read
|
||||||
// Windows does not have support for this timeout function
|
// Windows does not have support for this timeout function
|
||||||
if (\strpos(\PHP_OS, 'WIN') !== 0) {
|
if (!\str_starts_with(\PHP_OS, 'WIN')) {
|
||||||
$max = (int) \ini_get('max_execution_time');
|
$max = (int) \ini_get('max_execution_time');
|
||||||
if ($max !== 0 && $timeout > $max && \strpos(\ini_get('disable_functions'), 'set_time_limit') === false) {
|
if ($max !== 0 && $timeout > $max && \strpos(\ini_get('disable_functions'), 'set_time_limit') === false) {
|
||||||
\set_time_limit($timeout);
|
\set_time_limit($timeout);
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ final class Guard
|
||||||
*/
|
*/
|
||||||
public static function isSafePath(string $path, string $base = '') : bool
|
public static function isSafePath(string $path, string $base = '') : bool
|
||||||
{
|
{
|
||||||
return \stripos(
|
return \str_starts_with(
|
||||||
FileUtils::absolute($path),
|
FileUtils::absolute($path),
|
||||||
FileUtils::absolute(empty($base) ? self::$BASE_PATH : $base)
|
FileUtils::absolute(empty($base) ? self::$BASE_PATH : $base)
|
||||||
) === 0;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ final class FileUtils
|
||||||
return $path === false ? '' : $path;
|
return $path === false ? '' : $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$startsWithSlash = \strpos($origPath, '/') === 0 || \strpos($origPath, '\\') === 0 ? '/' : '';
|
$startsWithSlash = \str_starts_with($origPath, '/') || \str_starts_with($origPath, '\\') ? '/' : '';
|
||||||
|
|
||||||
$path = [];
|
$path = [];
|
||||||
$parts = \explode('/', $origPath);
|
$parts = \explode('/', $origPath);
|
||||||
|
|
@ -260,7 +260,7 @@ final class FileUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
$readable = \is_file($path);
|
$readable = \is_file($path);
|
||||||
if (\strpos($path, '\\\\') !== 0) {
|
if (!\str_starts_with($path, '\\\\')) {
|
||||||
$readable = $readable && \is_readable($path);
|
$readable = $readable && \is_readable($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ final class Argument implements UriInterface
|
||||||
$uriParts = \explode(' ', $uri);
|
$uriParts = \explode(' ', $uri);
|
||||||
|
|
||||||
// Handle no path information only data
|
// Handle no path information only data
|
||||||
$uriParts = \stripos($uriParts[0], '-') === 0 ? ['/', $uriParts[0]] : $uriParts;
|
$uriParts = \str_starts_with($uriParts[0], '-') ? ['/', $uriParts[0]] : $uriParts;
|
||||||
|
|
||||||
$this->path = empty($uriParts) ? '' : \array_shift($uriParts);
|
$this->path = empty($uriParts) ? '' : \array_shift($uriParts);
|
||||||
$this->pathElements = \explode('/', \ltrim($this->path, '/'));
|
$this->pathElements = \explode('/', \ltrim($this->path, '/'));
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ final class UriFactory
|
||||||
self::$uri = [];
|
self::$uri = [];
|
||||||
} else {
|
} else {
|
||||||
foreach (self::$uri as $key => $_) {
|
foreach (self::$uri as $key => $_) {
|
||||||
if (\stripos($key, $identifier) === 0) {
|
if (\str_starts_with($key, $identifier)) {
|
||||||
unset(self::$uri[$key]);
|
unset(self::$uri[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ final class Numeric
|
||||||
$result = 0;
|
$result = 0;
|
||||||
|
|
||||||
foreach (self::ROMANS as $key => $value) {
|
foreach (self::ROMANS as $key => $value) {
|
||||||
while (\strpos($roman, $key) === 0) {
|
while (\str_starts_with($roman, $key)) {
|
||||||
$result += $value;
|
$result += $value;
|
||||||
$temp = \substr($roman, \strlen($key));
|
$temp = \substr($roman, \strlen($key));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2895,7 +2895,7 @@ class Markdown
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\strpos($Line['text'], '<!--') === 0)
|
if (\str_starts_with($Line['text'], '<!--'))
|
||||||
{
|
{
|
||||||
$Block = [
|
$Block = [
|
||||||
'element' => [
|
'element' => [
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ class PresentationWriter
|
||||||
|
|
||||||
foreach ($constants as $key => $value) {
|
foreach ($constants as $key => $value) {
|
||||||
if ($value === $search) {
|
if ($value === $search) {
|
||||||
if ($startWith === '' || \strpos($key, $startWith) === 0) {
|
if ($startWith === '' || \str_starts_with($key, $startWith)) {
|
||||||
$constName = $key;
|
$constName = $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user