Browse Source

Merge pull request #48046 from nextcloud/refactor/self-class-reference

refactor: Replace __CLASS__ with ::class references
pull/48060/head
Anna 1 year ago
committed by GitHub
parent
commit
6892500405
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      apps/user_ldap/lib/LoginListener.php
  2. 6
      apps/user_ldap/lib/Service/UpdateGroupsService.php
  3. 2
      lib/private/Security/Bruteforce/Backend/MemoryCacheBackend.php
  4. 2
      lib/private/Security/RateLimiting/Backend/MemoryCacheBackend.php
  5. 2
      lib/public/Files/LockNotAcquiredException.php
  6. 2
      lib/public/HintException.php
  7. 4
      tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php

12
apps/user_ldap/lib/LoginListener.php

@ -42,7 +42,7 @@ class LoginListener implements IEventListener {
public function onPostLogin(IUser $user): void {
$this->logger->info(
__CLASS__ . ' - {user} postLogin',
self::class . ' - {user} postLogin',
[
'app' => 'user_ldap',
'user' => $user->getUID(),
@ -67,7 +67,7 @@ class LoginListener implements IEventListener {
$groupObject = $this->groupManager->get($groupId);
if ($groupObject === null) {
$this->logger->error(
__CLASS__ . ' - group {group} could not be found (user {user})',
self::class . ' - group {group} could not be found (user {user})',
[
'app' => 'user_ldap',
'user' => $userId,
@ -81,7 +81,7 @@ class LoginListener implements IEventListener {
} catch (Exception $e) {
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
$this->logger->error(
__CLASS__ . ' - group {group} membership failed to be added (user {user})',
self::class . ' - group {group} membership failed to be added (user {user})',
[
'app' => 'user_ldap',
'user' => $userId,
@ -96,7 +96,7 @@ class LoginListener implements IEventListener {
$this->groupBackend->addRelationshipToCaches($userId, null, $groupId);
$this->dispatcher->dispatchTyped(new UserAddedEvent($groupObject, $userObject));
$this->logger->info(
__CLASS__ . ' - {user} added to {group}',
self::class . ' - {user} added to {group}',
[
'app' => 'user_ldap',
'user' => $userId,
@ -110,7 +110,7 @@ class LoginListener implements IEventListener {
} catch (Exception $e) {
if ($e->getReason() !== Exception::REASON_DATABASE_OBJECT_NOT_FOUND) {
$this->logger->error(
__CLASS__ . ' - group {group} membership failed to be removed (user {user})',
self::class . ' - group {group} membership failed to be removed (user {user})',
[
'app' => 'user_ldap',
'user' => $userId,
@ -125,7 +125,7 @@ class LoginListener implements IEventListener {
$groupObject = $this->groupManager->get($groupId);
if ($groupObject === null) {
$this->logger->error(
__CLASS__ . ' - group {group} could not be found (user {user})',
self::class . ' - group {group} could not be found (user {user})',
[
'app' => 'user_ldap',
'user' => $userId,

6
apps/user_ldap/lib/Service/UpdateGroupsService.php

@ -90,7 +90,7 @@ class UpdateGroupsService {
if ($e->getReason() !== Exception::REASON_DATABASE_OBJECT_NOT_FOUND) {
/* If reason is not found something else removed the membership, that’s fine */
$this->logger->error(
__CLASS__ . ' - group {group} membership failed to be removed (user {user})',
self::class . ' - group {group} membership failed to be removed (user {user})',
[
'app' => 'user_ldap',
'user' => $removedUser,
@ -121,7 +121,7 @@ class UpdateGroupsService {
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
/* If reason is unique constraint something else added the membership, that’s fine */
$this->logger->error(
__CLASS__ . ' - group {group} membership failed to be added (user {user})',
self::class . ' - group {group} membership failed to be added (user {user})',
[
'app' => 'user_ldap',
'user' => $addedUser,
@ -167,7 +167,7 @@ class UpdateGroupsService {
} catch (Exception $e) {
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
$this->logger->error(
__CLASS__ . ' - group {group} membership failed to be added (user {user})',
self::class . ' - group {group} membership failed to be added (user {user})',
[
'app' => 'user_ldap',
'user' => $user,

2
lib/private/Security/Bruteforce/Backend/MemoryCacheBackend.php

@ -19,7 +19,7 @@ class MemoryCacheBackend implements IBackend {
ICacheFactory $cacheFactory,
private ITimeFactory $timeFactory,
) {
$this->cache = $cacheFactory->createDistributed(__CLASS__);
$this->cache = $cacheFactory->createDistributed(self::class);
}
private function hash(

2
lib/private/Security/RateLimiting/Backend/MemoryCacheBackend.php

@ -27,7 +27,7 @@ class MemoryCacheBackend implements IBackend {
ICacheFactory $cacheFactory,
private ITimeFactory $timeFactory,
) {
$this->cache = $cacheFactory->createDistributed(__CLASS__);
$this->cache = $cacheFactory->createDistributed(self::class);
}
private function hash(

2
lib/public/Files/LockNotAcquiredException.php

@ -35,6 +35,6 @@ class LockNotAcquiredException extends \Exception {
* @since 7.0.0
*/
public function __toString(): string {
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
return self::class . ": [{$this->code}]: {$this->message}\n";
}
}

2
lib/public/HintException.php

@ -43,7 +43,7 @@ class HintException extends \Exception {
* @return string
*/
public function __toString(): string {
return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
return self::class . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
}
/**

4
tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php

@ -72,7 +72,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testGetAnnotationParameterSingle() {
$reader = new ControllerMethodReflector();
$reader->reflect(
__CLASS__,
self::class,
__FUNCTION__
);
@ -85,7 +85,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testGetAnnotationParameterMultiple() {
$reader = new ControllerMethodReflector();
$reader->reflect(
__CLASS__,
self::class,
__FUNCTION__
);

Loading…
Cancel
Save