Fixed code style.

This commit is contained in:
Jan Böhmer 2020-01-04 20:24:09 +01:00
parent 1aed1d1d26
commit 9a7223a301
142 changed files with 534 additions and 716 deletions

File diff suppressed because one or more lines are too long

View file

@ -2,9 +2,8 @@
/**
* Based on the .php_cs.dist of the symfony project
* https://github.com/symfony/symfony/blob/4.4/.php_cs.dist
* https://github.com/symfony/symfony/blob/4.4/.php_cs.dist.
*/
if (!file_exists(__DIR__.'/src')) {
exit(0);
}

View file

@ -80,8 +80,6 @@ class ConvertBBCodeCommand extends Command
/**
* Returns a list which entities and which properties need to be checked.
*
* @return array
*/
protected function getTargetsLists(): array
{

View file

@ -40,7 +40,6 @@ class AttachmentFileController extends AbstractController
* @Route("/attachment/{id}/download", name="attachment_download")
*
* @return BinaryFileResponse
*
*/
public function download(Attachment $attachment, AttachmentManager $helper)
{

View file

@ -151,7 +151,7 @@ class PartController extends AbstractController
$cid = $request->get('cid', 1);
$category = $em->find(Category::class, $cid);
if($category !== null) {
if (null !== $category) {
$new_part->setCategory($category);
}

View file

@ -80,7 +80,7 @@ class SecurityController extends AbstractController
$builder = $this->createFormBuilder();
$builder->add('user', TextType::class, [
'label' => $this->translator->trans('pw_reset.user_or_email'),
'constraints' => [new NotBlank()]
'constraints' => [new NotBlank()],
]);
$builder->add('captcha', CaptchaType::class, [
'width' => 200,
@ -88,7 +88,7 @@ class SecurityController extends AbstractController
'length' => 6,
]);
$builder->add('submit', SubmitType::class, [
'label' => 'pw_reset.submit'
'label' => 'pw_reset.submit',
]);
$form = $builder->getForm();
@ -97,11 +97,12 @@ class SecurityController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$passwordReset->request($form->getData()['user']);
$this->addFlash('success', 'pw_reset.request.success');
return $this->redirectToRoute('login');
}
return $this->render('security/pw_reset_request.html.twig', [
'form' => $form->createView()
'form' => $form->createView(),
]);
}
@ -121,10 +122,10 @@ class SecurityController extends AbstractController
$data = ['username' => $user, 'token' => $token];
$builder = $this->createFormBuilder($data);
$builder->add('username', TextType::class, [
'label' => $this->translator->trans('pw_reset.username')
'label' => $this->translator->trans('pw_reset.username'),
]);
$builder->add('token', TextType::class, [
'label' => $this->translator->trans('pw_reset.token')
'label' => $this->translator->trans('pw_reset.token'),
]);
$builder->add('new_password', RepeatedType::class, [
'type' => PasswordType::class,
@ -138,7 +139,7 @@ class SecurityController extends AbstractController
]);
$builder->add('submit', SubmitType::class, [
'label' => 'pw_reset.submit'
'label' => 'pw_reset.submit',
]);
$form = $builder->getForm();
@ -152,13 +153,13 @@ class SecurityController extends AbstractController
$this->addFlash('error', 'pw_reset.new_pw.error');
} else {
$this->addFlash('success', 'pw_reset.new_pw.success');
return $this->redirectToRoute('login');
}
}
return $this->render('security/pw_reset_new_pw.html.twig', [
'form' => $form->createView()
'form' => $form->createView(),
]);
}

View file

@ -35,6 +35,7 @@ use Symfony\Component\Routing\Annotation\Route;
/**
* This controller has the purpose to provide the data for all treeviews.
*
* @Route("/tree")
*/
class TreeController extends AbstractController
@ -52,6 +53,7 @@ class TreeController extends AbstractController
public function tools(ToolsTreeBuilder $builder)
{
$tree = $builder->getTree();
return new JsonResponse($tree);
}
@ -62,6 +64,7 @@ class TreeController extends AbstractController
public function categoryTree(Category $category = null)
{
$tree = $this->treeGenerator->getTreeView(Category::class, $category);
return new JsonResponse($tree);
}
@ -72,6 +75,7 @@ class TreeController extends AbstractController
public function footprintTree(Footprint $footprint = null)
{
$tree = $this->treeGenerator->getTreeView(Footprint::class, $footprint);
return new JsonResponse($tree);
}
@ -82,6 +86,7 @@ class TreeController extends AbstractController
public function locationTree(Storelocation $location = null)
{
$tree = $this->treeGenerator->getTreeView(Storelocation::class, $location);
return new JsonResponse($tree);
}
@ -92,6 +97,7 @@ class TreeController extends AbstractController
public function manufacturerTree(Manufacturer $manufacturer = null)
{
$tree = $this->treeGenerator->getTreeView(Manufacturer::class, $manufacturer);
return new JsonResponse($tree);
}
@ -102,6 +108,7 @@ class TreeController extends AbstractController
public function supplierTree(Supplier $supplier = null)
{
$tree = $this->treeGenerator->getTreeView(Supplier::class, $supplier);
return new JsonResponse($tree);
}
@ -112,6 +119,7 @@ class TreeController extends AbstractController
public function deviceTree(Device $device = null)
{
$tree = $this->treeGenerator->getTreeView(Device::class, $device, '');
return new JsonResponse($tree);
}
}

View file

@ -56,7 +56,7 @@ class UserController extends AdminPages\BaseAdminController
{
//Handle 2FA disabling
if($request->request->has('reset_2fa')) {
if ($request->request->has('reset_2fa')) {
//Check if the admin has the needed permissions
$this->denyAccessUnlessGranted('set_password', $entity);
if ($this->isCsrfTokenValid('reset_2fa'.$entity->getId(), $request->request->get('_token'))) {
@ -64,7 +64,7 @@ class UserController extends AdminPages\BaseAdminController
$entity->setGoogleAuthenticatorSecret(null);
$entity->setBackupCodes([]);
//Remove all U2F keys
foreach($entity->getU2FKeys() as $key) {
foreach ($entity->getU2FKeys() as $key) {
$em->remove($key);
}
//Invalidate trusted devices
@ -136,7 +136,6 @@ class UserController extends AdminPages\BaseAdminController
//If no user id was passed, then we show info about the current user
if (null === $user) {
$user = $this->getUser();
} else {
//Else we must check, if the current user is allowed to access $user
$this->denyAccessUnlessGranted('read', $user);

View file

@ -21,14 +21,12 @@
namespace App\Controller;
use App\Entity\UserSystem\U2FKey;
use App\Entity\UserSystem\User;
use App\Form\TFAGoogleSettingsType;
use App\Form\UserSettingsType;
use App\Services\TFA\BackupCodeManager;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
@ -43,7 +41,6 @@ use Symfony\Component\Validator\Constraints\Length;
/**
* @Route("/user")
* @package App\Controller
*/
class UserSettingsController extends AbstractController
{
@ -74,7 +71,7 @@ class UserSettingsController extends AbstractController
}
return $this->render('Users/backup_codes.html.twig', [
'user' => $user
'user' => $user,
]);
}
@ -85,7 +82,7 @@ class UserSettingsController extends AbstractController
*/
public function removeU2FToken(Request $request, EntityManagerInterface $entityManager, BackupCodeManager $backupCodeManager)
{
if($this->demo_mode) {
if ($this->demo_mode) {
throw new \RuntimeException('You can not do 2FA things in demo mode');
}
@ -98,15 +95,14 @@ class UserSettingsController extends AbstractController
throw new \RuntimeException('This controller only works only for Part-DB User objects!');
}
if ($this->isCsrfTokenValid('delete'.$user->getId(), $request->request->get('_token'))) {
if($request->request->has('key_id')) {
if ($request->request->has('key_id')) {
$key_id = $request->request->get('key_id');
$key_repo = $entityManager->getRepository(U2FKey::class);
/** @var U2FKey|null $u2f */
$u2f = $key_repo->find($key_id);
if($u2f === null) {
$this->addFlash('danger','tfa_u2f.u2f_delete.not_existing');
if (null === $u2f) {
$this->addFlash('danger', 'tfa_u2f.u2f_delete.not_existing');
throw new \RuntimeException('Key not existing!');
}
@ -122,7 +118,7 @@ class UserSettingsController extends AbstractController
$this->addFlash('success', 'tfa.u2f.u2f_delete.success');
}
} else {
$this->addFlash('error','csfr_invalid');
$this->addFlash('error', 'csfr_invalid');
}
return $this->redirectToRoute('user_settings');
@ -133,7 +129,7 @@ class UserSettingsController extends AbstractController
*/
public function resetTrustedDevices(Request $request, EntityManagerInterface $entityManager)
{
if($this->demo_mode) {
if ($this->demo_mode) {
throw new \RuntimeException('You can not do 2FA things in demo mode');
}
@ -146,13 +142,12 @@ class UserSettingsController extends AbstractController
return new \RuntimeException('This controller only works only for Part-DB User objects!');
}
if ($this->isCsrfTokenValid('devices_reset'.$user->getId(), $request->request->get('_token'))) {
$user->invalidateTrustedDeviceTokens();
$entityManager->flush();
$this->addFlash('success', 'tfa_trustedDevice.invalidate.success');
} else {
$this->addFlash('error','csfr_invalid');
$this->addFlash('error', 'csfr_invalid');
}
return $this->redirectToRoute('user_settings');
@ -205,7 +200,7 @@ class UserSettingsController extends AbstractController
'data' => $user->getName(),
'attr' => ['autocomplete' => 'username'],
'disabled' => true,
'row_attr' => ['class' => 'd-none']
'row_attr' => ['class' => 'd-none'],
])
->add('old_password', PasswordType::class, [
'label' => 'user.settings.pw_old.label',
@ -219,7 +214,7 @@ class UserSettingsController extends AbstractController
'second_options' => ['label' => 'user.settings.pw_confirm.label'],
'invalid_message' => 'password_must_match',
'options' => [
'attr' => ['autocomplete' => 'new-password']
'attr' => ['autocomplete' => 'new-password'],
],
'constraints' => [new Length([
'min' => 6,
@ -260,6 +255,7 @@ class UserSettingsController extends AbstractController
$backupCodeManager->enableBackupCodes($user);
$em->flush();
$this->addFlash('success', 'user.settings.2fa.google.activated');
return $this->redirectToRoute('user_settings');
}
@ -269,14 +265,15 @@ class UserSettingsController extends AbstractController
$backupCodeManager->disableBackupCodesIfUnused($user);
$em->flush();
$this->addFlash('success', 'user.settings.2fa.google.disabled');
return $this->redirectToRoute('user_settings');
}
}
$backup_form = $this->get('form.factory')->createNamedBuilder('backup_codes')->add('reset_codes', SubmitType::class,[
$backup_form = $this->get('form.factory')->createNamedBuilder('backup_codes')->add('reset_codes', SubmitType::class, [
'label' => 'tfa_backup.regenerate_codes',
'attr' => ['class' => 'btn-danger'],
'disabled' => empty($user->getBackupCodes())
'disabled' => empty($user->getBackupCodes()),
])->getForm();
$backup_form->handleRequest($request);
@ -286,7 +283,6 @@ class UserSettingsController extends AbstractController
$this->addFlash('success', 'user.settings.2fa.backup_codes.regenerated');
}
/******************************
* Output both forms
*****************************/
@ -303,8 +299,8 @@ class UserSettingsController extends AbstractController
'enabled' => $google_enabled,
'qrContent' => $googleAuthenticator->getQRContent($user),
'secret' => $user->getGoogleAuthenticatorSecret(),
'username' => $user->getGoogleAuthenticatorUsername()
]
'username' => $user->getGoogleAuthenticatorUsername(),
],
]);
}
}

View file

@ -21,7 +21,6 @@
namespace App\DataTables\Adapter;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Omines\DataTablesBundle\Adapter\AdapterQuery;
@ -31,24 +30,25 @@ use Omines\DataTablesBundle\Column\AbstractColumn;
/**
* Override default ORM Adapter, to allow fetch joins (allow addSelect with ManyToOne Collections).
* This should improves performance for Part Tables.
* Based on: https://github.com/omines/datatables-bundle/blob/master/tests/Fixtures/AppBundle/DataTable/Adapter/CustomORMAdapter.php
* @package App\DataTables\Adapter
* Based on: https://github.com/omines/datatables-bundle/blob/master/tests/Fixtures/AppBundle/DataTable/Adapter/CustomORMAdapter.php.
*/
class CustomORMAdapter extends ORMAdapter
{
protected $hydrationMode;
public function configure(array $options)
{
parent::configure($options);
$this->hydrationMode = isset($options['hydrate']) ? $options['hydrate'] : Query::HYDRATE_OBJECT;
}
protected function prepareQuery(AdapterQuery $query)
{
parent::prepareQuery($query);
$query->setIdentifierPropertyPath(null);
}
/**
* @param AdapterQuery $query
* @return \Traversable
*/
protected function getResults(AdapterQuery $query): \Traversable

View file

@ -21,7 +21,6 @@
namespace App\DataTables\Column;
use App\Services\MarkdownParser;
use Omines\DataTablesBundle\Column\AbstractColumn;
@ -38,6 +37,7 @@ class MarkdownColumn extends AbstractColumn
* The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type.
*
* @param mixed $value The single value of the column
*
* @return mixed
*/
public function normalize($value)

View file

@ -21,21 +21,16 @@
namespace App\DataTables\Column;
use App\Entity\Attachments\Attachment;
use App\Entity\Parts\Part;
use App\Services\Attachments\AttachmentManager;
use App\Services\Attachments\AttachmentURLGenerator;
use App\Services\EntityURLGenerator;
use App\Services\FAIconGenerator;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class PartAttachmentsColumn extends AbstractColumn
{
protected $FAIconGenerator;
protected $urlGenerator;
protected $attachmentManager;
@ -51,6 +46,7 @@ class PartAttachmentsColumn extends AbstractColumn
* The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type.
*
* @param mixed $value The single value of the column
*
* @return mixed
*/
public function normalize($value)
@ -63,7 +59,7 @@ class PartAttachmentsColumn extends AbstractColumn
if (!$context instanceof Part) {
throw new \RuntimeException('$context must be a Part object!');
}
$tmp = "";
$tmp = '';
$attachments = $context->getAttachments()->filter(function (Attachment $attachment) {
return $attachment->getShowInTable() && $this->attachmentManager->isFileExisting($attachment);
});
@ -74,11 +70,11 @@ class PartAttachmentsColumn extends AbstractColumn
if (--$count < 0) {
break;
}
/** @var Attachment $attachment */
/* @var Attachment $attachment */
$tmp .= sprintf(
'<a href="%s" title="%s" class="attach-table-icon" target="_blank" rel="noopener" data-no-ajax>%s</a>',
$this->urlGenerator->viewURL($attachment),
htmlspecialchars($attachment->getName()) . ': ' . htmlspecialchars($attachment->getFilename()),
htmlspecialchars($attachment->getName()).': '.htmlspecialchars($attachment->getFilename()),
$this->FAIconGenerator->generateIconHTML(
// Sometimes the extension can not be determined, so ensure a generic icon is shown
$this->FAIconGenerator->fileExtensionToFAType($attachment->getExtension() ?? 'file'),

View file

@ -21,13 +21,11 @@
namespace App\DataTables\Column;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class TagsColumn extends AbstractColumn
{
protected $urlGenerator;
public function __construct(UrlGeneratorInterface $urlGenerator)
@ -39,6 +37,7 @@ class TagsColumn extends AbstractColumn
* The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type.
*
* @param mixed $value The single value of the column
*
* @return mixed
*/
public function normalize($value)
@ -46,6 +45,7 @@ class TagsColumn extends AbstractColumn
if (empty($value)) {
return [];
}
return explode(',', $value);
}

View file

@ -27,7 +27,6 @@ use App\DataTables\Column\LocaleDateTimeColumn;
use App\DataTables\Column\MarkdownColumn;
use App\DataTables\Column\PartAttachmentsColumn;
use App\DataTables\Column\TagsColumn;
use App\Entity\Attachments\Attachment;
use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer;
@ -38,19 +37,15 @@ use App\Services\AmountFormatter;
use App\Services\Attachments\AttachmentURLGenerator;
use App\Services\Attachments\PartPreviewGenerator;
use App\Services\EntityURLGenerator;
use App\Services\FAIconGenerator;
use App\Services\MarkdownParser;
use App\Services\Trees\NodesListBuilder;
use Doctrine\ORM\QueryBuilder;
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider;
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
use Omines\DataTablesBundle\Column\BoolColumn;
use Omines\DataTablesBundle\Column\MapColumn;
use Omines\DataTablesBundle\Column\TextColumn;
use Omines\DataTablesBundle\DataTable;
use Omines\DataTablesBundle\DataTableTypeInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function foo\func;
class PartsDataTable implements DataTableTypeInterface
{

View file

@ -81,7 +81,7 @@ abstract class Attachment extends NamedDBElement
protected $path = '';
/**
* @var string The original filename the file had, when the user uploaded it.
* @var string the original filename the file had, when the user uploaded it
* @ORM\Column(type="string", nullable=true)
*/
protected $original_filename;
@ -138,8 +138,6 @@ abstract class Attachment extends NamedDBElement
/**
* Check if this attachment is a 3D model and therefore can be directly shown to user.
* If the attachment is external, false is returned (3D Models must be internal).
*
* @return bool
*/
public function is3DModel(): bool
{
@ -179,7 +177,7 @@ abstract class Attachment extends NamedDBElement
* Check if this attachment is saved in a secure place.
* This means that it can not be accessed directly via a web request, but must be viewed via a controller.
*
* @return bool True, if the file is secure.
* @return bool true, if the file is secure
*/
public function isSecure(): bool
{
@ -197,7 +195,7 @@ abstract class Attachment extends NamedDBElement
* Checks if the attachment file is using a builtin file. (see BUILTIN_PLACEHOLDERS const for possible placeholders)
* If a file is built in, the path is shown to user in url field (no sensitive infos are provided).
*
* @return bool True if the attachment is using an builtin file.
* @return bool true if the attachment is using an builtin file
*/
public function isBuiltIn(): bool
{
@ -215,7 +213,7 @@ abstract class Attachment extends NamedDBElement
* For a path like %BASE/path/foo.bar, bar will be returned.
* If this attachment is external null is returned.
*
* @return string|null The file extension in lower case.
* @return string|null the file extension in lower case
*/
public function getExtension(): ?string
{
@ -233,7 +231,7 @@ abstract class Attachment extends NamedDBElement
/**
* Get the element, associated with this Attachment (for example a "Part" object).
*
* @return AttachmentContainingDBElement The associated Element.
* @return AttachmentContainingDBElement the associated Element
*/
public function getElement(): ?AttachmentContainingDBElement
{
@ -243,8 +241,6 @@ abstract class Attachment extends NamedDBElement
/**
* The URL to the external file, or the path to the built in file.
* Returns null, if the file is not external (and not builtin).
*
* @return string|null
*/
public function getURL(): ?string
{
@ -258,8 +254,6 @@ abstract class Attachment extends NamedDBElement
/**
* Returns the hostname where the external file is stored.
* Returns null, if the file is not external.
*
* @return string|null
*/
public function getHost(): ?string
{
@ -285,8 +279,6 @@ abstract class Attachment extends NamedDBElement
* For a path like %BASE/path/foo.bar, foo.bar will be returned.
*
* If the path is a URL (can be checked via isExternal()), null will be returned.
*
* @return string|null
*/
public function getFilename(): ?string
{
@ -356,10 +348,6 @@ abstract class Attachment extends NamedDBElement
* Setters
****************************************************************************************************/
/**
* @param bool $show_in_table
* @return self
*/
public function setShowInTable(bool $show_in_table): self
{
$this->show_in_table = $show_in_table;
@ -369,7 +357,7 @@ abstract class Attachment extends NamedDBElement
/**
* Sets the element that is associated with this attachment.
* @param AttachmentContainingDBElement $element
*
* @return $this
*/
public function setElement(AttachmentContainingDBElement $element): self
@ -384,8 +372,10 @@ abstract class Attachment extends NamedDBElement
}
/**
* Sets the filepath (with relative placeholder) for this attachment
* @param string $path The new filepath of the attachment.
* Sets the filepath (with relative placeholder) for this attachment.
*
* @param string $path the new filepath of the attachment
*
* @return Attachment
*/
public function setPath(string $path): self
@ -396,7 +386,6 @@ abstract class Attachment extends NamedDBElement
}
/**
* @param AttachmentType $attachement_type
* @return $this
*/
public function setAttachmentType(AttachmentType $attachement_type): self
@ -410,7 +399,6 @@ abstract class Attachment extends NamedDBElement
* Sets the url associated with this attachment.
* If the url is empty nothing is changed, to not override the file path.
*
* @param string|null $url
* @return Attachment
*/
public function setURL(?string $url): self
@ -438,7 +426,7 @@ abstract class Attachment extends NamedDBElement
*
* @param string $path The path that should be checked
*
* @return bool True if the path is pointing to a builtin resource.
* @return bool true if the path is pointing to a builtin resource
*/
public static function checkIfBuiltin(string $path): bool
{
@ -455,7 +443,7 @@ abstract class Attachment extends NamedDBElement
/**
* Check if a string is a URL and is valid.
*
* @param $string string The string which should be checked.
* @param $string string The string which should be checked
* @param bool $path_required If true, the string must contain a path to be valid. (e.g. foo.bar would be invalid, foo.bar/test.php would be valid).
* @param $only_http bool Set this to true, if only HTTPS or HTTP schemata should be allowed.
* *Caution: When this is set to false, a attacker could use the file:// schema, to get internal server files, like /etc/passwd.*

View file

@ -85,7 +85,6 @@ abstract class AttachmentContainingDBElement extends NamedDBElement
/**
* Removes the given attachment from this element.
*
* @param Attachment $attachment
* @return $this
*/
public function removeAttachment(Attachment $attachment): self

View file

@ -88,8 +88,6 @@ class AttachmentType extends StructuralDBElement
* Gets an filter, which file types are allowed for attachment files.
* Must be in the format of <input type=file> accept attribute
* (See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers).
*
* @return string
*/
public function getFiletypeFilter(): string
{
@ -98,7 +96,9 @@ class AttachmentType extends StructuralDBElement
/**
* Sets the filetype filter pattern.
*
* @param string $filetype_filter The new filetype filter
*
* @return $this
*/
public function setFiletypeFilter(string $filetype_filter): self

View file

@ -31,7 +31,7 @@ use Doctrine\ORM\Mapping as ORM;
class AttachmentTypeAttachment extends Attachment
{
/**
* @var AttachmentType The element this attachment is associated with.
* @var AttachmentType the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\AttachmentType", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class CategoryAttachment extends Attachment
{
/**
* @var Category The element this attachment is associated with.
* @var Category the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Category", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class CurrencyAttachment extends Attachment
{
/**
* @var Currency The element this attachment is associated with.
* @var Currency the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class DeviceAttachment extends Attachment
{
/**
* @var Device The element this attachment is associated with.
* @var Device the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Devices\Device", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class FootprintAttachment extends Attachment
{
/**
* @var Footprint The element this attachment is associated with.
* @var Footprint the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Footprint", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class GroupAttachment extends Attachment
{
/**
* @var Group The element this attachment is associated with.
* @var Group the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\Group", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class ManufacturerAttachment extends Attachment
{
/**
* @var Manufacturer The element this attachment is associated with.
* @var Manufacturer the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Manufacturer", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -33,7 +33,7 @@ use Doctrine\ORM\Mapping as ORM;
class MeasurementUnitAttachment extends Attachment
{
/**
* @var Manufacturer The element this attachment is associated with.
* @var Manufacturer the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\MeasurementUnit", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class PartAttachment extends Attachment
{
/**
* @var Part The element this attachment is associated with.
* @var Part the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class StorelocationAttachment extends Attachment
{
/**
* @var Storelocation The element this attachment is associated with.
* @var Storelocation the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Storelocation", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class SupplierAttachment extends Attachment
{
/**
* @var Supplier The element this attachment is associated with.
* @var Supplier the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
class UserAttachment extends Attachment
{
/**
* @var User The element this attachment is associated with.
* @var User the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/

View file

@ -173,8 +173,6 @@ abstract class Company extends PartsContainingDBElement
* Set the addres.
*
* @param string $new_address the new address (with "\n" as line break)
*
* @return self
*/
public function setAddress(string $new_address): self
{
@ -187,8 +185,6 @@ abstract class Company extends PartsContainingDBElement
* Set the phone number.
*
* @param string $new_phone_number the new phone number
*
* @return self
*/
public function setPhoneNumber(string $new_phone_number): self
{
@ -201,8 +197,6 @@ abstract class Company extends PartsContainingDBElement
* Set the fax number.
*
* @param string $new_fax_number the new fax number
*
* @return self
*/
public function setFaxNumber(string $new_fax_number): self
{
@ -215,8 +209,6 @@ abstract class Company extends PartsContainingDBElement
* Set the e-mail address.
*
* @param string $new_email_address the new e-mail address
*
* @return self
*/
public function setEmailAddress(string $new_email_address): self
{
@ -229,8 +221,6 @@ abstract class Company extends PartsContainingDBElement
* Set the website.
*
* @param string $new_website the new website
*
* @return self
*/
public function setWebsite(string $new_website): self
{
@ -243,8 +233,6 @@ abstract class Company extends PartsContainingDBElement
* Set the link to the website of an article.
*
* @param string $new_url the new URL with the placeholder %PARTNUMBER% for the part number
*
* @return self
*/
public function setAutoProductUrl(string $new_url): self
{

View file

@ -51,7 +51,6 @@ trait MasterAttachmentTrait
/**
* Sets the new master picture for this part.
*
* @param Attachment|null $new_master_attachment
* @return $this
*/
public function setMasterPictureAttachment(?Attachment $new_master_attachment)

View file

@ -29,14 +29,14 @@ use Symfony\Component\Serializer\Annotation\Groups;
trait TimestampTrait
{
/**
* @var \DateTime The date when this element was modified the last time.
* @var \DateTime the date when this element was modified the last time
* @ORM\Column(type="datetime", name="last_modified", options={"default"="CURRENT_TIMESTAMP"})
* @Groups({"extended", "full"})
*/
protected $lastModified;
/**
* @var \DateTime The date when this element was created.
* @var \DateTime the date when this element was created
* @ORM\Column(type="datetime", name="datetime_added", options={"default"="CURRENT_TIMESTAMP"})
* @Groups({"extended", "full"})
*/
@ -46,7 +46,7 @@ trait TimestampTrait
* Returns the last time when the element was modified.
* Returns null if the element was not yet saved to DB yet.
*
* @return \DateTime|null The time of the last edit.
* @return \DateTime|null the time of the last edit
*/
public function getLastModified(): ?\DateTime
{
@ -57,7 +57,7 @@ trait TimestampTrait
* Returns the date/time when the element was created.
* Returns null if the element was not yet saved to DB yet.
*
* @return \DateTime|null The creation time of the part.
* @return \DateTime|null the creation time of the part
*/
public function getAddedDate(): ?\DateTime
{

View file

@ -133,7 +133,8 @@ class Device extends PartsContainingDBElement
/**
* Set the order quantity.
*
* @param int $new_order_quantity the new order quantity
* @param int $new_order_quantity the new order quantity
*
* @return $this
*/
public function setOrderQuantity(int $new_order_quantity): self
@ -150,6 +151,7 @@ class Device extends PartsContainingDBElement
* Set the "order_only_missing_parts" attribute.
*
* @param bool $new_order_only_missing_parts the new "order_only_missing_parts" attribute
*
* @return Device
*/
public function setOrderOnlyMissingParts(bool $new_order_only_missing_parts): self

View file

@ -117,16 +117,12 @@ class Category extends PartsContainingDBElement
return 'C'.sprintf('%09d', $this->getID());
}
/**
* @return string
*/
public function getPartnameHint(): string
{
return $this->partname_hint;
}
/**
* @param string $partname_hint
* @return Category
*/
public function setPartnameHint(string $partname_hint): self
@ -136,16 +132,12 @@ class Category extends PartsContainingDBElement
return $this;
}
/**
* @return string
*/
public function getPartnameRegex(): string
{
return $this->partname_regex;
}
/**
* @param string $partname_regex
* @return Category
*/
public function setPartnameRegex(string $partname_regex): self
@ -155,16 +147,12 @@ class Category extends PartsContainingDBElement
return $this;
}
/**
* @return bool
*/
public function isDisableFootprints(): bool
{
return $this->disable_footprints;
}
/**
* @param bool $disable_footprints
* @return Category
*/
public function setDisableFootprints(bool $disable_footprints): self
@ -174,16 +162,12 @@ class Category extends PartsContainingDBElement
return $this;
}
/**
* @return bool
*/
public function isDisableManufacturers(): bool
{
return $this->disable_manufacturers;
}
/**
* @param bool $disable_manufacturers
* @return Category
*/
public function setDisableManufacturers(bool $disable_manufacturers): self
@ -193,16 +177,12 @@ class Category extends PartsContainingDBElement
return $this;
}
/**
* @return bool
*/
public function isDisableAutodatasheets(): bool
{
return $this->disable_autodatasheets;
}
/**
* @param bool $disable_autodatasheets
* @return Category
*/
public function setDisableAutodatasheets(bool $disable_autodatasheets): self
@ -212,16 +192,12 @@ class Category extends PartsContainingDBElement
return $this;
}
/**
* @return bool
*/
public function isDisableProperties(): bool
{
return $this->disable_properties;
}
/**
* @param bool $disable_properties
* @return Category
*/
public function setDisableProperties(bool $disable_properties): self
@ -231,16 +207,12 @@ class Category extends PartsContainingDBElement
return $this;
}
/**
* @return string
*/
public function getDefaultDescription(): string
{
return $this->default_description;
}
/**
* @param string $default_description
* @return Category
*/
public function setDefaultDescription(string $default_description): self
@ -250,16 +222,12 @@ class Category extends PartsContainingDBElement
return $this;
}
/**
* @return string
*/
public function getDefaultComment(): string
{
return $this->default_comment;
}
/**
* @param string $default_comment
* @return Category
*/
public function setDefaultComment(string $default_comment): self

View file

@ -110,8 +110,6 @@ class Footprint extends PartsContainingDBElement
/**
* Returns the 3D Model associated with this footprint.
*
* @return FootprintAttachment|null
*/
public function getFootprint3d(): ?FootprintAttachment
{
@ -128,6 +126,7 @@ class Footprint extends PartsContainingDBElement
* Sets the 3D Model associated with this footprint.
*
* @param FootprintAttachment|null $new_attachment The new 3D Model
*
* @return Footprint
*/
public function setFootprint3d(?FootprintAttachment $new_attachment): self

View file

@ -113,16 +113,12 @@ class MeasurementUnit extends PartsContainingDBElement
return $this;
}
/**
* @return bool
*/
public function isInteger(): bool
{
return $this->is_integer;
}
/**
* @param bool $isInteger
* @return MeasurementUnit
*/
public function setIsInteger(bool $isInteger): self
@ -132,16 +128,12 @@ class MeasurementUnit extends PartsContainingDBElement
return $this;
}
/**
* @return bool
*/
public function isUseSIPrefix(): bool
{
return $this->use_si_prefix;
}
/**
* @param bool $usesSIPrefixes
* @return MeasurementUnit
*/
public function setUseSIPrefix(bool $usesSIPrefixes): self

View file

@ -92,7 +92,7 @@ class Part extends AttachmentContainingDBElement
protected $addedDate;
/**
* @var \DateTime The date when this element was modified the last time.
* @var \DateTime the date when this element was modified the last time
* @ColumnSecurity(type="datetime")
* @ORM\Column(type="datetime", name="last_modified", options={"default"="CURRENT_TIMESTAMP"})
*/

View file

@ -112,6 +112,7 @@ class PartLot extends DBElement
* This is the case, if the expiration date is greater the the current date.
*
* @return bool|null True, if the part lot is expired. Returns null, if no expiration date was set.
*
* @throws \Exception If an error with the DateTime occurs
*/
public function isExpired(): ?bool
@ -137,7 +138,6 @@ class PartLot extends DBElement
/**
* Sets the description of the part lot.
*
* @param string $description
* @return PartLot
*/
public function setDescription(string $description): self
@ -160,7 +160,6 @@ class PartLot extends DBElement
/**
* Sets the comment for this part lot.
*
* @param string $comment
* @return PartLot
*/
public function setComment(string $comment): self
@ -207,7 +206,6 @@ class PartLot extends DBElement
/**
* Sets the storage location, where this part lot is stored.
*
* @param Storelocation|null $storage_location
* @return PartLot
*/
public function setStorageLocation(?Storelocation $storage_location): self
@ -254,7 +252,6 @@ class PartLot extends DBElement
/**
* Set the unknown instock status of this part lot.
*
* @param bool $instock_unknown
* @return PartLot
*/
public function setInstockUnknown(bool $instock_unknown): self
@ -292,7 +289,6 @@ class PartLot extends DBElement
}
/**
* @param bool $needs_refill
* @return PartLot
*/
public function setNeedsRefill(bool $needs_refill): self

View file

@ -37,14 +37,14 @@ trait AdvancedPropertyTrait
protected $needs_review = false;
/**
* @var string A comma separated list of tags, associated with the part.
* @var string a comma separated list of tags, associated with the part
* @ORM\Column(type="text")
* @ColumnSecurity(type="string", prefix="tags", placeholder="")
*/
protected $tags = '';
/**
* @var float|null How much a single part unit weighs in grams.
* @var float|null how much a single part unit weighs in grams
* @ORM\Column(type="float", nullable=true)
* @ColumnSecurity(type="float", placeholder=null)
* @Assert\PositiveOrZero()
@ -53,8 +53,6 @@ trait AdvancedPropertyTrait
/**
* Checks if this part is marked, for that it needs further review.
*
* @return bool
*/
public function isNeedsReview(): bool
{
@ -63,7 +61,9 @@ trait AdvancedPropertyTrait
/**
* Sets the "needs review" status of this part.
*
* @param bool $needs_review The new status
*
* @return Part|self
*/
public function setNeedsReview(bool $needs_review): self
@ -75,8 +75,6 @@ trait AdvancedPropertyTrait
/**
* Gets a comma separated list, of tags, that are assigned to this part.
*
* @return string
*/
public function getTags(): string
{
@ -87,7 +85,6 @@ trait AdvancedPropertyTrait
* Sets a comma separated list of tags, that are assigned to this part.
*
* @param string $tags The new tags
* @return self
*/
public function setTags(string $tags): self
{
@ -99,8 +96,6 @@ trait AdvancedPropertyTrait
/**
* Returns the mass of a single part unit.
* Returns null, if the mass is unknown/not set yet.
*
* @return float|null
*/
public function getMass(): ?float
{
@ -111,8 +106,7 @@ trait AdvancedPropertyTrait
* Sets the mass of a single part unit.
* Sett to null, if the mass is unknown.
*
* @param float|null $mass The new mass.
* @return self
* @param float|null $mass the new mass
*/
public function setMass(?float $mass): self
{

View file

@ -49,7 +49,7 @@ trait BasicPropertyTrait
protected $visible = true;
/**
* @var bool True, if the part is marked as favorite.
* @var bool true, if the part is marked as favorite
* @ORM\Column(type="boolean")
* @ColumnSecurity(type="boolean")
*/
@ -111,7 +111,7 @@ trait BasicPropertyTrait
* Check if this part is a favorite.
*
* @return bool * true if this part is a favorite
* * false if this part is not a favorite.
* * false if this part is not a favorite
*/
public function isFavorite(): bool
{
@ -143,8 +143,6 @@ trait BasicPropertyTrait
* Sets the description of this part.
*
* @param string $new_description the new description
*
* @return self
*/
public function setDescription(?string $new_description): self
{
@ -157,8 +155,6 @@ trait BasicPropertyTrait
* Sets the comment property of this part.
*
* @param string $new_comment the new comment
*
* @return self
*/
public function setComment(string $new_comment): self
{
@ -172,8 +168,6 @@ trait BasicPropertyTrait
* The category property is required for every part, so you can not pass null like the other properties (footprints).
*
* @param Category $category The new category of this part
*
* @return self
*/
public function setCategory(Category $category): self
{
@ -187,8 +181,6 @@ trait BasicPropertyTrait
*
* @param Footprint|null $new_footprint The new footprint of this part. Set to null, if this part should not have
* a footprint.
*
* @return self
*/
public function setFootprint(?Footprint $new_footprint): self
{
@ -202,8 +194,6 @@ trait BasicPropertyTrait
*
* @param $new_favorite_status bool The new favorite status, that should be applied on this part.
* Set this to true, when the part should be a favorite.
*
* @return self
*/
public function setFavorite(bool $new_favorite_status): self
{

View file

@ -49,7 +49,7 @@ trait InstockTrait
protected $minamount = 0;
/**
* @var ?MeasurementUnit The unit in which the part's amount is measured.
* @var ?MeasurementUnit the unit in which the part's amount is measured
* @ORM\ManyToOne(targetEntity="MeasurementUnit", inversedBy="parts")
* @ORM\JoinColumn(name="id_part_unit", referencedColumnName="id", nullable=true)
* @ColumnSecurity(type="object", prefix="unit")
@ -69,9 +69,6 @@ trait InstockTrait
/**
* Adds the given part lot, to the list of part lots.
* The part lot is assigned to this part.
*
* @param PartLot $lot
* @return self
*/
public function addPartLot(PartLot $lot): self
{
@ -84,9 +81,7 @@ trait InstockTrait
/**
* Removes the given part lot from the list of part lots.
*
* @param PartLot $lot The part lot that should be deleted.
*
* @return self
* @param PartLot $lot the part lot that should be deleted
*/
public function removePartLot(PartLot $lot): self
{
@ -98,8 +93,6 @@ trait InstockTrait
/**
* Gets the measurement unit in which the part's amount should be measured.
* Returns null if no specific unit was that. That means the parts are measured simply in quantity numbers.
*
* @return MeasurementUnit|null
*/
public function getPartUnit(): ?MeasurementUnit
{
@ -109,9 +102,6 @@ trait InstockTrait
/**
* Sets the measurement unit in which the part's amount should be measured.
* Set to null, if the part should be measured in quantities.
*
* @param MeasurementUnit|null $partUnit
* @return self
*/
public function setPartUnit(?MeasurementUnit $partUnit): self
{
@ -182,8 +172,6 @@ trait InstockTrait
* See getPartUnit() for the associated unit.
*
* @param float $new_minamount the new count of parts which should be in stock at least
*
* @return self
*/
public function setMinAmount(float $new_minamount): self
{

View file

@ -41,7 +41,7 @@ trait ManufacturerTrait
protected $manufacturer;
/**
* @var string The url to the part on the manufacturer's homepage.
* @var string the url to the part on the manufacturer's homepage
* @ORM\Column(type="string")
* @Assert\Url()
* @ColumnSecurity(prefix="mpn", type="string", placeholder="")
@ -86,7 +86,7 @@ trait ManufacturerTrait
/**
* Similar to getManufacturerProductUrl, but here only the database value is returned.
*
* @return string The manufacturer url saved in DB for this part.
* @return string the manufacturer url saved in DB for this part
*/
public function getCustomProductURL(): string
{
@ -115,7 +115,6 @@ trait ManufacturerTrait
* Sets the manufacturing status for this part
* See getManufacturingStatus() for valid values.
*
* @param string $manufacturing_status
* @return Part
*/
public function setManufacturingStatus(string $manufacturing_status): self
@ -137,8 +136,6 @@ trait ManufacturerTrait
/**
* Returns the assigned manufacturer product number (MPN) for this part.
*
* @return string
*/
public function getManufacturerProductNumber(): string
{
@ -148,7 +145,6 @@ trait ManufacturerTrait
/**
* Sets the manufacturer product number (MPN) for this part.
*
* @param string $manufacturer_product_number
* @return Part
*/
public function setManufacturerProductNumber(string $manufacturer_product_number): self
@ -163,8 +159,6 @@ trait ManufacturerTrait
* Set to "" if this part should use the automatically URL based on its manufacturer.
*
* @param string $new_url The new url
*
* @return self
*/
public function setManufacturerProductURL(string $new_url): self
{
@ -178,8 +172,6 @@ trait ManufacturerTrait
*
* @param Manufacturer|null $new_manufacturer The new Manufacturer of this part. Set to null, if this part should
* not have a manufacturer.
*
* @return self
*/
public function setManufacturer(?Manufacturer $new_manufacturer): self
{

View file

@ -31,7 +31,7 @@ use Doctrine\Common\Collections\Collection;
trait OrderTrait
{
/**
* @var Orderdetail[]|Collection The details about how and where you can order this part.
* @var Orderdetail[]|Collection the details about how and where you can order this part
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @ColumnSecurity(prefix="orderdetails", type="collection")
@ -121,9 +121,7 @@ trait OrderTrait
* Adds the given orderdetail to list of orderdetails.
* The orderdetail is assigned to this part.
*
* @param Orderdetail $orderdetail The orderdetail that should be added.
*
* @return self
* @param Orderdetail $orderdetail the orderdetail that should be added
*/
public function addOrderdetail(Orderdetail $orderdetail): self
{
@ -136,7 +134,6 @@ trait OrderTrait
/**
* Removes the given orderdetail from the list of orderdetails.
*
* @param Orderdetail $orderdetail
* @return OrderTrait
*/
public function removeOrderdetail(Orderdetail $orderdetail): self
@ -157,8 +154,6 @@ trait OrderTrait
* (if the part has exactly one orderdetails,
* set this orderdetails as order orderdetails.
* Otherwise, set "no order orderdetails")
*
* @return self
*/
public function setManualOrder(bool $new_manual_order, int $new_order_quantity = 1, ?Orderdetail $new_order_orderdetail = null): self
{

View file

@ -145,7 +145,6 @@ class Storelocation extends PartsContainingDBElement
}
/**
* @param bool $only_single_part
* @return Storelocation
*/
public function setOnlySinglePart(bool $only_single_part): self
@ -166,7 +165,6 @@ class Storelocation extends PartsContainingDBElement
}
/**
* @param bool $limit_to_existing_parts
* @return Storelocation
*/
public function setLimitToExistingParts(bool $limit_to_existing_parts): self
@ -185,7 +183,6 @@ class Storelocation extends PartsContainingDBElement
}
/**
* @param MeasurementUnit|null $storage_type
* @return Storelocation
*/
public function setStorageType(?MeasurementUnit $storage_type): self

View file

@ -127,7 +127,6 @@ class Supplier extends Company
/**
* Sets the default currency.
*
* @param Currency|null $default_currency
* @return Supplier
*/
public function setDefaultCurrency(?Currency $default_currency): self
@ -151,6 +150,7 @@ class Supplier extends Company
* Sets the shipping costs for an order with this supplier.
*
* @param string|null $shipping_costs a bcmath string with the shipping costs
*
* @return Supplier
*/
public function setShippingCosts(?string $shipping_costs): self

View file

@ -46,7 +46,7 @@ class Currency extends StructuralDBElement
protected $attachments;
/**
* @var string The 3 letter ISO code of the currency.
* @var string the 3 letter ISO code of the currency
* @ORM\Column(type="string")
* @Assert\Currency()
*/
@ -95,8 +95,6 @@ class Currency extends StructuralDBElement
/**
* Returns the inverse exchange rate (how many of the current currency the base unit is worth).
*
* @return string|null
*/
public function getInverseExchangeRate(): ?string
{
@ -112,8 +110,6 @@ class Currency extends StructuralDBElement
/**
* Returns The exchange rate between this currency and the base currency
* (how many base units the current currency is worth).
*
* @return string|null
*/
public function getExchangeRate(): ?string
{
@ -122,8 +118,10 @@ class Currency extends StructuralDBElement
/**
* Sets the exchange rate of the currency.
*
* @param string|null $exchange_rate The new exchange rate of the currency.
* Set to null, if the exchange rate is unknown.
* Set to null, if the exchange rate is unknown.
*
* @return Currency
*/
public function setExchangeRate(?string $exchange_rate): self

View file

@ -157,7 +157,7 @@ class Orderdetail extends DBElement
/**
* Get the supplier part-nr.
*
* @return string the part-nr.
* @return string the part-nr
*/
public function getSupplierPartNr(): string
{
@ -228,7 +228,6 @@ class Orderdetail extends DBElement
/**
* Removes an pricedetail from this orderdetail.
*
* @param Pricedetail $pricedetail
* @return Orderdetail
*/
public function removePricedetail(Pricedetail $pricedetail): self
@ -276,7 +275,6 @@ class Orderdetail extends DBElement
/**
* Sets a new part with which this orderdetail is associated.
*
* @param Part $part
* @return Orderdetail
*/
public function setPart(Part $part): self
@ -289,7 +287,6 @@ class Orderdetail extends DBElement
/**
* Sets the new supplier associated with this orderdetail.
*
* @param Supplier $new_supplier
* @return Orderdetail
*/
public function setSupplier(Supplier $new_supplier): self
@ -333,7 +330,7 @@ class Orderdetail extends DBElement
* Sets the custom product supplier URL for this order detail.
* Set this to "", if the function getSupplierProductURL should return the automatic generated URL.
*
* @param $new_url string The new URL for the supplier URL.
* @param $new_url string The new URL for the supplier URL
*
* @return Orderdetail
*/

View file

@ -130,7 +130,7 @@ class Pricedetail extends DBElement
/**
* Get the orderdetail to which this pricedetail belongs to this pricedetails.
*
* @return Orderdetail The orderdetail this price belongs to.
* @return Orderdetail the orderdetail this price belongs to
*/
public function getOrderdetail(): Orderdetail
{
@ -141,7 +141,7 @@ class Pricedetail extends DBElement
* Returns the price associated with this pricedetail.
* It is given in current currency and for the price related quantity.
*
* @return string The price as string, like returned raw from DB.
* @return string the price as string, like returned raw from DB
*/
public function getPrice(): string
{
@ -215,8 +215,6 @@ class Pricedetail extends DBElement
/**
* Returns the currency associated with this price information.
* Returns null, if no specific currency is selected and the global base currency should be assumed.
*
* @return Currency|null
*/
public function getCurrency(): ?Currency
{
@ -232,7 +230,6 @@ class Pricedetail extends DBElement
/**
* Sets the orderdetail to which this pricedetail belongs to.
*
* @param Orderdetail $orderdetail
* @return $this
*/
public function setOrderdetail(Orderdetail $orderdetail): self
@ -246,7 +243,6 @@ class Pricedetail extends DBElement
* Sets the currency associated with the price informations.
* Set to null, to use the global base currency.
*
* @param Currency|null $currency
* @return Pricedetail
*/
public function setCurrency(?Currency $currency): self
@ -264,8 +260,6 @@ class Pricedetail extends DBElement
* * This is the price for "price_related_quantity" parts!!
* * Example: if "price_related_quantity" is '10',
* you have to set here the price for 10 parts!
*
* @return self
*/
public function setPrice(string $new_price): self
{
@ -286,8 +280,6 @@ class Pricedetail extends DBElement
* quantity to 100. The single price (20$/100 = 0.2$) will be calculated automatically.
*
* @param float $new_price_related_quantity the price related quantity
*
* @return self
*/
public function setPriceRelatedQuantity(float $new_price_related_quantity): self
{
@ -312,8 +304,6 @@ class Pricedetail extends DBElement
* So the orderdetails would have three Pricedetails for one supplier.)
*
* @param float $new_min_discount_quantity the minimum discount quantity
*
* @return self
*/
public function setMinDiscountQuantity(float $new_min_discount_quantity): self
{

View file

@ -78,6 +78,7 @@ class Group extends StructuralDBElement implements HasPermissionsInterface
/**
* Check if the users of this group are enforced to have two factor authentification (2FA) enabled.
*
* @return bool
*/
public function isEnforce2FA(): bool
@ -87,17 +88,18 @@ class Group extends StructuralDBElement implements HasPermissionsInterface
/**
* Sets if the user of this group are enforced to have two factor authentification enabled.
*
* @param bool $enforce2FA True, if the users of this group are enforced to have 2FA enabled.
*
* @return $this
*/
public function setEnforce2FA(bool $enforce2FA): Group
public function setEnforce2FA(bool $enforce2FA): self
{
$this->enforce2FA = $enforce2FA;
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.

View file

@ -21,7 +21,6 @@
namespace App\Entity\UserSystem;
use App\Entity\Base\TimestampTrait;
use Doctrine\ORM\Mapping as ORM;
use R\U2FTwoFactorBundle\Model\U2F\TwoFactorInterface;
@ -48,41 +47,46 @@ class U2FKey implements TwoFactorKeyInterface
/**
* @ORM\Column(type="string", length=64)
*
* @var string
**/
public $keyHandle;
/**
* @ORM\Column(type="string")
*
* @var string
**/
public $publicKey;
/**
* @ORM\Column(type="text")
*
* @var string
**/
public $certificate;
/**
* @ORM\Column(type="string")
*
* @var int
**/
public $counter;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="u2fKeys")
*
* @var User
**/
protected $user;
/**
* @ORM\Column(type="string")
*
* @var string
**/
protected $name;
public function fromRegistrationData(Registration $data): void
{
$this->keyHandle = $data->keyHandle;
@ -91,62 +95,61 @@ class U2FKey implements TwoFactorKeyInterface
$this->counter = $data->counter;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function getKeyHandle()
{
return $this->keyHandle;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function setKeyHandle($keyHandle)
{
$this->keyHandle = $keyHandle;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function getPublicKey()
{
return $this->publicKey;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function setPublicKey($publicKey)
{
$this->publicKey = $publicKey;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function getCertificate()
{
return $this->certificate;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function setCertificate($certificate)
{
$this->certificate = $certificate;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function getCounter()
{
return $this->counter;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function setCounter($counter)
{
$this->counter = $counter;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function getName()
{
return $this->name;
}
/** @inheritDoc */
/** {@inheritdoc} */
public function setName($name)
{
$this->name = $name;
@ -154,30 +157,33 @@ class U2FKey implements TwoFactorKeyInterface
/**
* Gets the user, this U2F key belongs to.
*
* @return User
*/
public function getUser() : User
public function getUser(): User
{
return $this->user;
}
/**
* The primary key ID of this key
* The primary key ID of this key.
*
* @return int
*/
public function getID() : int
public function getID(): int
{
return $this->id;
}
/**
* Sets the user this U2F key belongs to.
* @param TwoFactorInterface $new_user
*
* @return $this
*/
public function setUser(TwoFactorInterface $new_user) : self
public function setUser(TwoFactorInterface $new_user): self
{
$this->user = $new_user;
return $this;
}
}

View file

@ -62,6 +62,7 @@ use App\Validator\Constraints\ValidPermission;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use R\U2FTwoFactorBundle\Model\U2F\TwoFactorInterface as U2FTwoFactorInterface;
use R\U2FTwoFactorBundle\Model\U2F\TwoFactorKeyInterface;
use Scheb\TwoFactorBundle\Model\BackupCodeInterface;
use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface;
@ -70,7 +71,6 @@ use Scheb\TwoFactorBundle\Model\TrustedDeviceInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use R\U2FTwoFactorBundle\Model\U2F\TwoFactorInterface as U2FTwoFactorInterface;
/**
* This entity represents a user, which can log in and have permissions.
@ -80,8 +80,7 @@ use R\U2FTwoFactorBundle\Model\U2F\TwoFactorInterface as U2FTwoFactorInterface;
* @ORM\Table("`users`")
* @UniqueEntity("name", message="validator.user.username_already_used")
*/
class User extends AttachmentContainingDBElement implements UserInterface, HasPermissionsInterface,
TwoFactorInterface, BackupCodeInterface, TrustedDeviceInterface, U2FTwoFactorInterface, PreferredProviderInterface
class User extends AttachmentContainingDBElement implements UserInterface, HasPermissionsInterface, TwoFactorInterface, BackupCodeInterface, TrustedDeviceInterface, U2FTwoFactorInterface, PreferredProviderInterface
{
use MasterAttachmentTrait;
@ -205,8 +204,8 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
protected $trustedDeviceCookieVersion = 0;
/** @var Collection<TwoFactorKeyInterface>
* @ORM\OneToMany(targetEntity="App\Entity\UserSystem\U2FKey", mappedBy="user", cascade={"REMOVE"}, orphanRemoval=true)
*/
* @ORM\OneToMany(targetEntity="App\Entity\UserSystem\U2FKey", mappedBy="user", cascade={"REMOVE"}, orphanRemoval=true)
*/
protected $u2fKeys;
/**
@ -319,7 +318,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the password hash for this user.
*
* @param string $password
* @return User
*/
public function setPassword(string $password): self
@ -359,7 +357,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the currency the users prefers to see prices in.
*
* @param Currency|null $currency
* @return User
*/
public function setCurrency(?Currency $currency): self
@ -422,7 +419,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Set the status, if the user needs a password change.
*
* @param bool $need_pw_change
* @return User
*/
public function setNeedPwChange(bool $need_pw_change): self
@ -433,7 +429,8 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Returns the encrypted password reset token
* Returns the encrypted password reset token.
*
* @return string|null
*/
public function getPwResetToken(): ?string
@ -442,18 +439,20 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Sets the encrypted password reset token
* @param string|null $pw_reset_token
* Sets the encrypted password reset token.
*
* @return User
*/
public function setPwResetToken(?string $pw_reset_token): User
public function setPwResetToken(?string $pw_reset_token): self
{
$this->pw_reset_token = $pw_reset_token;
return $this;
}
/**
* Gets the datetime when the password reset token expires
* Gets the datetime when the password reset token expires.
*
* @return \DateTime
*/
public function getPwResetExpires(): \DateTime
@ -462,18 +461,17 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Sets the datetime when the password reset token expires
* @param \DateTime $pw_reset_expires
* Sets the datetime when the password reset token expires.
*
* @return User
*/
public function setPwResetExpires(\DateTime $pw_reset_expires): User
public function setPwResetExpires(\DateTime $pw_reset_expires): self
{
$this->pw_reset_expires = $pw_reset_expires;
return $this;
}
/************************************************
* Getters
************************************************/
@ -496,8 +494,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Change the username of this user
* Change the username of this user.
*
* @param string $new_name The new username.
*
* @return $this
*/
public function setName(string $new_name): NamedDBElement
@ -512,6 +512,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Get the first name of the user.
*
* @return string|null
*/
public function getFirstName(): ?string
@ -520,7 +521,8 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Change the first name of the user
* Change the first name of the user.
*
* @param string $first_name The new first name
*
* @return $this
@ -533,7 +535,8 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Get the last name of the user
* Get the last name of the user.
*
* @return string|null
*/
public function getLastName(): ?string
@ -542,7 +545,8 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Change the last name of the user
* Change the last name of the user.
*
* @param string $last_name The new last name
*
* @return $this
@ -555,7 +559,8 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Gets the department of this user
* Gets the department of this user.
*
* @return string
*/
public function getDepartment(): ?string
@ -564,8 +569,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Change the department of the user
* Change the department of the user.
*
* @param string $department The new department
*
* @return User
*/
public function setDepartment(?string $department): self
@ -577,6 +584,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Get the email of the user.
*
* @return string
*/
public function getEmail(): ?string
@ -585,8 +593,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* Change the email of the user
* Change the email of the user.
*
* @param string $email The new email adress
*
* @return $this
*/
public function setEmail(?string $email): self
@ -598,8 +608,9 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Gets the language the user prefers (as 2 letter ISO code).
*
* @return string|null The 2 letter ISO code of the preferred language (e.g. 'en' or 'de').
* If null is returned, the user has not specified a language and the server wide language should be used.
* If null is returned, the user has not specified a language and the server wide language should be used.
*/
public function getLanguage(): ?string
{
@ -608,20 +619,24 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Change the language the user prefers.
*
* @param string|null $language The new language as 2 letter ISO code (e.g. 'en' or 'de').
* Set to null, to use the system wide language.
* Set to null, to use the system wide language.
*
* @return User
*/
public function setLanguage(?string $language): self
{
$this->language = $language;
return $this;
}
/**
* Gets the timezone of the user
* Gets the timezone of the user.
*
* @return string|null The timezone of the user (e.g. 'Europe/Berlin') or null if the user has not specified
* a timezone (then the global one should be used)
* a timezone (then the global one should be used)
*/
public function getTimezone(): ?string
{
@ -630,7 +645,9 @@ 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
@ -642,6 +659,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Gets the theme the users wants to see. See self::AVAILABLE_THEMES for valid values.
*
* @return string|null The name of the theme the user wants to see, or null if the system wide should be used.
*/
public function getTheme(): ?string
@ -651,8 +669,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Change the theme the user wants to see.
*
* @param string|null $theme The name of the theme (See See self::AVAILABLE_THEMES for valid values). Set to null
* if the system wide theme should be used.
* if the system wide theme should be used.
*
* @return $this
*/
public function setTheme(?string $theme): self
@ -664,6 +684,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Gets the group to which this user belongs to.
*
* @return Group|null The group of this user. Null if this user does not have a group.
*/
public function getGroup(): ?Group
@ -673,7 +694,9 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the group of this user.
*
* @param Group|null $group The new group of this user. Set to null if this user should not have a group.
*
* @return $this
*/
public function setGroup(?Group $group): self
@ -685,12 +708,14 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Returns a string representation of this user (the full name).
* E.g. 'Jane Doe (j.doe) [DISABLED]
* E.g. 'Jane Doe (j.doe) [DISABLED].
*
* @return string
*/
public function __toString()
{
$tmp = $this->isDisabled() ? ' [DISABLED]' : '';
return $this->getFullName(true).$tmp;
}
@ -706,6 +731,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Return the user name that should be shown in Google Authenticator.
*
* @return string
*/
public function getGoogleAuthenticatorUsername(): string
@ -726,12 +752,13 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the secret used for Google Authenticator. Set to null to disable Google Authenticator.
* @param string|null $googleAuthenticatorSecret
*
* @return $this
*/
public function setGoogleAuthenticatorSecret(?string $googleAuthenticatorSecret): self
{
$this->googleAuthenticatorSecret = $googleAuthenticatorSecret;
return $this;
}
@ -739,11 +766,12 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
* Check if the given code is a valid backup code.
*
* @param string $code The code that should be checked.
*
* @return bool True if the backup code is valid.
*/
public function isBackupCode(string $code): bool
{
return in_array($code, $this->backupCodes);
return \in_array($code, $this->backupCodes);
}
/**
@ -754,48 +782,55 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
public function invalidateBackupCode(string $code): void
{
$key = array_search($code, $this->backupCodes);
if ($key !== false){
if (false !== $key) {
unset($this->backupCodes[$key]);
}
}
/**
* Returns the list of all valid backup codes
* Returns the list of all valid backup codes.
*
* @return string[] An array with all backup codes
*/
public function getBackupCodes() : array
public function getBackupCodes(): array
{
return $this->backupCodes ?? [];
}
/**
* Set the backup codes for this user. Existing backup codes are overridden.
* @param string[] $codes An array containing the backup codes
*
* @param string[] $codes An array containing the backup codes
*
* @return $this
*
* @throws \Exception If an error with the datetime occurs
*/
public function setBackupCodes(array $codes) : self
public function setBackupCodes(array $codes): self
{
$this->backupCodes = $codes;
if(empty($codes)) {
if (empty($codes)) {
$this->backupCodesGenerationDate = null;
} else {
$this->backupCodesGenerationDate = new \DateTime();
}
return $this;
}
/**
* Return the date when the backup codes were generated.
*
* @return \DateTime|null
*/
public function getBackupCodesGenerationDate() : ?\DateTime
public function getBackupCodesGenerationDate(): ?\DateTime
{
return $this->backupCodesGenerationDate;
}
/**
* Return version for the trusted device token. Increase version to invalidate all trusted token of the user.
*
* @return int The version of trusted device token
*/
public function getTrustedTokenVersion(): int
@ -807,22 +842,24 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
* Invalidate all trusted device tokens at once, by incrementing the token version.
* You have to flush the changes to database afterwards.
*/
public function invalidateTrustedDeviceTokens() : void
public function invalidateTrustedDeviceTokens(): void
{
$this->trustedDeviceCookieVersion++;
++$this->trustedDeviceCookieVersion;
}
/**
* Check if U2F is enabled
* Check if U2F is enabled.
*
* @return bool
*/
public function isU2FAuthEnabled(): bool
{
return count($this->u2fKeys) > 0;
return \count($this->u2fKeys) > 0;
}
/**
* Get all U2F Keys that are associated with this user
* Get all U2F Keys that are associated with this user.
*
* @return Collection<TwoFactorKeyInterface>
*/
public function getU2FKeys(): Collection
@ -832,7 +869,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Add a U2F key to this user.
* @param TwoFactorKeyInterface $key
*/
public function addU2FKey(TwoFactorKeyInterface $key): void
{
@ -841,7 +877,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Remove a U2F key from this user.
* @param TwoFactorKeyInterface $key
*/
public function removeU2FKey(TwoFactorKeyInterface $key): void
{
@ -849,12 +884,12 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function getPreferredTwoFactorProvider(): ?string
{
//If U2F is available then prefer it
if($this->isU2FAuthEnabled()) {
if ($this->isU2FAuthEnabled()) {
return 'u2f_two_factor';
}

View file

@ -21,7 +21,6 @@
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Mailer\Event\MessageEvent;
use Symfony\Component\Mime\Address;
@ -34,7 +33,7 @@ class MailFromListener implements EventSubscriberInterface
public function __construct(string $email, string $name)
{
$this->email = $email;
$this->email = $email;
$this->name = $name;
}

View file

@ -21,7 +21,6 @@
namespace App\EventSubscriber;
use App\Entity\UserSystem\User;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
@ -34,18 +33,16 @@ use Symfony\Component\Security\Http\HttpUtils;
* This event subscriber redirects a user to its settings page, when it needs to change its password or is enforced
* to setup a 2FA method (enforcement can be set per group).
* In this cases the user is unable to access sites other than the whitelisted (see ALLOWED_ROUTES).
* @package App\EventSubscriber
*/
class PasswordChangeNeededSubscriber implements EventSubscriberInterface
{
protected $security;
protected $flashBag;
protected $httpUtils;
/**
* @var string[] The routes the user is allowed to access without being redirected.
* This should be only routes related to login/logout and user settings
* This should be only routes related to login/logout and user settings
*/
public const ALLOWED_ROUTES = [
'2fa_login',
@ -69,17 +66,16 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
* This function is called when the kernel encounters a request.
* It checks if the user must change its password or add an 2FA mehtod and redirect it to the user settings page,
* if needed.
* @param RequestEvent $event
*/
public function redirectToSettingsIfNeeded(RequestEvent $event) : void
public function redirectToSettingsIfNeeded(RequestEvent $event): void
{
$user = $this->security->getUser();
$request = $event->getRequest();
if(!$event->isMasterRequest()) {
if (!$event->isMasterRequest()) {
return;
}
if(!$user instanceof User) {
if (!$user instanceof User) {
return;
}
@ -98,35 +94,36 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
/* Dont redirect tree endpoints, as this would cause trouble and creates multiple flash
warnigs for one page reload */
if(strpos($request->getUri(), '/tree/') !== false) {
if (false !== strpos($request->getUri(), '/tree/')) {
return;
}
//Show appropriate message to user about the reason he was redirected
if($user->isNeedPwChange()) {
if ($user->isNeedPwChange()) {
$this->flashBag->add('warning', 'user.pw_change_needed.flash');
}
if(static::TFARedirectNeeded($user)) {
if (static::TFARedirectNeeded($user)) {
$this->flashBag->add('warning', 'user.2fa_needed.flash');
}
$event->setResponse($this->httpUtils->createRedirectResponse($request, static::REDIRECT_TARGET));
}
/**
* Check if a redirect because of a missing 2FA method is needed.
* That is the case if the group of the user enforces 2FA, but the user has neither Google Authenticator nor an
* U2F key setup.
* @param User $user The user for which should be checked if it needs to be redirected.
*
* @param User $user The user for which should be checked if it needs to be redirected.
*
* @return bool True if the user needs to be redirected.
*/
public static function TFARedirectNeeded(User $user) : bool
public static function TFARedirectNeeded(User $user): bool
{
$tfa_enabled = $user->isU2FAuthEnabled() || $user->isGoogleAuthenticatorEnabled();
if ($user->getGroup() !== null && $user->getGroup()->isEnforce2FA() && !$tfa_enabled) {
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled) {
return true;
}
@ -134,7 +131,7 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{

View file

@ -21,7 +21,6 @@
namespace App\EventSubscriber;
use App\Entity\UserSystem\U2FKey;
use Doctrine\ORM\EntityManagerInterface;
use R\U2FTwoFactorBundle\Event\RegisterEvent;
@ -51,9 +50,9 @@ class U2FRegistrationSubscriber implements EventSubscriberInterface
/** @return string[] **/
public static function getSubscribedEvents(): array
{
return array(
return [
'r_u2f_two_factor.register' => 'onRegister',
);
];
}
public function onRegister(RegisterEvent $event): void

View file

@ -28,7 +28,6 @@ use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class AttachmentTypeAdminForm extends BaseEntityAdminForm
{

View file

@ -38,7 +38,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class BaseEntityAdminForm extends AbstractType
{
@ -65,7 +64,7 @@ class BaseEntityAdminForm extends AbstractType
$builder
->add('name', TextType::class, ['empty_data' => '', 'label' => 'name.label',
'attr' => ['placeholder' =>'part.name.placeholder'],
'attr' => ['placeholder' => 'part.name.placeholder'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
->add('parent', StructuralEntityType::class, ['class' => \get_class($entity),

View file

@ -36,7 +36,7 @@ class GroupAdminForm extends BaseEntityAdminForm
'label' => 'group.edit.enforce_2fa',
'help' => 'entity.edit.enforce_2fa.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
]);
$builder->add('permissions', PermissionsType::class, [

View file

@ -31,7 +31,6 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class ImportType extends AbstractType
{

View file

@ -28,7 +28,6 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class MassCreationForm extends AbstractType
{

View file

@ -38,7 +38,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\Constraints\Url;
use Symfony\Contracts\Translation\TranslatorInterface;
class AttachmentFormType extends AbstractType
{

View file

@ -36,13 +36,12 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class OrderdetailType extends AbstractType
{
protected $security;
public function __construct( Security $security)
public function __construct(Security $security)
{
$this->security = $security;
}

View file

@ -46,7 +46,6 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class PartBaseType extends AbstractType
{

View file

@ -33,7 +33,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class PartLotType extends AbstractType
{

View file

@ -53,7 +53,7 @@ class PricedetailType extends AbstractType
]);
$builder->add('currency', CurrencyEntityType::class, [
'required' => false,
'label' => false
'label' => false,
]);
}

View file

@ -21,7 +21,6 @@
namespace App\Form;
use App\Entity\UserSystem\User;
use App\Validator\Constraints\ValidGoogleAuthCode;
use Symfony\Component\Form\AbstractType;
@ -33,11 +32,9 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
class TFAGoogleSettingsType extends AbstractType
{
protected $translator;
public function __construct()
@ -46,20 +43,20 @@ class TFAGoogleSettingsType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) {
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$form = $event->getForm();
/** @var User $user */
$user = $event->getData();
//Only show setup fields, when google authenticator is not enabled
if(!$user->isGoogleAuthenticatorEnabled()) {
if (!$user->isGoogleAuthenticatorEnabled()) {
$form->add(
'google_confirmation',
TextType::class,
[
'mapped' => false,
'attr' => ['maxlength' => '6', 'minlength' => '6', 'pattern' => '\d*', 'autocomplete' => 'off'],
'constraints' => [new ValidGoogleAuthCode()]
'constraints' => [new ValidGoogleAuthCode()],
]
);
@ -72,12 +69,12 @@ class TFAGoogleSettingsType extends AbstractType
);
$form->add('submit', SubmitType::class, [
'label' => 'tfa_google.enable'
'label' => 'tfa_google.enable',
]);
} else {
$form->add('submit', SubmitType::class, [
'label' =>'tfa_google.disable',
'attr' => ['class' => 'btn-danger']
'label' => 'tfa_google.disable',
'attr' => ['class' => 'btn-danger'],
]);
}
});

View file

@ -44,7 +44,6 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Contracts\Translation\TranslatorInterface;
class UserAdminForm extends AbstractType
{

View file

@ -34,7 +34,6 @@ use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class UserSettingsType extends AbstractType
{

View file

@ -38,9 +38,9 @@ class BBCodeToMarkdownConverter
* Converts the given BBCode to markdown.
* BBCode tags that does not have a markdown aequivalent are outputed as HTML tags.
*
* @param $bbcode string The Markdown that should be converted.
* @param $bbcode string The Markdown that should be converted
*
* @return string The markdown version of the text.
* @return string the markdown version of the text
*/
public function convert(string $bbcode): string
{

View file

@ -21,10 +21,8 @@
namespace App\Helpers\Trees;
use App\Entity\Base\StructuralDBElement;
use Doctrine\Common\Collections\Collection;
use RecursiveIterator;
class StructuralDBElementIterator extends \ArrayIterator implements \RecursiveIterator
{
@ -37,22 +35,24 @@ class StructuralDBElementIterator extends \ArrayIterator implements \RecursiveIt
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hasChildren()
{
/** @var StructuralDBElement $element */
$element = $this->current();
return !empty($element->getSubelements());
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function getChildren()
{
/** @var StructuralDBElement $element */
$element = $this->current();
return new StructuralDBElementIterator($element->getSubelements()->toArray());
return new self($element->getSubelements()->toArray());
}
}

View file

@ -21,11 +21,6 @@
namespace App\Helpers\Trees;
use App\Entity\Base\DBElement;
use App\Entity\Base\NamedDBElement;
use App\Entity\Base\StructuralDBElement;
use App\Helpers\Trees\TreeViewNodeState;
/**
* This class represents a node for the bootstrap treeview node.
* When you serialize an array of these objects to JSON, you can use the serialized data in data for the treeview.
@ -63,9 +58,10 @@ class TreeViewNode implements \JsonSerializable
/**
* Return the ID of the entity associated with this node.
* Null if this node is not connected with an entity.
*
* @return int|null
*/
public function getId() : ?int
public function getId(): ?int
{
return $this->id;
}
@ -73,12 +69,13 @@ class TreeViewNode implements \JsonSerializable
/**
* Sets the ID of the entity associated with this node.
* Null if this node is not connected with an entity.
* @param int|null $id
*
* @return $this
*/
public function setId(?int $id): self
{
$this->id = $id;
return $this;
}
@ -208,27 +205,27 @@ class TreeViewNode implements \JsonSerializable
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function jsonSerialize()
{
$ret = [
'text' => $this->text
'text' => $this->text,
];
if($this->href !== null) {
if (null !== $this->href) {
$ret['href'] = $this->href;
}
if($this->tags !== null) {
if (null !== $this->tags) {
$ret['tags'] = $this->tags;
}
if($this->nodes !== null) {
if (null !== $this->nodes) {
$ret['nodes'] = $this->nodes;
}
if($this->state !== null) {
if (null !== $this->state) {
$ret['state'] = $this->state;
}

View file

@ -21,11 +21,8 @@
namespace App\Helpers\Trees;
use App\Helpers\Trees\TreeViewNode;
class TreeViewNodeIterator extends \ArrayIterator implements \RecursiveIterator
{
/**
* @param $nodes TreeViewNode[]
*/
@ -35,22 +32,24 @@ class TreeViewNodeIterator extends \ArrayIterator implements \RecursiveIterator
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hasChildren()
{
/** @var TreeViewNode $element */
$element = $this->current();
return !empty($element->getNodes());
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function getChildren()
{
/** @var TreeViewNode $element */
$element = $this->current();
return new TreeViewNodeIterator($element->getNodes());
return new self($element->getNodes());
}
}

View file

@ -75,20 +75,20 @@ class TreeViewNodeState implements \JsonSerializable
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function jsonSerialize()
{
$ret = [];
if ($this->selected !== null) {
if (null !== $this->selected) {
$ret['selected'] = $this->selected;
}
if($this->disabled !== null) {
if (null !== $this->disabled) {
$ret['disabled'] = $this->disabled;
}
if($this->expanded !== null) {
if (null !== $this->expanded) {
$ret['expanded'] = $this->expanded;
}

View file

@ -31,15 +31,15 @@ use Doctrine\Migrations\AbstractMigration;
*/
final class Version20191214153125 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return '';
}
public function up(Schema $schema) : void
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE u2f_keys (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, key_handle VARCHAR(64) NOT NULL, public_key VARCHAR(255) NOT NULL, certificate LONGTEXT NOT NULL, counter VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_4F4ADB4BA76ED395 (user_id), UNIQUE INDEX user_unique (user_id, key_handle), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE u2f_keys ADD CONSTRAINT FK_4F4ADB4BA76ED395 FOREIGN KEY (user_id) REFERENCES `users` (id)');
@ -47,10 +47,10 @@ final class Version20191214153125 extends AbstractMigration
$this->addSql('ALTER TABLE users ADD google_authenticator_secret VARCHAR(255) DEFAULT NULL, ADD backup_codes LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', ADD backup_codes_generation_date DATETIME DEFAULT NULL, ADD trusted_device_cookie_version INT NOT NULL');
}
public function down(Schema $schema) : void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('DROP TABLE u2f_keys');
$this->addSql('ALTER TABLE `groups` DROP enforce_2fa');

View file

@ -21,20 +21,19 @@
namespace App\Repository;
use App\Entity\Base\NamedDBElement;
use App\Helpers\Trees\TreeViewNode;
use Doctrine\ORM\EntityRepository;
class NamedDBElementRepository extends EntityRepository
{
/**
* Gets a tree of TreeViewNode elements. The root elements has $parent as parent.
* The treeview is generic, that means the href are null and ID values are set.
*
* @return TreeViewNode[]
*/
public function getGenericNodeTree() : array
public function getGenericNodeTree(): array
{
$result = [];

View file

@ -37,14 +37,15 @@ class StructuralDBElementRepository extends NamedDBElementRepository
return $this->findBy(['parent' => null], ['name' => 'ASC']);
}
/**
* Gets a tree of TreeViewNode elements. The root elements has $parent as parent.
* The treeview is generic, that means the href are null and ID values are set.
* @param StructuralDBElement|null $parent The parent the root elements should have.
*
* @param StructuralDBElement|null $parent The parent the root elements should have.
*
* @return TreeViewNode[]
*/
public function getGenericNodeTree(?StructuralDBElement $parent = null) : array
public function getGenericNodeTree(?StructuralDBElement $parent = null): array
{
$result = [];
@ -80,7 +81,7 @@ class StructuralDBElementRepository extends NamedDBElementRepository
//$result = iterator_to_array($recursiveIterator);
//We can not use iterator_to_array here or we get only the parent elements
foreach($recursiveIterator as $item) {
foreach ($recursiveIterator as $item) {
$result[] = $item;
}

View file

@ -42,9 +42,9 @@ class UserRepository extends NamedDBElementRepository implements PasswordUpgrade
*
* @return User|null
*/
public function getAnonymousUser() : ?User
public function getAnonymousUser(): ?User
{
if ($this->anonymous_user === null) {
if (null === $this->anonymous_user) {
$this->anonymous_user = $this->findOneBy([
'id' => User::ID_ANONYMOUS,
]);
@ -55,10 +55,12 @@ class UserRepository extends NamedDBElementRepository implements PasswordUpgrade
/**
* Find a user by its name or its email. Useful for login or password reset purposes.
*
* @param string $name_or_password The username or the email of the user that should be found
*
* @return User|null The user if it is existing, null if no one matched the criteria
*/
public function findByEmailOrName(string $name_or_password) : ?User
public function findByEmailOrName(string $name_or_password): ?User
{
if (empty($name_or_password)) {
return null;
@ -79,7 +81,7 @@ class UserRepository extends NamedDBElementRepository implements PasswordUpgrade
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
{

View file

@ -80,16 +80,18 @@ class ElementPermissionListener
/**
* Checks if access to the property of the given element is granted.
* This function adds an additional cache layer, where the voters are called only once (to improve performance).
* @param string $mode What operation should be checked. Must be 'read' or 'edit'
*
* @param string $mode What operation should be checked. Must be 'read' or 'edit'
* @param ColumnSecurity $annotation The annotation of the property that should be checked
* @param DBElement $element The element that should for which should be checked
* @param DBElement $element The element that should for which should be checked
*
* @return bool True if the user is allowed to read that property
*/
protected function isGranted(string $mode, ColumnSecurity $annotation, DBElement $element) : bool
protected function isGranted(string $mode, ColumnSecurity $annotation, DBElement $element): bool
{
if ($mode === 'read') {
if ('read' === $mode) {
$operation = $annotation->getReadOperationName();
} elseif ($mode === 'edit') {
} elseif ('edit' === $mode) {
$operation = $annotation->getEditOperationName();
} else {
throw new \InvalidArgumentException('$mode must be either "read" or "edit"!');
@ -101,12 +103,11 @@ class ElementPermissionListener
}
//Check if we have already have saved the permission, otherwise save it to cache
if (!isset($this->perm_cache[$mode][get_class($element)][$operation])) {
$this->perm_cache[$mode][get_class($element)][$operation] = $this->security->isGranted($operation, $element);
if (!isset($this->perm_cache[$mode][\get_class($element)][$operation])) {
$this->perm_cache[$mode][\get_class($element)][$operation] = $this->security->isGranted($operation, $element);
}
return $this->perm_cache[$mode][get_class($element)][$operation];
return $this->perm_cache[$mode][\get_class($element)][$operation];
}
/**

View file

@ -26,13 +26,11 @@ use Symfony\Component\Security\Core\Exception\AccountStatusException;
use Symfony\Component\Security\Core\Exception\DisabledException;
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class UserChecker implements UserCheckerInterface
{
public function __construct()
{
}
/**

View file

@ -32,8 +32,6 @@ class AttachmentVoter extends ExtendedVoter
*
* @param $attribute
* @param $subject
*
* @return bool
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{

View file

@ -72,7 +72,6 @@ abstract class ExtendedVoter extends Voter
*
* @param $attribute
* @param $subject
* @return bool
*/
abstract protected function voteOnUser($attribute, $subject, User $user): bool;
}

View file

@ -32,8 +32,6 @@ class GroupVoter extends ExtendedVoter
*
* @param $attribute
* @param $subject
*
* @return bool
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{

View file

@ -35,8 +35,6 @@ class PermissionVoter extends ExtendedVoter
*
* @param $attribute
* @param $subject
*
* @return bool
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{

View file

@ -54,9 +54,9 @@ class StructureVoter extends ExtendedVoter
/**
* Maps a instance type to the permission name.
*
* @param $subject mixed The subject for which the permission name should be generated.
* @param $subject mixed The subject for which the permission name should be generated
*
* @return string|null The name of the permission for the subject's type or null, if the subject is not supported.
* @return string|null the name of the permission for the subject's type or null, if the subject is not supported
*/
protected function instanceToPermissionName($subject): ?string
{
@ -91,8 +91,6 @@ class StructureVoter extends ExtendedVoter
*
* @param $attribute
* @param $subject
*
* @return bool
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{

View file

@ -95,7 +95,7 @@ class AmountFormatter
*
* @return string The formatted string
*
* @throws \InvalidArgumentException Thrown if $value is not numeric.
* @throws \InvalidArgumentException thrown if $value is not numeric
*/
public function format($value, ?MeasurementUnit $unit = null, array $options = [])
{

View file

@ -61,8 +61,6 @@ class AttachmentManager
* or is not existing.
*
* @param Attachment $attachment The attachment for which the filepath should be determined
*
* @return string|null
*/
public function toAbsoluteFilePath(Attachment $attachment): ?string
{
@ -96,7 +94,7 @@ class AttachmentManager
*
* @param Attachment $attachment The attachment for which the existence should be checked
*
* @return bool True if the file is existing.
* @return bool true if the file is existing
*/
public function isFileExisting(Attachment $attachment): bool
{
@ -111,9 +109,7 @@ class AttachmentManager
* Returns the filesize of the attachments in bytes.
* For external attachments or not existing attachments, null is returned.
*
* @param Attachment $attachment The filesize for which the filesize should be calculated.
*
* @return int|null
* @param Attachment $attachment the filesize for which the filesize should be calculated
*/
public function getFileSize(Attachment $attachment): ?int
{

View file

@ -44,11 +44,11 @@ class AttachmentPathResolver
/**
* AttachmentPathResolver constructor.
*
* @param string $project_dir The kernel that should be used to resolve the project dir.
* @param string $media_path The path where uploaded attachments should be stored.
* @param string $project_dir the kernel that should be used to resolve the project dir
* @param string $media_path the path where uploaded attachments should be stored
* @param string|null $footprints_path The path where builtin attachments are stored.
* Set to null if this ressource should be disabled.
* @param string|null $models_path Set to null if this ressource should be disabled.
* @param string|null $models_path set to null if this ressource should be disabled
*/
public function __construct(string $project_dir, string $media_path, string $secure_path, ?string $footprints_path, ?string $models_path)
{
@ -83,8 +83,6 @@ class AttachmentPathResolver
* @internal
*
* @param string|null $param_path The parameter value that should be converted to a absolute path
*
* @return string|null
*/
public function parameterToAbsolutePath(?string $param_path): ?string
{
@ -120,8 +118,6 @@ class AttachmentPathResolver
* Create an array usable for preg_replace out of an array of placeholders or pathes.
* Slashes and other chars become escaped.
* For example: '%TEST%' becomes '/^%TEST%/'.
*
* @return array
*/
protected function arrayToRegexArray(array $array): array
{
@ -139,7 +135,7 @@ class AttachmentPathResolver
* Converts an relative placeholder filepath (with %MEDIA% or older %BASE%) to an absolute filepath on disk.
* The directory separator is always /. Relative pathes are not realy possible (.. is striped).
*
* @param string $placeholder_path The filepath with placeholder for which the real path should be determined.
* @param string $placeholder_path the filepath with placeholder for which the real path should be determined
*
* @return string|null The absolute real path of the file, or null if the placeholder path is invalid
*/
@ -175,7 +171,7 @@ class AttachmentPathResolver
/**
* Converts an real absolute filepath to a placeholder version.
*
* @param string $real_path The absolute path, for which the placeholder version should be generated.
* @param string $real_path the absolute path, for which the placeholder version should be generated
* @param bool $old_version By default the %MEDIA% placeholder is used, which is directly replaced with the
* media directory. If set to true, the old version with %BASE% will be used, which is the project directory.
*
@ -213,7 +209,7 @@ class AttachmentPathResolver
/**
* The path where uploaded attachments is stored.
*
* @return string The absolute path to the media folder.
* @return string the absolute path to the media folder
*/
public function getMediaPath(): string
{
@ -224,7 +220,7 @@ class AttachmentPathResolver
* The path where secured attachments are stored. Must not be located in public/ folder, so it can only be accessed
* via the attachment controller.
*
* @return string The absolute path to the secure path.
* @return string the absolute path to the secure path
*/
public function getSecurePath(): string
{

View file

@ -51,7 +51,7 @@ class AttachmentReverseSearch
*
* @param \SplFileInfo $file The file for which is searched
*
* @return Attachment[] An list of attachments that use the given file.
* @return Attachment[] an list of attachments that use the given file
*/
public function findAttachmentsByFile(\SplFileInfo $file): array
{
@ -69,7 +69,7 @@ class AttachmentReverseSearch
* Deletes the given file if it is not used by more than $threshold attachments.
*
* @param \SplFileInfo $file The file that should be removed
* @param int $threshold The threshold used, to determine if a file should be deleted or not.
* @param int $threshold the threshold used, to determine if a file should be deleted or not
*
* @return bool True, if the file was delete. False if not.
*/

View file

@ -89,7 +89,7 @@ class AttachmentSubmitHandler
* @param Attachment $attachment The attachment that should be used for generating an attachment
* @param string $extension The extension that the new file should have (must only contain chars allowed in pathes)
*
* @return string The new filename.
* @return string the new filename
*/
public function generateAttachmentFilename(Attachment $attachment, string $extension): string
{
@ -114,7 +114,7 @@ class AttachmentSubmitHandler
* @param Attachment $attachment The attachment that should be used for
* @param bool $secure_upload True if the file path should be located in a safe location
*
* @return string The absolute path for the attachment folder.
* @return string the absolute path for the attachment folder
*/
public function generateAttachmentPath(Attachment $attachment, bool $secure_upload = false): string
{
@ -143,7 +143,7 @@ class AttachmentSubmitHandler
* Handle the submit of an attachment form.
* This function will move the uploaded file or download the URL file to server, if needed.
*
* @param Attachment $attachment The attachment that should be used for handling.
* @param Attachment $attachment the attachment that should be used for handling
* @param UploadedFile|null $file If given, that file will be moved to the right location
* @param array $options The options to use with the upload. Here you can specify that an URL should be downloaded,
* or an file should be moved to a secure location.
@ -181,8 +181,8 @@ class AttachmentSubmitHandler
/**
* Move the given attachment to secure location (or back to public folder) if needed.
*
* @param Attachment $attachment The attachment for which the file should be moved.
* @param bool $secure_location This value determines, if the attachment is moved to the secure or public folder.
* @param Attachment $attachment the attachment for which the file should be moved
* @param bool $secure_location this value determines, if the attachment is moved to the secure or public folder
*
* @return Attachment The attachment with the updated filepath
*/

View file

@ -53,7 +53,7 @@ class AttachmentURLGenerator
* Converts the absolute file path to a version relative to the public folder, that can be passed to asset
* Asset Component functions.
*
* @param string $absolute_path The absolute path that should be converted.
* @param string $absolute_path the absolute path that should be converted
* @param string|null $public_path The public path to which the relative pathes should be created.
* The path must NOT have a trailing slash!
* If this is set to null, the global public/ folder is used.
@ -78,8 +78,6 @@ class AttachmentURLGenerator
/**
* Returns a URL under which the attachment file can be viewed.
*
* @return string
*/
public function getViewURL(Attachment $attachment): string
{
@ -101,8 +99,6 @@ class AttachmentURLGenerator
/**
* Returns a URL to an thumbnail of the attachment file.
*
* @return string
*/
public function getThumbnailURL(Attachment $attachment, string $filter_name = 'thumbnail_sm'): string
{
@ -137,8 +133,6 @@ class AttachmentURLGenerator
/**
* Returns a download link to the file associated with the attachment.
*
* @return string
*/
public function getDownloadURL(Attachment $attachment): string
{

View file

@ -55,7 +55,7 @@ class BuiltinAttachmentsFinder
* The array is a list of the relative filenames using the %PLACEHOLDERS%.
* The list contains the files from all configured valid ressoureces.
*
* @return array The list of the ressources, or an empty array if an error happened.
* @return array the list of the ressources, or an empty array if an error happened
*/
public function getListOfRessources(): array
{
@ -92,9 +92,9 @@ class BuiltinAttachmentsFinder
/**
* Find all ressources which are matching the given keyword and the specified options.
*
* @param string $keyword The keyword you want to search for.
* @param string $keyword the keyword you want to search for
* @param array $options Here you can specify some options (see configureOptions for list of options)
* @param array|null $base_list The list from which should be used as base for filtering.
* @param array|null $base_list the list from which should be used as base for filtering
*
* @return array The list of the results matching the specified keyword and options
*/

View file

@ -53,9 +53,9 @@ class FileTypeFilterTools
/**
* Check if a filetype filter string is valid.
*
* @param string $filter The filter string that should be validated.
* @param string $filter the filter string that should be validated
*
* @return bool Returns true, if the string is valid.
* @return bool returns true, if the string is valid
*/
public function validateFilterString(string $filter): bool
{
@ -84,7 +84,7 @@ class FileTypeFilterTools
* Normalize a filter string. All extensions are converted to lowercase, too much whitespaces are removed.
* The filter string is not validated.
*
* @param string $filter The filter string that should be normalized.
* @param string $filter the filter string that should be normalized
*
* @return string The normalized filter string
*/
@ -131,7 +131,7 @@ class FileTypeFilterTools
/**
* Get a list of all file extensions that matches the given filter string.
*
* @param string $filter A valid filetype filter string.
* @param string $filter a valid filetype filter string
*
* @return string[] An array of allowed extensions ['txt', 'csv', 'gif']
*/
@ -166,10 +166,10 @@ class FileTypeFilterTools
/**
* Check if the given extension matches the filter.
*
* @param string $filter The filter which should be used for checking.
* @param string $extension The extension that should be checked.
* @param string $filter the filter which should be used for checking
* @param string $extension the extension that should be checked
*
* @return bool Returns true, if the extension is allowed with the given filter.
* @return bool returns true, if the extension is allowed with the given filter
*/
public function isExtensionAllowed(string $filter, string $extension): bool
{

View file

@ -38,7 +38,7 @@ class PartPreviewGenerator
* The priority is: Part MasterAttachment -> Footprint MasterAttachment -> Category MasterAttachment
* -> Storelocation Attachment -> MeasurementUnit Attachment -> ManufacturerAttachment.
*
* @param Part $part The part for which the attachments should be determined.
* @param Part $part the part for which the attachments should be determined
*
* @return Attachment[]
*/
@ -97,8 +97,6 @@ class PartPreviewGenerator
* The returned attachment is guaranteed to be existing and be a picture.
*
* @param Part $part The part for which the attachment should be determined
*
* @return Attachment|null
*/
public function getTablePreviewAttachment(Part $part): ?Attachment
{
@ -123,9 +121,9 @@ class PartPreviewGenerator
/**
* Checks if a attachment is exising and a valid picture.
*
* @param Attachment|null $attachment The attachment that should be checked.
* @param Attachment|null $attachment the attachment that should be checked
*
* @return bool True if the attachment is valid.
* @return bool true if the attachment is valid
*/
protected function isAttachmentValidPicture(?Attachment $attachment): bool
{

View file

@ -21,22 +21,21 @@
namespace App\Services;
use Symfony\Component\DependencyInjection\EnvVarProcessorInterface;
use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
class CustomEnvVarProcessor implements EnvVarProcessorInterface
{
/**
* @inheritDoc
* {@inheritdoc}
*/
public function getEnv($prefix, $name, \Closure $getEnv)
{
if ('validMailDSN' === $prefix) {
try {
$env = $getEnv($name);
return !empty($env) && $env !== 'null://null';
return !empty($env) && 'null://null' !== $env;
} catch (EnvNotFoundException $exception) {
return false;
}
@ -44,7 +43,7 @@ class CustomEnvVarProcessor implements EnvVarProcessorInterface
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public static function getProvidedTypes()
{

View file

@ -80,9 +80,9 @@ class ElementTypeNameGenerator
*
* @param DBElement $entity The element for which the label should be generated
*
* @return string The locatlized label for the entity type.
* @return string the locatlized label for the entity type
*
* @throws EntityNotSupportedException When the passed entity is not supported.
* @throws EntityNotSupportedException when the passed entity is not supported
*/
public function getLocalizedTypeLabel(DBElement $entity): string
{
@ -107,11 +107,12 @@ class ElementTypeNameGenerator
* For example this could be something like: "Part: BC547".
* It uses getLocalizedLabel to determine the type.
*
* @param NamedDBElement $entity The entity for which the string should be generated.
* @param NamedDBElement $entity the entity for which the string should be generated
* @param bool $use_html If set to true, a html string is returned, where the type is set italic
*
* @return string The localized string
* @throws EntityNotSupportedException When the passed entity is not supported.
*
* @throws EntityNotSupportedException when the passed entity is not supported
*/
public function getTypeNameCombination(NamedDBElement $entity, bool $use_html = false): string
{

View file

@ -43,9 +43,9 @@ class EntityExporter
* Exports an Entity or an array of entities to multiple file formats.
*
* @param $entity NamedDBElement|NamedDBElement[] The element/elements[] that should be exported
* @param Request $request The request that should be used for option resolving.
* @param Request $request the request that should be used for option resolving
*
* @return Response The generated response containing the exported data.
* @return Response the generated response containing the exported data
*
* @throws \ReflectionException
*/

View file

@ -21,7 +21,6 @@
namespace App\Services;
use App\Entity\Base\DBElement;
use App\Entity\Base\StructuralDBElement;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\File\File;
@ -59,10 +58,10 @@ class EntityImporter
*
* @param string $lines The list of names seperated by \n
* @param string $class_name The name of the class for which the entities should be created
* @param StructuralDBElement|null $parent The element which will be used as parent element for new elements.
* @param array $errors An associative array containing all validation errors.
* @param StructuralDBElement|null $parent the element which will be used as parent element for new elements
* @param array $errors an associative array containing all validation errors
*
* @return StructuralDBElement[] An array containing all valid imported entities (with the type $class_name)
* @return StructuralDBElement[] An array containing all valid imported entities (with the type $class_name)
*/
public function massCreation(string $lines, string $class_name, ?StructuralDBElement $parent = null, array &$errors = []): array
{
@ -72,7 +71,7 @@ class EntityImporter
if (!is_a($class_name, StructuralDBElement::class, true)) {
throw new \InvalidArgumentException('$class_name must be a StructuralDBElement type!');
}
if ($parent !== null && !is_a($parent, $class_name)) {
if (null !== $parent && !is_a($parent, $class_name)) {
throw new \InvalidArgumentException('$parent must have the same type as specified in $class_name!');
}
@ -81,7 +80,7 @@ class EntityImporter
foreach ($names as $name) {
$name = trim($name);
if ($name === '') {
if ('' === $name) {
//Skip empty lines (StrucuralDBElements must have a name)
continue;
}
@ -108,9 +107,9 @@ class EntityImporter
* This methods deserializes the given file and saves it database.
* The imported elements will be checked (validated) before written to database.
*
* @param File $file The file that should be used for importing.
* @param string $class_name The class name of the enitity that should be imported.
* @param array $options Options for the import process.
* @param File $file the file that should be used for importing
* @param string $class_name the class name of the enitity that should be imported
* @param array $options options for the import process
*
* @return array An associative array containing an ConstraintViolationList and the entity name as key are returned,
* if an error happened during validation. When everything was successfull, the array should be empty.
@ -156,11 +155,11 @@ class EntityImporter
*
* The imported elements will NOT be validated. If you want to use the result array, you have to validate it by yourself.
*
* @param File $file The file that should be used for importing.
* @param string $class_name The class name of the enitity that should be imported.
* @param array $options Options for the import process.
* @param File $file the file that should be used for importing
* @param string $class_name the class name of the enitity that should be imported
* @param array $options options for the import process
*
* @return array An array containing the deserialized elements.
* @return array an array containing the deserialized elements
*/
public function fileToEntityArray(File $file, string $class_name, array $options = []): array
{
@ -198,8 +197,8 @@ class EntityImporter
/**
* This functions corrects the parent setting based on the children value of the parent.
*
* @param iterable $entities The list of entities that should be fixed.
* @param null $parent The parent, to which the entity should be set.
* @param iterable $entities the list of entities that should be fixed
* @param null $parent the parent, to which the entity should be set
*/
protected function correctParentEntites(iterable $entities, $parent = null)
{

View file

@ -63,7 +63,7 @@ class EntityURLGenerator
* Throws an exception if the entity class is not known to the map.
*
* @param array $map The map that should be used for determing the controller
* @param $entity mixed The entity for which the controller name should be determined.
* @param $entity mixed The entity for which the controller name should be determined
*
* @return string The name of the controller fitting the entity class
*
@ -93,13 +93,13 @@ class EntityURLGenerator
* For the given types, the [type]URL() functions are called (e.g. infoURL()).
* Not all entity class and $type combinations are supported.
*
* @param $entity mixed The element for which the page should be generated.
* @param $entity mixed The element for which the page should be generated
* @param string $type The page type. Currently supported: 'info', 'edit', 'create', 'clone', 'list'/'list_parts'
*
* @return string The link to the desired page.
* @return string the link to the desired page
*
* @throws EntityNotSupportedException Thrown if the entity is not supported for the given type.
* @throws \InvalidArgumentException Thrown if the givent type is not existing.
* @throws EntityNotSupportedException thrown if the entity is not supported for the given type
* @throws \InvalidArgumentException thrown if the givent type is not existing
*/
public function getURL($entity, string $type)
{
@ -157,7 +157,7 @@ class EntityURLGenerator
/**
* Generates an URL to a page, where info about this entity can be viewed.
*
* @param $entity mixed The entity for which the info should be generated.
* @param $entity mixed The entity for which the info should be generated
*
* @return string The URL to the info page
*
@ -188,9 +188,9 @@ class EntityURLGenerator
/**
* Generates an URL to a page, where this entity can be edited.
*
* @param $entity mixed The entity for which the edit link should be generated.
* @param $entity mixed The entity for which the edit link should be generated
*
* @return string The URL to the edit page.
* @return string the URL to the edit page
*
* @throws EntityNotSupportedException If the method is not supported for the given Entity
*/
@ -217,9 +217,9 @@ class EntityURLGenerator
/**
* Generates an URL to a page, where a entity of this type can be created.
*
* @param $entity mixed The entity for which the link should be generated.
* @param $entity mixed The entity for which the link should be generated
*
* @return string The URL to the page.
* @return string the URL to the page
*
* @throws EntityNotSupportedException If the method is not supported for the given Entity
*/
@ -247,9 +247,9 @@ class EntityURLGenerator
* Generates an URL to a page, where a new entity can be created, that has the same informations as the
* given entity (element cloning).
*
* @param $entity mixed The entity for which the link should be generated.
* @param $entity mixed The entity for which the link should be generated
*
* @return string The URL to the page.
* @return string the URL to the page
*
* @throws EntityNotSupportedException If the method is not supported for the given Entity
*/
@ -265,9 +265,9 @@ class EntityURLGenerator
/**
* Generates an URL to a page, where all parts are listed, which are contained in the given element.
*
* @param $entity mixed The entity for which the link should be generated.
* @param $entity mixed The entity for which the link should be generated
*
* @return string The URL to the page.
* @return string the URL to the page
*
* @throws EntityNotSupportedException If the method is not supported for the given Entity
*/

View file

@ -21,7 +21,6 @@
namespace App\Services;
use App\Entity\Attachments\Attachment;
class FAIconGenerator
@ -42,19 +41,21 @@ class FAIconGenerator
/**
* Gets the Font awesome icon class for a file with the specified extension.
* For example 'pdf' gives you 'fa-file-pdf'
* For example 'pdf' gives you 'fa-file-pdf'.
*
* @param string $extension The file extension (without dot). Must be ASCII chars only!
*
* @return string The fontawesome class with leading 'fa-'
*/
public function fileExtensionToFAType(string $extension) : string
public function fileExtensionToFAType(string $extension): string
{
if ($extension === '') {
if ('' === $extension) {
throw new \InvalidArgumentException('You must specify an extension!');
}
//Normalize file extension
$extension = strtolower($extension);
foreach (self::EXT_MAPPING as $fa => $exts) {
if (in_array($extension, $exts, true)) {
if (\in_array($extension, $exts, true)) {
return $fa;
}
}
@ -65,13 +66,15 @@ class FAIconGenerator
/**
* Returns HTML code to show the given fontawesome icon.
* E.g. <i class="fas fa-file-text"></i>
* E.g. <i class="fas fa-file-text"></i>.
*
* @param string $icon_class The icon which should be shown (e.g. fa-file-text)
* @param string $style The style of the icon 'fas'
* @param string $options Any other css class attributes like size, etc.
* @param string $style The style of the icon 'fas'
* @param string $options Any other css class attributes like size, etc.
*
* @return string The final html
*/
public function generateIconHTML(string $icon_class, string $style = 'fas', string $options = '') : string
public function generateIconHTML(string $icon_class, string $style = 'fas', string $options = ''): string
{
//XSS protection
$icon_class = htmlspecialchars($icon_class);

View file

@ -39,10 +39,10 @@ class MarkdownParser
* Mark the markdown for rendering.
* The rendering of markdown is done on client side.
*
* @param string $markdown The markdown text that should be parsed to html.
* @param string $markdown the markdown text that should be parsed to html
* @param bool $inline_mode Only allow inline markdown codes like (*bold* or **italic**), not something like tables
*
* @return string The markdown in a version that can be parsed on client side.
* @return string the markdown in a version that can be parsed on client side
*/
public function markForRendering(string $markdown, bool $inline_mode = false): string
{

View file

@ -38,10 +38,10 @@ class MoneyFormatter
/**
* Format the the given value in the given currency.
*
* @param string|float $value The value that should be formatted.
* @param string|float $value the value that should be formatted
* @param Currency|null $currency The currency that should be used for formatting. If null the global one is used
* @param int $decimals The number of decimals that should be shown.
* @param bool $show_all_digits If set to true, all digits are shown, even if they are null.
* @param int $decimals the number of decimals that should be shown
* @param bool $show_all_digits if set to true, all digits are shown, even if they are null
*
* @return string
*/

Some files were not shown because too many files have changed in this diff Show more