- str_starts_with, str_contains used instead of strpos === 0, strpos !== 0, strpos === false, strpos !== false

- symfony/polyfill-php80 installed to introduce the polyfill and support php7.3 using php8 functions
- symfony/polyfill-ctype installed to introduce ctype functions in case somebody doesn't have the ctype extension installed
This commit is contained in:
ribas160
2025-01-04 00:46:20 +02:00
parent 15488d3405
commit f9e2373e62
29 changed files with 1367 additions and 555 deletions
+1 -1
View File
@@ -371,7 +371,7 @@ class GoogleCloudStorage extends AbstractData
try {
foreach ($this->_bucket->objects(array('prefix' => $prefix)) as $object) {
$candidate = substr($object->name(), strlen($prefix));
if (strpos($candidate, '/') === false) {
if (!str_contains($candidate, '/')) {
$pastes[] = $candidate;
}
}
+1 -1
View File
@@ -462,7 +462,7 @@ class S3Storage extends AbstractData
try {
foreach ($this->_listAllObjects($prefix) as $object) {
$candidate = substr($object['Key'], strlen($prefix));
if (strpos($candidate, '/') === false) {
if (!str_contains($candidate, '/')) {
$pastes[] = $candidate;
}
}
+1 -1
View File
@@ -130,7 +130,7 @@ class I18n
// encode any non-integer arguments and the message ID, if it doesn't contain a link
$argsCount = count($args);
for ($i = 0; $i < $argsCount; ++$i) {
if ($i > 0 ? !is_int($args[$i]) : strpos($args[0], '<a') === false) {
if ($i > 0 ? !is_int($args[$i]) : !str_contains($args[0], '<a')) {
$args[$i] = self::encode($args[$i]);
}
}
+7 -7
View File
@@ -146,7 +146,7 @@ class Request
} elseif (array_key_exists('jsonld', $this->_params) && !empty($this->_params['jsonld'])) {
$this->_operation = 'jsonld';
} elseif (array_key_exists('link', $this->_params) && !empty($this->_params['link'])) {
if (strpos($this->getRequestUri(), '/shortenviayourls') !== false || array_key_exists('shortenviayourls', $this->_params)) {
if (str_contains($this->getRequestUri(), '/shortenviayourls') || array_key_exists('shortenviayourls', $this->_params)) {
$this->_operation = 'yourlsproxy';
}
}
@@ -267,9 +267,9 @@ class Request
(array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) &&
$_SERVER['HTTP_X_REQUESTED_WITH'] == 'JSONHttpRequest') ||
($hasAcceptHeader &&
strpos($acceptHeader, self::MIME_JSON) !== false &&
strpos($acceptHeader, self::MIME_HTML) === false &&
strpos($acceptHeader, self::MIME_XHTML) === false)
str_contains($acceptHeader, self::MIME_JSON) &&
!str_contains($acceptHeader, self::MIME_HTML) &&
!str_contains($acceptHeader, self::MIME_XHTML))
) {
return true;
}
@@ -300,11 +300,11 @@ class Request
foreach ($mediaTypes as $acceptedQuality => $acceptedValues) {
foreach ($acceptedValues as $acceptedValue) {
if (
strpos($acceptedValue, self::MIME_HTML) === 0 ||
strpos($acceptedValue, self::MIME_XHTML) === 0
str_starts_with($acceptedValue, self::MIME_HTML) ||
str_starts_with($acceptedValue, self::MIME_XHTML)
) {
return false;
} elseif (strpos($acceptedValue, self::MIME_JSON) === 0) {
} elseif (str_starts_with($acceptedValue, self::MIME_JSON)) {
return true;
}
}
+1 -1
View File
@@ -47,7 +47,7 @@ class YourlsProxy
*/
public function __construct(Configuration $conf, $link)
{
if (strpos($link, $conf->getKey('basepath') . '?') !== 0) {
if (!str_starts_with($link, $conf->getKey('basepath') . '?')) {
$this->_error = 'Trying to shorten a URL that isn\'t pointing at our instance.';
return;
}