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\Form\AdminPages;
use App\Entity\Base\AbstractNamedDBElement;
@ -59,4 +61,4 @@ class ProjectAdminForm extends BaseEntityAdminForm
],
]);
}
}
}

View file

@ -144,7 +144,7 @@ class AttachmentFormType extends AbstractType
}
//If the name is empty, use the original file name as attachment name
if (empty($attachment->getName())) {
if ($attachment->getName() === '') {
$attachment->setName($file->getClientOriginalName());
}
}, 100000);

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\Form\Filters;
use App\DataTables\Filters\AttachmentFilter;
@ -114,4 +116,4 @@ class AttachmentFilterType extends AbstractType
'label' => 'filter.discard',
]);
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\BooleanConstraint;
@ -51,4 +53,4 @@ class BooleanConstraintType extends AbstractType
//Remove the label from the compound form, as the checkbox already has a label
$view->vars['label'] = false;
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\ChoiceConstraint;
@ -63,4 +65,4 @@ class ChoiceConstraintType extends AbstractType
]);
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\DateTimeConstraint;
@ -90,4 +92,4 @@ class DateTimeConstraintType extends AbstractType
$view->vars['text_suffix'] = $options['text_suffix'];
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\InstanceOfConstraint;
@ -40,4 +42,4 @@ class InstanceOfConstraintType extends AbstractType
{
return ChoiceConstraintType::class;
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\NumberConstraint;
@ -95,4 +97,4 @@ class NumberConstraintType extends AbstractType
{
$view->vars['text_suffix'] = $options['text_suffix'];
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\Part\ParameterConstraint;
@ -75,4 +77,4 @@ class ParameterConstraintType extends AbstractType
}
});
}
}
}

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\Form\Filters\Constraints;
class ParameterValueConstraintType extends NumberConstraintType
@ -48,4 +50,4 @@ class ParameterValueConstraintType extends NumberConstraintType
{
return NumberConstraintType::class;
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\EntityConstraint;
@ -70,4 +72,4 @@ class StructuralEntityConstraintType extends AbstractType
parent::buildView($view, $form, $options);
$view->vars['text_suffix'] = $options['text_suffix'];
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\Part\TagsConstraint;
@ -68,4 +70,4 @@ class TagsConstraintType extends AbstractType
'required' => false,
]);
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\TextConstraint;
@ -76,4 +78,4 @@ class TextConstraintType extends AbstractType
$view->vars['text_suffix'] = $options['text_suffix'];
}
}
}

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\Form\Filters\Constraints;
use App\DataTables\Filters\Constraints\EntityConstraint;
@ -65,4 +67,4 @@ class UserEntityConstraintType extends AbstractType
parent::buildView($view, $form, $options);
$view->vars['text_suffix'] = $options['text_suffix'];
}
}
}

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\Form\Filters;
use App\DataTables\Filters\LogFilter;
@ -168,4 +170,4 @@ class LogFilterType extends AbstractType
'label' => 'filter.discard',
]);
}
}
}

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\Form\Filters;
use App\DataTables\Filters\Constraints\Part\ParameterConstraint;
@ -277,4 +279,4 @@ class PartFilterType extends AbstractType
]);
}
}
}

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Form\ProjectSystem;
use Symfony\Component\Form\AbstractType;
@ -27,4 +29,4 @@ class ProjectBOMEntryCollectionType extends AbstractType
'label' => false,
]);
}
}
}

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Form\ProjectSystem;
use App\Entity\ProjectSystem\ProjectBOMEntry;
@ -87,4 +89,4 @@ class ProjectBOMEntryType extends AbstractType
'data_class' => ProjectBOMEntry::class,
]);
}
}
}

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\Form\ProjectSystem;
use Symfony\Bundle\SecurityBundle\Security;
@ -153,7 +155,7 @@ class ProjectBuildType extends AbstractType implements DataMapperInterface
if (!$lot) { //When the user selected "Create new lot", create a new lot
$lot = new PartLot();
$description = 'Build ' . date('Y-m-d H:i:s');
if (!empty($data->getComment())) {
if ($data->getComment() !== '') {
$description .= ' (' . $data->getComment() . ')';
}
$lot->setDescription($description);
@ -166,4 +168,4 @@ class ProjectBuildType extends AbstractType implements DataMapperInterface
//This has to be set after the builds part lot, so that it can disable the option
$data->setAddBuildsToBuildsPart($forms['addBuildsToBuildsPart']->getData());
}
}
}

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\Form\Type;
use Brick\Math\BigDecimal;

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\Form\Type;
use Brick\Math\BigDecimal;

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\Form\Type\Helper;
use App\Entity\Attachments\Attachment;
@ -82,7 +84,7 @@ class StructuralEntityChoiceHelper
;
}
if ($choice instanceof AttachmentType && !empty($choice->getFiletypeFilter())) {
if ($choice instanceof AttachmentType && $choice->getFiletypeFilter() !== '') {
$tmp += ['data-filetype_filter' => $choice->getFiletypeFilter()];
}
@ -96,7 +98,7 @@ class StructuralEntityChoiceHelper
public function generateChoiceAttrCurrency(Currency $choice, Options|array $options): array
{
$tmp = $this->generateChoiceAttr($choice, $options);
$symbol = empty($choice->getIsoCode()) ? null : Currencies::getSymbol($choice->getIsoCode());
$symbol = $choice->getIsoCode() === null || $choice->getIsoCode() === '' ? null : Currencies::getSymbol($choice->getIsoCode());
$tmp['data-short'] = $options['short'] ? $symbol : $choice->getName();
return $tmp + [
@ -147,4 +149,4 @@ class StructuralEntityChoiceHelper
return null;
}
}
}

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\Form\Type\Helper;
use App\Repository\StructuralDBElementRepository;
@ -84,4 +86,4 @@ class StructuralEntityChoiceLoader extends AbstractChoiceLoader
return $this->additional_element;
}
}
}

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\Form\Type;
use App\Entity\Parts\Storelocation;
@ -51,4 +53,4 @@ class PartLotSelectType extends AbstractType
->setParameter('part', $options['part'])
]);
}
}
}

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Form\Type;
use App\Entity\Attachments\Attachment;
@ -122,4 +124,4 @@ class PartSelectType extends AbstractType implements DataMapperInterface
$data = $form->getData();
}
}
}

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\Form\Type;
use Symfony\Component\Form\AbstractType;
@ -61,4 +63,4 @@ class RichTextEditorType extends AbstractType
{
return TextareaType::class;
}
}
}

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\Form\Type;
use Symfony\Component\Form\AbstractType;
@ -45,4 +47,4 @@ class ThemeChoiceType extends AbstractType
]);
}
}
}

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\Form\Type;
use App\Entity\UserSystem\User;
@ -40,4 +42,4 @@ class UserSelectType extends AbstractType
{
return StructuralEntityType::class;
}
}
}