Added declare strict types to all files

This commit is contained in:
Jan Böhmer 2023-06-11 18:59:07 +02:00
parent bea90a7d94
commit 6a2ff9d153
196 changed files with 685 additions and 360 deletions

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters;
use App\DataTables\Filters\Constraints\BooleanConstraint;
@ -102,4 +104,4 @@ class AttachmentFilter implements FilterInterface
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters;
use Doctrine\Common\Collections\Collection;
@ -70,4 +72,4 @@ trait CompoundFilterTrait
$filter->apply($queryBuilder);
}
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use App\DataTables\Filters\FilterInterface;
@ -45,4 +47,4 @@ abstract class AbstractConstraint implements FilterInterface
{
$this->identifier = $identifier ?? $this->generateParameterIdentifier($property);
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use Doctrine\ORM\QueryBuilder;
@ -61,4 +63,4 @@ class BooleanConstraint extends AbstractConstraint
$this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier, '=', $this->value);
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use Doctrine\ORM\QueryBuilder;
@ -68,7 +70,7 @@ class ChoiceConstraint extends AbstractConstraint
public function isEnabled(): bool
{
return !empty($this->operator);
return $this->operator !== '';
}
public function apply(QueryBuilder $queryBuilder): void
@ -91,4 +93,4 @@ class ChoiceConstraint extends AbstractConstraint
throw new \RuntimeException('Unknown operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES));
}
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
/**
@ -25,4 +27,4 @@ namespace App\DataTables\Filters\Constraints;
*/
class DateTimeConstraint extends NumberConstraint
{
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use App\Entity\Base\AbstractDBElement;
@ -112,7 +114,7 @@ class EntityConstraint extends AbstractConstraint
public function isEnabled(): bool
{
return !empty($this->operator);
return $this->operator !== null && $this->operator !== '';
}
public function apply(QueryBuilder $queryBuilder): void
@ -167,4 +169,4 @@ class EntityConstraint extends AbstractConstraint
}
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use Doctrine\ORM\QueryBuilder;
@ -71,4 +73,4 @@ trait FilterTrait
$queryBuilder->setParameter($parameterIdentifier, $value);
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use Doctrine\ORM\QueryBuilder;
@ -75,7 +77,7 @@ class InstanceOfConstraint extends AbstractConstraint
public function isEnabled(): bool
{
return !empty($this->operator);
return $this->operator !== '';
}
public function apply(QueryBuilder $queryBuilder): void
@ -107,4 +109,4 @@ class InstanceOfConstraint extends AbstractConstraint
throw new \RuntimeException('Unknown operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES));
}
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use Doctrine\ORM\QueryBuilder;
@ -35,4 +37,4 @@ class IntConstraint extends NumberConstraint
parent::apply($queryBuilder);
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use Doctrine\ORM\QueryBuilder;
@ -82,7 +84,7 @@ class NumberConstraint extends AbstractConstraint
public function isEnabled(): bool
{
return $this->value1 !== null
&& !empty($this->operator);
&& ($this->operator !== null && $this->operator !== '');
}
public function apply(QueryBuilder $queryBuilder): void
@ -108,4 +110,4 @@ class NumberConstraint extends AbstractConstraint
$this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier . '2', '<=', $this->value2);
}
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints\Part;
use App\DataTables\Filters\Constraints\BooleanConstraint;
@ -44,4 +46,4 @@ class LessThanDesiredConstraint extends BooleanConstraint
$queryBuilder->andHaving('amountSum >= part.minamount');
}
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints\Part;
use App\DataTables\Filters\Constraints\AbstractConstraint;
@ -72,19 +74,19 @@ class ParameterConstraint extends AbstractConstraint
->from(PartParameter::class, $this->alias)
->where($this->alias . '.element = part');
if (!empty($this->name)) {
if ($this->name !== '') {
$paramName = $this->generateParameterIdentifier('params.name');
$subqb->andWhere($this->alias . '.name = :' . $paramName);
$queryBuilder->setParameter($paramName, $this->name);
}
if (!empty($this->symbol)) {
if ($this->symbol !== '') {
$paramName = $this->generateParameterIdentifier('params.symbol');
$subqb->andWhere($this->alias . '.symbol = :' . $paramName);
$queryBuilder->setParameter($paramName, $this->symbol);
}
if (!empty($this->unit)) {
if ($this->unit !== '') {
$paramName = $this->generateParameterIdentifier('params.unit');
$subqb->andWhere($this->alias . '.unit = :' . $paramName);
$queryBuilder->setParameter($paramName, $this->unit);
@ -147,4 +149,4 @@ class ParameterConstraint extends AbstractConstraint
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints\Part;
use App\DataTables\Filters\Constraints\NumberConstraint;
@ -141,4 +143,4 @@ class ParameterValueConstraint extends NumberConstraint
//For all other cases use the default implementation
parent::apply($queryBuilder);
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints\Part;
use Doctrine\ORM\Query\Expr\Orx;
@ -74,7 +76,7 @@ class TagsConstraint extends AbstractConstraint
public function isEnabled(): bool
{
return $this->value !== null
&& !empty($this->operator);
&& ($this->operator !== null && $this->operator !== '');
}
/**
@ -141,4 +143,4 @@ class TagsConstraint extends AbstractConstraint
return;
}
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters\Constraints;
use Doctrine\ORM\QueryBuilder;
@ -72,7 +74,7 @@ class TextConstraint extends AbstractConstraint
public function isEnabled(): bool
{
return $this->value !== null
&& !empty($this->operator);
&& ($this->operator !== null && $this->operator !== '');
}
public function apply(QueryBuilder $queryBuilder): void
@ -115,4 +117,4 @@ class TextConstraint extends AbstractConstraint
$queryBuilder->setParameter($this->identifier, $this->value);
}
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters;
use Doctrine\ORM\QueryBuilder;
@ -31,4 +33,4 @@ interface FilterInterface
* @return void
*/
public function apply(QueryBuilder $queryBuilder): void;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters;
use App\DataTables\Filters\Constraints\ChoiceConstraint;
@ -97,4 +99,4 @@ class LogFilter implements FilterInterface
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters;
use App\DataTables\Filters\Constraints\BooleanConstraint;

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\DataTables\Filters;
use Doctrine\ORM\Query\Expr;
@ -121,7 +123,7 @@ class PartSearchFilter implements FilterInterface
$fields_to_search = $this->getFieldsToSearch();
//If we have nothing to search for, do nothing
if ($fields_to_search === [] || empty($this->keyword)) {
if ($fields_to_search === [] || $this->keyword === '') {
return;
}
@ -302,4 +304,4 @@ class PartSearchFilter implements FilterInterface
}
}
}