Applied rector with PHP8.1 migration rules

This commit is contained in:
Jan Böhmer 2023-06-11 14:15:46 +02:00
parent dc6a67c2f0
commit 7ee01d9a05
303 changed files with 1228 additions and 3465 deletions

View file

@ -45,7 +45,7 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Index(name: 'currency_idx_parent_name', columns: ['parent_id', 'name'])]
class Currency extends AbstractStructuralDBElement
{
public const PRICE_SCALE = 5;
final public const PRICE_SCALE = 5;
/**
* @var BigDecimal|null The exchange rate between this currency and the base currency
@ -69,26 +69,26 @@ class Currency extends AbstractStructuralDBElement
#[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id')]
protected ?AbstractStructuralDBElement $parent;
protected ?AbstractStructuralDBElement $parent = null;
/**
* @var Collection<int, CurrencyAttachment>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CurrencyAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\CurrencyAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
protected Collection $attachments;
/** @var Collection<int, CurrencyParameter>
*/
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\CurrencyParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\CurrencyParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
protected Collection $parameters;
/** @var Collection<int, Pricedetail>
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Pricedetail', mappedBy: 'currency')]
#[ORM\OneToMany(targetEntity: \App\Entity\PriceInformations\Pricedetail::class, mappedBy: 'currency')]
protected Collection $pricedetails;
public function __construct()
@ -115,11 +115,6 @@ class Currency extends AbstractStructuralDBElement
return $this->iso_code;
}
/**
* @param string|null $iso_code
*
* @return Currency
*/
public function setIsoCode(?string $iso_code): self
{
$this->iso_code = $iso_code;
@ -134,7 +129,7 @@ class Currency extends AbstractStructuralDBElement
{
$tmp = $this->getExchangeRate();
if (null === $tmp || $tmp->isZero()) {
if (!$tmp instanceof \Brick\Math\BigDecimal || $tmp->isZero()) {
return null;
}
@ -155,12 +150,10 @@ class Currency extends AbstractStructuralDBElement
*
* @param BigDecimal|null $exchange_rate The new exchange rate of the currency.
* Set to null, if the exchange rate is unknown.
*
* @return Currency
*/
public function setExchangeRate(?BigDecimal $exchange_rate): self
{
if (null === $exchange_rate) {
if (!$exchange_rate instanceof \Brick\Math\BigDecimal) {
$this->exchange_rate = null;
}
$tmp = $exchange_rate->toScale(self::PRICE_SCALE, RoundingMode::HALF_UP);

View file

@ -81,7 +81,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @var Part|null
*/
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'orderdetails')]
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Part::class, inversedBy: 'orderdetails')]
#[ORM\JoinColumn(name: 'part_id', nullable: false, onDelete: 'CASCADE')]
protected ?Part $part = null;
@ -90,7 +90,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
*/
#[Assert\NotNull(message: 'validator.orderdetail.supplier_must_not_be_null')]
#[Groups(['extended', 'full', 'import'])]
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'orderdetails')]
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Supplier::class, inversedBy: 'orderdetails')]
#[ORM\JoinColumn(name: 'id_supplier')]
protected ?Supplier $supplier = null;
@ -121,7 +121,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
public function updateTimestamps(): void
{
$this->lastModified = new DateTime('now');
if (null === $this->addedDate) {
if (!$this->addedDate instanceof \DateTimeInterface) {
$this->addedDate = new DateTime('now');
}
@ -194,7 +194,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
return $this->supplier_product_url;
}
if (null === $this->getSupplier()) {
if (!$this->getSupplier() instanceof \App\Entity\Parts\Supplier) {
return '';
}
@ -216,8 +216,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* Adds a price detail to this orderdetail.
*
* @param Pricedetail $pricedetail The pricedetail to add
*
* @return Orderdetail
*/
public function addPricedetail(Pricedetail $pricedetail): self
{
@ -229,8 +227,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
/**
* Removes a price detail from this orderdetail.
*
* @return Orderdetail
*/
public function removePricedetail(Pricedetail $pricedetail): self
{
@ -273,11 +269,8 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* Setters
*
*********************************************************************************/
/**
* Sets a new part with which this orderdetail is associated.
*
* @return Orderdetail
*/
public function setPart(Part $part): self
{
@ -288,8 +281,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
/**
* Sets the new supplier associated with this orderdetail.
*
* @return Orderdetail
*/
public function setSupplier(Supplier $new_supplier): self
{
@ -302,9 +293,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* Set the supplier part-nr.
*
* @param string $new_supplierpartnr the new supplier-part-nr
*
* @return Orderdetail
* @return Orderdetail
*/
public function setSupplierpartnr(string $new_supplierpartnr): self
{
@ -317,9 +305,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* Set if the part is obsolete at the supplier of that orderdetails.
*
* @param bool $new_obsolete true means that this part is obsolete
*
* @return Orderdetail
* @return Orderdetail
*/
public function setObsolete(bool $new_obsolete): self
{
@ -333,8 +318,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* Set this to "", if the function getSupplierProductURL should return the automatic generated URL.
*
* @param string $new_url The new URL for the supplier URL
*
* @return Orderdetail
*/
public function setSupplierProductUrl(string $new_url): self
{

View file

@ -48,7 +48,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
{
use TimestampTrait;
public const PRICE_PRECISION = 5;
final public const PRICE_PRECISION = 5;
/**
* @var BigDecimal The price related to the detail. (Given in the selected currency)
@ -119,7 +119,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
public function updateTimestamps(): void
{
$this->lastModified = new DateTime('now');
if (null === $this->addedDate) {
if (!$this->addedDate instanceof \DateTimeInterface) {
$this->addedDate = new DateTime('now');
}
@ -166,7 +166,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
*
* @return BigDecimal the price as a bcmath string
*/
public function getPricePerUnit($multiplier = 1.0): BigDecimal
public function getPricePerUnit(float|string|\Brick\Math\BigDecimal $multiplier = 1.0): BigDecimal
{
$tmp = BigDecimal::of($multiplier);
$tmp = $tmp->multipliedBy($this->price);
@ -248,8 +248,6 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
/**
* Sets the currency associated with the price information.
* Set to null, to use the global base currency.
*
* @return Pricedetail
*/
public function setCurrency(?Currency $currency): self
{