mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-09 18:04:33 +02:00
Fixed some inspection issues.
This commit is contained in:
parent
eef26f7ae6
commit
639829f5c5
97 changed files with 305 additions and 185 deletions
|
@ -180,7 +180,7 @@ abstract class Attachment extends AbstractNamedDBElement
|
|||
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placeholder via explode
|
||||
$tmp = explode('/', $this->path);
|
||||
|
||||
return !in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER), false);
|
||||
return !in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
namespace App\Entity\Base;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JsonSerializable;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
|
@ -55,7 +56,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
* "user" = "App\Entity\User"
|
||||
* })
|
||||
*/
|
||||
abstract class AbstractDBElement implements \JsonSerializable
|
||||
abstract class AbstractDBElement implements JsonSerializable
|
||||
{
|
||||
/** @var int|null The Identification number for this part. This value is unique for the element in this table.
|
||||
* Null if the element is not saved to DB yet.
|
||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
|||
namespace App\Entity\Base;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
|||
namespace App\Entity\Base;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\Contracts;
|
||||
|
||||
use DateTime;
|
||||
|
||||
interface TimeTravelInterface
|
||||
{
|
||||
/**
|
||||
|
@ -41,5 +43,5 @@ interface TimeTravelInterface
|
|||
/**
|
||||
* Returns the the timestamp associated with this change.
|
||||
*/
|
||||
public function getTimestamp(): \DateTime;
|
||||
public function getTimestamp(): DateTime;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ use App\Entity\UserSystem\Group;
|
|||
use App\Entity\UserSystem\User;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
/**
|
||||
|
@ -263,7 +264,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
public function setLevel(int $level): self
|
||||
{
|
||||
if ($level < 0 || $this->level > 7) {
|
||||
throw new \InvalidArgumentException(sprintf('$level must be between 0 and 7! %d given!', $level));
|
||||
throw new InvalidArgumentException(sprintf('$level must be between 0 and 7! %d given!', $level));
|
||||
}
|
||||
$this->level = $level;
|
||||
|
||||
|
@ -387,7 +388,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
final public static function levelIntToString(int $level): string
|
||||
{
|
||||
if (!isset(self::LEVEL_ID_TO_STRING[$level])) {
|
||||
throw new \InvalidArgumentException('No level with this int is existing!');
|
||||
throw new InvalidArgumentException('No level with this int is existing!');
|
||||
}
|
||||
|
||||
return self::LEVEL_ID_TO_STRING[$level];
|
||||
|
@ -404,7 +405,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
{
|
||||
$tmp = array_flip(self::LEVEL_ID_TO_STRING);
|
||||
if (!isset($tmp[$level])) {
|
||||
throw new \InvalidArgumentException('No level with this string is existing!');
|
||||
throw new InvalidArgumentException('No level with this string is existing!');
|
||||
}
|
||||
|
||||
return $tmp[$level];
|
||||
|
@ -418,7 +419,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
final public static function targetTypeIdToClass(int $type_id): string
|
||||
{
|
||||
if (!isset(self::TARGET_CLASS_MAPPING[$type_id])) {
|
||||
throw new \InvalidArgumentException('No target type with this ID is existing!');
|
||||
throw new InvalidArgumentException('No target type with this ID is existing!');
|
||||
}
|
||||
|
||||
return self::TARGET_CLASS_MAPPING[$type_id];
|
||||
|
@ -446,6 +447,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
}
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('No target ID for this class is existing!');
|
||||
throw new InvalidArgumentException('No target ID for this class is existing!');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ use App\Entity\Base\AbstractDBElement;
|
|||
use App\Entity\Contracts\LogWithEventUndoInterface;
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
|
@ -104,7 +105,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
} elseif ('revert' === $mode) {
|
||||
$this->extra['um'] = 2;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
||||
throw new InvalidArgumentException('Passed invalid $mode!');
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -48,6 +48,7 @@ use App\Entity\Contracts\LogWithEventUndoInterface;
|
|||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\User;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
|
@ -120,7 +121,7 @@ class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentI
|
|||
} elseif ('revert' === $mode) {
|
||||
$this->extra['um'] = 2;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
||||
throw new InvalidArgumentException('Passed invalid $mode!');
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -50,6 +50,7 @@ use App\Entity\Contracts\TimeTravelInterface;
|
|||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\User;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
|
@ -153,7 +154,7 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
|
|||
} elseif ('revert' === $mode) {
|
||||
$this->extra['um'] = 2;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
||||
throw new InvalidArgumentException('Passed invalid $mode!');
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -47,6 +47,7 @@ use App\Entity\Contracts\LogWithCommentInterface;
|
|||
use App\Entity\Contracts\LogWithEventUndoInterface;
|
||||
use App\Entity\Contracts\TimeTravelInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
|
@ -157,7 +158,7 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
|
|||
} elseif ('revert' === $mode) {
|
||||
$this->extra['um'] = 2;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
||||
throw new InvalidArgumentException('Passed invalid $mode!');
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -27,6 +27,7 @@ use App\Entity\Base\AbstractDBElement;
|
|||
use App\Entity\UserSystem\User;
|
||||
use App\Events\SecurityEvents;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\HttpFoundation\IpUtils;
|
||||
|
||||
/**
|
||||
|
@ -60,7 +61,7 @@ class SecurityEventLogEntry extends AbstractLogEntry
|
|||
public function setTargetElement(?AbstractDBElement $element): AbstractLogEntry
|
||||
{
|
||||
if (!$element instanceof User) {
|
||||
throw new \InvalidArgumentException('Target element must be a User object!');
|
||||
throw new InvalidArgumentException('Target element must be a User object!');
|
||||
}
|
||||
|
||||
return parent::setTargetElement($element);
|
||||
|
@ -75,7 +76,7 @@ class SecurityEventLogEntry extends AbstractLogEntry
|
|||
{
|
||||
$key = array_search($type, static::SECURITY_TYPE_MAPPING, true);
|
||||
if (false === $key) {
|
||||
throw new \InvalidArgumentException('Given event type is not existing!');
|
||||
throw new InvalidArgumentException('Given event type is not existing!');
|
||||
}
|
||||
$this->extra['e'] = $key;
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ use InvalidArgumentException;
|
|||
use LogicException;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table("parameters")
|
||||
|
@ -376,7 +378,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
*/
|
||||
protected function formatWithUnit(float $value, string $format = '%g'): string
|
||||
{
|
||||
$str = \sprintf($format, $value);
|
||||
$str = sprintf($format, $value);
|
||||
if (!empty($this->unit)) {
|
||||
return $str.' '.$this->unit;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace App\Entity\Parts\PartTraits;
|
|||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Security\Annotations\ColumnSecurity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Advanced properties of a part, not related to a more specific group.
|
||||
|
|
|
@ -46,6 +46,7 @@ use App\Entity\Parts\Category;
|
|||
use App\Entity\Parts\Footprint;
|
||||
use App\Security\Annotations\ColumnSecurity;
|
||||
use App\Validator\Constraints\Selectable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
trait BasicPropertyTrait
|
||||
|
|
|
@ -46,6 +46,8 @@ use App\Entity\Parts\MeasurementUnit;
|
|||
use App\Entity\Parts\PartLot;
|
||||
use App\Security\Annotations\ColumnSecurity;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* This trait collects all aspects of a part related to instock, part lots.
|
||||
|
|
|
@ -46,6 +46,8 @@ use App\Entity\Parts\Manufacturer;
|
|||
use App\Entity\Parts\Part;
|
||||
use App\Security\Annotations\ColumnSecurity;
|
||||
use App\Validator\Constraints\Selectable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* In this trait all manufacturer related properties of a part are collected (like MPN, manufacturer URL).
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace App\Entity\Parts\PartTraits;
|
|||
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Security\Annotations\ColumnSecurity;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use function count;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
|
|
@ -235,7 +235,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
|
||||
$tmp = round($this->min_discount_quantity);
|
||||
|
||||
return $tmp < 1 ? 1 : $tmp;
|
||||
return max($tmp, 1);
|
||||
}
|
||||
|
||||
return $this->min_discount_quantity;
|
||||
|
|
|
@ -518,8 +518,6 @@ class PermissionsEmbed
|
|||
|
||||
$mask = 0b11 << $n; //Mask all bits that should be written
|
||||
$newval = $new << $n; //The new value.
|
||||
$data = ($data & ~$mask) | ($newval & $mask);
|
||||
|
||||
return $data;
|
||||
return ($data & ~$mask) | ($newval & $mask);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -721,7 +721,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
*/
|
||||
public function isGoogleAuthenticatorEnabled(): bool
|
||||
{
|
||||
return $this->googleAuthenticatorSecret ? true : false;
|
||||
return (bool)$this->googleAuthenticatorSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue