From 71c4808140aa85d21d995fc53ff428196c229559 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 22 Sep 2021 11:56:37 +0200 Subject: [PATCH] Replace use of `StringUtil::endsWith()` by `\str_ends_with()` --- .../install/files/lib/acp/form/ApplicationEditForm.class.php | 2 +- .../files/lib/acp/form/ApplicationManagementForm.class.php | 2 +- .../files/lib/acp/form/PackageUpdateServerAddForm.class.php | 2 +- .../files/lib/data/application/ApplicationAction.class.php | 3 +-- .../install/files/lib/data/attachment/Attachment.class.php | 3 +-- wcfsetup/install/files/lib/data/style/StyleEditor.class.php | 2 +- wcfsetup/install/files/lib/system/acl/ACLHandler.class.php | 3 +-- wcfsetup/install/files/lib/util/HeaderUtil.class.php | 4 ++-- wcfsetup/install/files/lib/util/Url.class.php | 2 +- 9 files changed, 10 insertions(+), 13 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php b/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php index 5de2feb987..1e761a9ce6 100644 --- a/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php @@ -171,7 +171,7 @@ class ApplicationEditForm extends AbstractForm $this->cookieDomain = $regex->replace($this->cookieDomain, ''); // check if cookie domain shares the same domain (may exclude subdomains) - if (!StringUtil::endsWith($regex->replace($this->domainName, ''), $this->cookieDomain)) { + if (!\str_ends_with($regex->replace($this->domainName, ''), $this->cookieDomain)) { throw new UserInputException('cookieDomain', 'invalid'); } } diff --git a/wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php b/wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php index a3ca319be2..edb6fdeda5 100644 --- a/wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php @@ -125,7 +125,7 @@ final class ApplicationManagementForm extends AbstractForm $this->cookieDomain = $regex->replace($this->cookieDomain, ''); // check if cookie domain shares the same domain (may exclude subdomains) - if (!StringUtil::endsWith($regex->replace($this->domainName, ''), $this->cookieDomain)) { + if (!\str_ends_with($regex->replace($this->domainName, ''), $this->cookieDomain)) { throw new UserInputException('cookieDomain', 'invalid'); } } diff --git a/wcfsetup/install/files/lib/acp/form/PackageUpdateServerAddForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageUpdateServerAddForm.class.php index 30d54df781..bdc2f6c686 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageUpdateServerAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageUpdateServerAddForm.class.php @@ -93,7 +93,7 @@ class PackageUpdateServerAddForm extends AbstractForm throw new UserInputException('serverURL', 'invalid'); } - if (StringUtil::endsWith(Url::parse($this->serverURL)['host'], '.woltlab.com', true)) { + if (\str_ends_with(Url::parse($this->serverURL)['host'], '.woltlab.com', true)) { throw new UserInputException('serverURL', 'woltlab'); } diff --git a/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php b/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php index e8dbdf179e..21fcdd5e37 100644 --- a/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php +++ b/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php @@ -7,7 +7,6 @@ use wcf\system\cache\builder\ApplicationCacheBuilder; use wcf\system\language\LanguageFactory; use wcf\system\Regex; use wcf\system\WCF; -use wcf\util\StringUtil; /** * Executes application-related actions. @@ -53,7 +52,7 @@ class ApplicationAction extends AbstractDatabaseObjectAction WCF::getDB()->beginTransaction(); foreach ($this->getObjects() as $application) { $domainName = $application->domainName; - if (StringUtil::endsWith($regex->replace($domainName, ''), $application->cookieDomain)) { + if (\str_ends_with($regex->replace($domainName, ''), $application->cookieDomain)) { $domainName = $application->cookieDomain; } diff --git a/wcfsetup/install/files/lib/data/attachment/Attachment.class.php b/wcfsetup/install/files/lib/data/attachment/Attachment.class.php index 7be261a006..6d8559bf1e 100644 --- a/wcfsetup/install/files/lib/data/attachment/Attachment.class.php +++ b/wcfsetup/install/files/lib/data/attachment/Attachment.class.php @@ -10,7 +10,6 @@ use wcf\system\request\IRouteController; use wcf\system\request\LinkHandler; use wcf\system\WCF; use wcf\util\FileUtil; -use wcf\util\StringUtil; /** * Represents an attachment. @@ -199,7 +198,7 @@ class Attachment extends DatabaseObject implements ILinkableObject, IRouteContro $this->getThumbnailLocation('tiny'), ] as $location ) { - if (!StringUtil::endsWith($location, '.bin')) { + if (!\str_ends_with($location, '.bin')) { \rename($location, $location . '.bin'); } } diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index 045f2fec16..10d34b8660 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -545,7 +545,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject // copy templates foreach ($templates as $template) { - if (!StringUtil::endsWith($template['filename'], '.tpl')) { + if (!\str_ends_with($template['filename'], '.tpl')) { continue; } diff --git a/wcfsetup/install/files/lib/system/acl/ACLHandler.class.php b/wcfsetup/install/files/lib/system/acl/ACLHandler.class.php index 07b5a4df9f..92e0aef46f 100644 --- a/wcfsetup/install/files/lib/system/acl/ACLHandler.class.php +++ b/wcfsetup/install/files/lib/system/acl/ACLHandler.class.php @@ -14,7 +14,6 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; use wcf\system\SingletonFactory; use wcf\system\WCF; -use wcf\util\StringUtil; /** * Handles ACL permissions. @@ -446,7 +445,7 @@ class ACLHandler extends SingletonFactory { $optionList = new ACLOptionList(); if (!empty($categoryName)) { - if (StringUtil::endsWith($categoryName, '.*')) { + if (\str_ends_with($categoryName, '.*')) { $categoryName = \mb_substr($categoryName, 0, -1) . '%'; $optionList->getConditionBuilder()->add("acl_option.categoryName LIKE ?", [$categoryName]); } else { diff --git a/wcfsetup/install/files/lib/util/HeaderUtil.class.php b/wcfsetup/install/files/lib/util/HeaderUtil.class.php index 5eca0e76fd..effb548e33 100644 --- a/wcfsetup/install/files/lib/util/HeaderUtil.class.php +++ b/wcfsetup/install/files/lib/util/HeaderUtil.class.php @@ -65,10 +65,10 @@ final class HeaderUtil $addDomain = (\mb_strpos( $application->cookieDomain, '.' - ) === false || StringUtil::endsWith( + ) === false || \str_ends_with( $application->cookieDomain, '.lan' - ) || StringUtil::endsWith($application->cookieDomain, '.local')) ? false : true; + ) || \str_ends_with($application->cookieDomain, '.local')) ? false : true; if (!$addDomain) { return null; diff --git a/wcfsetup/install/files/lib/util/Url.class.php b/wcfsetup/install/files/lib/util/Url.class.php index 4a0b0aec8d..e24ed95fba 100644 --- a/wcfsetup/install/files/lib/util/Url.class.php +++ b/wcfsetup/install/files/lib/util/Url.class.php @@ -208,7 +208,7 @@ final class Url implements \ArrayAccess if ($isWildcard && \mb_strpos($hostname, $host) !== false) { // the prepended dot will ensure that `example.com` matches only // on domains like `foo.example.com` but not on `bar-example.com` - if (StringUtil::endsWith($hostname, '.' . $host)) { + if (\str_ends_with($hostname, '.' . $host)) { $validHosts[$hostname] = $hostname; return true; -- 2.20.1