mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
Applied code style rules to src/
This commit is contained in:
parent
700c049d26
commit
f861de791f
186 changed files with 1462 additions and 1059 deletions
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -299,7 +302,7 @@ class PermissionsEmbed
|
|||
*/
|
||||
public function isValidPermissionName(string $permission_name): bool
|
||||
{
|
||||
return isset($this->$permission_name);
|
||||
return isset($this->{$permission_name});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,11 +315,11 @@ class PermissionsEmbed
|
|||
*/
|
||||
public function getBitValue(string $permission_name, int $bit_n): int
|
||||
{
|
||||
if (!$this->isValidPermissionName($permission_name)) {
|
||||
if (! $this->isValidPermissionName($permission_name)) {
|
||||
throw new \InvalidArgumentException(sprintf('No permission with the name "%s" is existing!', $permission_name));
|
||||
}
|
||||
|
||||
$perm_int = $this->$permission_name;
|
||||
$perm_int = (int) $this->{$permission_name};
|
||||
|
||||
return static::readBitPair($perm_int, $bit_n);
|
||||
}
|
||||
|
@ -382,11 +385,11 @@ class PermissionsEmbed
|
|||
*/
|
||||
public function setBitValue(string $permission_name, int $bit_n, int $new_value): self
|
||||
{
|
||||
if (!$this->isValidPermissionName($permission_name)) {
|
||||
if (! $this->isValidPermissionName($permission_name)) {
|
||||
throw new \InvalidArgumentException('No permission with the given name is existing!');
|
||||
}
|
||||
|
||||
$this->$permission_name = static::writeBitPair($this->$permission_name, $bit_n, $new_value);
|
||||
$this->{$permission_name} = static::writeBitPair($this->{$permission_name}, $bit_n, $new_value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -401,11 +404,11 @@ class PermissionsEmbed
|
|||
*/
|
||||
public function getRawPermissionValue(string $permission_name): int
|
||||
{
|
||||
if (!$this->isValidPermissionName($permission_name)) {
|
||||
if (! $this->isValidPermissionName($permission_name)) {
|
||||
throw new \InvalidArgumentException('No permission with the given name is existing!');
|
||||
}
|
||||
|
||||
return $this->$permission_name;
|
||||
return $this->{$permission_name};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -418,11 +421,11 @@ class PermissionsEmbed
|
|||
*/
|
||||
public function setRawPermissionValue(string $permission_name, int $value): self
|
||||
{
|
||||
if (!$this->isValidPermissionName($permission_name)) {
|
||||
if (! $this->isValidPermissionName($permission_name)) {
|
||||
throw new \InvalidArgumentException(sprintf('No permission with the given name %s is existing!', $permission_name));
|
||||
}
|
||||
|
||||
$this->$permission_name = $value;
|
||||
$this->{$permission_name} = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -436,9 +439,9 @@ class PermissionsEmbed
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRawPermissionValues(array $values, array $values2 = null): self
|
||||
public function setRawPermissionValues(array $values, ?array $values2 = null): self
|
||||
{
|
||||
if (!empty($values2)) {
|
||||
if (! empty($values2)) {
|
||||
$values = array_combine($values, $values2);
|
||||
}
|
||||
|
||||
|
@ -452,12 +455,12 @@ class PermissionsEmbed
|
|||
/**
|
||||
* Reads a bit pair from $data.
|
||||
*
|
||||
* @param $data int The data from where the bits should be extracted from
|
||||
* @param $n int The number of the lower bit (of the pair) that should be read. Starting from zero.
|
||||
* @param int|string $data The data from where the bits should be extracted from
|
||||
* @param int $n The number of the lower bit (of the pair) that should be read. Starting from zero.
|
||||
*
|
||||
* @return int the value of the bit pair
|
||||
*/
|
||||
final protected static function readBitPair(int $data, int $n): int
|
||||
final protected static function readBitPair($data, int $n): int
|
||||
{
|
||||
Assert::lessThanEq($n, 31, '$n must be smaller than 32, because only a 32bit int is used! Got %s.');
|
||||
if (0 !== $n % 2) {
|
||||
|
@ -471,9 +474,9 @@ class PermissionsEmbed
|
|||
/**
|
||||
* Writes a bit pair in the given $data and returns it.
|
||||
*
|
||||
* @param $data int The data which should be modified
|
||||
* @param $n int The number of the lower bit of the pair which should be written
|
||||
* @param $new int The new value of the pair
|
||||
* @param int $data The data which should be modified
|
||||
* @param int $n The number of the lower bit of the pair which should be written
|
||||
* @param int $new The new value of the pair
|
||||
*
|
||||
* @return int the new data with the modified pair
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -38,13 +41,6 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
{
|
||||
use TimestampTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64)
|
||||
*
|
||||
|
@ -73,6 +69,13 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
**/
|
||||
public $counter;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="u2fKeys")
|
||||
*
|
||||
|
@ -95,62 +98,52 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
$this->counter = $data->counter;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getKeyHandle()
|
||||
{
|
||||
return $this->keyHandle;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function setKeyHandle($keyHandle)
|
||||
public function setKeyHandle($keyHandle): void
|
||||
{
|
||||
$this->keyHandle = $keyHandle;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getPublicKey()
|
||||
{
|
||||
return $this->publicKey;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function setPublicKey($publicKey)
|
||||
public function setPublicKey($publicKey): void
|
||||
{
|
||||
$this->publicKey = $publicKey;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getCertificate()
|
||||
{
|
||||
return $this->certificate;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function setCertificate($certificate)
|
||||
public function setCertificate($certificate): void
|
||||
{
|
||||
$this->certificate = $certificate;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getCounter()
|
||||
{
|
||||
return $this->counter;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function setCounter($counter)
|
||||
public function setCounter($counter): void
|
||||
{
|
||||
$this->counter = $counter;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function setName($name)
|
||||
public function setName($name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
|
|
@ -266,6 +266,19 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
$this->u2fKeys = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this user (the full name).
|
||||
* E.g. 'Jane Doe (j.doe) [DISABLED].
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$tmp = $this->isDisabled() ? ' [DISABLED]' : '';
|
||||
|
||||
return $this->getFullName(true).$tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current user, is the user which represents the not logged in (anonymous) users.
|
||||
*
|
||||
|
@ -330,7 +343,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function getSalt()
|
||||
public function getSalt(): void
|
||||
{
|
||||
// not needed when using the "bcrypt" algorithm in security.yaml
|
||||
}
|
||||
|
@ -338,7 +351,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function eraseCredentials()
|
||||
public function eraseCredentials(): void
|
||||
{
|
||||
// If you store any temporary, sensitive data on the user, clear it here
|
||||
// $this->plainPassword = null;
|
||||
|
@ -503,7 +516,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
public function setName(string $new_name): NamedDBElement
|
||||
{
|
||||
// Anonymous user is not allowed to change its username
|
||||
if (!$this->isAnonymousUser()) {
|
||||
if (! $this->isAnonymousUser()) {
|
||||
$this->name = $new_name;
|
||||
}
|
||||
|
||||
|
@ -646,8 +659,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* Change the timezone of this user.
|
||||
*
|
||||
* @param string $timezone|null The new timezone (e.g. 'Europe/Berlin') or null to use the system wide one.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimezone(?string $timezone): self
|
||||
|
@ -706,19 +717,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this user (the full name).
|
||||
* E.g. 'Jane Doe (j.doe) [DISABLED].
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$tmp = $this->isDisabled() ? ' [DISABLED]' : '';
|
||||
|
||||
return $this->getFullName(true).$tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the user should do two-factor authentication.
|
||||
*
|
||||
|
@ -771,7 +769,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
*/
|
||||
public function isBackupCode(string $code): bool
|
||||
{
|
||||
return \in_array($code, $this->backupCodes);
|
||||
return \in_array($code, $this->backupCodes, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -781,7 +779,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
*/
|
||||
public function invalidateBackupCode(string $code): void
|
||||
{
|
||||
$key = array_search($code, $this->backupCodes);
|
||||
$key = array_search($code, $this->backupCodes, true);
|
||||
if (false !== $key) {
|
||||
unset($this->backupCodes[$key]);
|
||||
}
|
||||
|
@ -883,9 +881,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
$this->u2fKeys->removeElement($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPreferredTwoFactorProvider(): ?string
|
||||
{
|
||||
//If U2F is available then prefer it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue