Fix code formatting

This commit is contained in:
Timothy Warren 2022-09-30 10:49:02 -04:00
parent 41d19ad84b
commit fb296c1034
24 changed files with 337 additions and 369 deletions

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
namespace App\Controller; namespace App\Controller;
@ -7,8 +7,7 @@ use App\Form\BrandType;
use App\Traits\FormControllerTrait; use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand')] #[Route('/brand')]
@ -29,7 +28,7 @@ class BrandController extends AbstractController
public function index(): Response public function index(): Response
{ {
return $this->itemListView('brands', [ return $this->itemListView('brands', [
'name' => 'asc' 'name' => 'asc',
]); ]);
} }
@ -49,20 +48,6 @@ class BrandController extends AbstractController
public function edit(Request $request, Brand $brand): Response public function edit(Request $request, Brand $brand): Response
{ {
return $this->itemUpdate($request, $brand, 'brand'); return $this->itemUpdate($request, $brand, 'brand');
//
// $form = $this->createForm(BrandType::class, $brand);
// $form->handleRequest($request);
//
// if ($form->isSubmitted() && $form->isValid()) {
// $entityManager->flush();
//
// return $this->redirectToRoute('brand_index', [], Response::HTTP_SEE_OTHER);
// }
//
// return $this->renderForm('brand/edit.html.twig', [
// 'brand' => $brand,
// 'form' => $form,
// ]);
} }
#[Route('/{id}', name: 'brand_delete', methods: ['POST'])] #[Route('/{id}', name: 'brand_delete', methods: ['POST'])]

View File

@ -4,10 +4,8 @@ namespace App\Controller;
use App\Entity\Camera; use App\Entity\Camera;
use App\Form\CameraType; use App\Form\CameraType;
use App\Traits\DeleteFormTrait; use App\Traits\{DeleteFormTrait, FormControllerTrait};
use App\Traits\FormControllerTrait; use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\ORMInvalidArgumentException;
use LogicException; use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
@ -69,7 +67,7 @@ class CameraController extends AbstractController
#[Route(path: '/new', name: 'camera_new', methods: ['GET', 'POST'])] #[Route(path: '/new', name: 'camera_new', methods: ['GET', 'POST'])]
public function newAction(Request $request): RedirectResponse|Response public function newAction(Request $request): RedirectResponse|Response
{ {
return $this->itemCreate($request,'camera'); return $this->itemCreate($request, 'camera');
} }
/** /**
@ -78,7 +76,7 @@ class CameraController extends AbstractController
#[Route(path: '/{id}', name: 'camera_show', methods: ['GET'])] #[Route(path: '/{id}', name: 'camera_show', methods: ['GET'])]
public function showAction(Camera $camera): Response public function showAction(Camera $camera): Response
{ {
return $this->itemView($camera,'camera'); return $this->itemView($camera, 'camera');
} }
/** /**
@ -89,7 +87,7 @@ class CameraController extends AbstractController
#[Route(path: '/{id}/edit', name: 'camera_edit', methods: ['GET', 'POST'])] #[Route(path: '/{id}/edit', name: 'camera_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, Camera $camera): RedirectResponse|Response public function editAction(Request $request, Camera $camera): RedirectResponse|Response
{ {
return $this->itemUpdate($request, $camera,'camera'); return $this->itemUpdate($request, $camera, 'camera');
} }
/** /**
@ -97,7 +95,7 @@ class CameraController extends AbstractController
* *
* @throws LogicException * @throws LogicException
*/ */
#[Route(path: '/{id}', name: 'camera_delete', methods: ['POST','DELETE'])] #[Route(path: '/{id}', name: 'camera_delete', methods: ['POST', 'DELETE'])]
public function deleteAction(Request $request, Camera $camera): RedirectResponse public function deleteAction(Request $request, Camera $camera): RedirectResponse
{ {
return $this->itemDelete($request, $camera); return $this->itemDelete($request, $camera);

View File

@ -4,8 +4,7 @@ namespace App\Controller;
use App\Entity\CameraType; use App\Entity\CameraType;
use App\Form\CameraTypeType; use App\Form\CameraTypeType;
use App\Traits\DeleteFormTrait; use App\Traits\{DeleteFormTrait, FormControllerTrait};
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};

View File

@ -4,8 +4,7 @@ namespace App\Controller;
use App\Entity\Film; use App\Entity\Film;
use App\Form\FilmType; use App\Form\FilmType;
use App\Traits\DeleteFormTrait; use App\Traits\{DeleteFormTrait, FormControllerTrait};
use App\Traits\FormControllerTrait;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use LogicException; use LogicException;
@ -95,7 +94,7 @@ class FilmController extends AbstractController
* *
* @throws LogicException * @throws LogicException
*/ */
#[Route(path: '/{id}', name: 'film_delete', methods: ['POST','DELETE'])] #[Route(path: '/{id}', name: 'film_delete', methods: ['POST', 'DELETE'])]
public function deleteAction(Request $request, Film $film): RedirectResponse public function deleteAction(Request $request, Film $film): RedirectResponse
{ {
return $this->itemDelete($request, $film); return $this->itemDelete($request, $film);

View File

@ -4,11 +4,9 @@ namespace App\Controller;
use App\Entity\Flash; use App\Entity\Flash;
use App\Form\FlashType; use App\Form\FlashType;
use App\Traits\DeleteFormTrait; use App\Traits\{DeleteFormTrait, FormControllerTrait};
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
@ -45,7 +43,7 @@ class FlashController extends AbstractController
#[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])] #[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])]
public function newAction(Request $request): RedirectResponse|Response public function newAction(Request $request): RedirectResponse|Response
{ {
return $this->itemCreate($request,'flash'); return $this->itemCreate($request, 'flash');
} }
/** /**
@ -54,7 +52,7 @@ class FlashController extends AbstractController
#[Route(path: '/{id}', name: 'flash_show', methods: ['GET'])] #[Route(path: '/{id}', name: 'flash_show', methods: ['GET'])]
public function showAction(Flash $flash): Response public function showAction(Flash $flash): Response
{ {
return $this->itemView($flash,'flash'); return $this->itemView($flash, 'flash');
} }
/** /**

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
namespace App\Controller; namespace App\Controller;
@ -7,8 +7,7 @@ use App\Form\GPUCoreType;
use App\Traits\FormControllerTrait; use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/gpu-core')] #[Route('/gpu-core')]
@ -57,7 +56,7 @@ class GpuCoreController extends AbstractController
#[Route('/{id}', name: 'gpu-core_delete', methods: ['POST'])] #[Route('/{id}', name: 'gpu-core_delete', methods: ['POST'])]
public function delete(Request $request, GpuCore $gPUCore, EntityManagerInterface $entityManager): Response public function delete(Request $request, GpuCore $gPUCore, EntityManagerInterface $entityManager): Response
{ {
if ($this->isCsrfTokenValid('delete'.$gPUCore->getId(), $request->request->get('_token'))) { if ($this->isCsrfTokenValid('delete' . $gPUCore->getId(), $request->request->get('_token'))) {
$entityManager->remove($gPUCore); $entityManager->remove($gPUCore);
$entityManager->flush(); $entityManager->flush();
} }

View File

@ -4,8 +4,7 @@ namespace App\Controller;
use App\Entity\Lenses; use App\Entity\Lenses;
use App\Form\LensesType; use App\Form\LensesType;
use App\Traits\DeleteFormTrait; use App\Traits\{DeleteFormTrait, FormControllerTrait};
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
@ -67,7 +66,7 @@ class LensesController extends AbstractController
#[Route(path: '/new', name: 'lens_new', methods: ['GET', 'POST'])] #[Route(path: '/new', name: 'lens_new', methods: ['GET', 'POST'])]
public function newAction(Request $request): RedirectResponse|Response public function newAction(Request $request): RedirectResponse|Response
{ {
return $this->itemCreate($request,'lense'); return $this->itemCreate($request, 'lense');
} }
/** /**
@ -104,7 +103,7 @@ class LensesController extends AbstractController
/** /**
* Deletes a lens entity. * Deletes a lens entity.
*/ */
#[Route(path: '/{id}', name: 'lens_delete', methods: ['POST','DELETE'])] #[Route(path: '/{id}', name: 'lens_delete', methods: ['POST', 'DELETE'])]
public function deleteAction(Request $request, Lenses $lens): RedirectResponse public function deleteAction(Request $request, Lenses $lens): RedirectResponse
{ {
return $this->itemDelete($request, $lens); return $this->itemDelete($request, $lens);

View File

@ -5,8 +5,7 @@ namespace App\Controller;
use App\Entity\PreviouslyOwnedCamera; use App\Entity\PreviouslyOwnedCamera;
use App\Form\PreviouslyOwnedCameraType; use App\Form\PreviouslyOwnedCameraType;
use App\Traits\FormControllerTrait; use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
use Doctrine\ORM\ORMInvalidArgumentException;
use LogicException; use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
@ -39,7 +38,7 @@ class PreviouslyOwnedCameraController extends AbstractController
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])] #[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
public function indexAction(): Response public function indexAction(): Response
{ {
return $this->itemListView( 'previouslyOwnedCameras', [ return $this->itemListView('previouslyOwnedCameras', [
'brand' => 'ASC', 'brand' => 'ASC',
'mount' => 'ASC', 'mount' => 'ASC',
'model' => 'ASC', 'model' => 'ASC',

View File

@ -33,7 +33,7 @@ class PreviouslyOwnedFlashController extends AbstractController
#[Route(path: '/', name: 'previously-owned-flash_index', methods: ['GET'])] #[Route(path: '/', name: 'previously-owned-flash_index', methods: ['GET'])]
public function indexAction(): Response public function indexAction(): Response
{ {
return $this->itemListView( 'previouslyOwnedFlashes'); return $this->itemListView('previouslyOwnedFlashes');
} }
/** /**

View File

@ -16,7 +16,7 @@ class Brand
#[ORM\SequenceGenerator(sequenceName: 'brand_id_seq', allocationSize: 1, initialValue: 1)] #[ORM\SequenceGenerator(sequenceName: 'brand_id_seq', allocationSize: 1, initialValue: 1)]
private int $id; private int $id;
#[ORM\Column(name: 'name', unique: true, nullable: FALSE)] #[ORM\Column(name: 'name', unique: TRUE, nullable: FALSE)]
private string $name; private string $name;
public function __toString(): string public function __toString(): string

View File

@ -2,7 +2,6 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Stringable; use Stringable;

View File

@ -2,7 +2,6 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**

View File

@ -2,32 +2,31 @@
namespace App\Entity; namespace App\Entity;
trait GetSetTrait { use InvalidArgumentException;
trait GetSetTrait
{
public function __call(string $name, array $arguments): mixed public function __call(string $name, array $arguments): mixed
{ {
if (method_exists($this, $name)) if (method_exists($this, $name)) {
{ return $this->{$name}(...$arguments);
return $this->$name(...$arguments);
} }
// Apparently Doctrine first tries the method with the same // Apparently Doctrine first tries the method with the same
// name as the property, instead of with the get prefix // name as the property, instead of with the get prefix
if (property_exists($this, $name) && empty($arguments)) if (property_exists($this, $name) && empty($arguments)) {
{ return $this->{$name};
return $this->$name;
} }
if (str_starts_with('set', $name)) if (str_starts_with('set', $name)) {
{
$var = lcfirst(str_replace('set', '', $name)); $var = lcfirst(str_replace('set', '', $name));
if (property_exists($this, $var)) if (property_exists($this, $var)) {
{ $this->{$name} = $arguments[0];
$this->$name = $arguments[0];
} }
return $this; return $this;
} }
throw new \InvalidArgumentException("Undefined method: {$name}"); throw new InvalidArgumentException("Undefined method: {$name}");
} }
} }

View File

@ -2,7 +2,6 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'gpu', schema: 'collection')] #[ORM\Table(name: 'gpu', schema: 'collection')]

View File

@ -2,8 +2,6 @@
namespace App\Entity; namespace App\Entity;
use App\Repository\GPURepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'gpu_core', schema: 'collection')] #[ORM\Table(name: 'gpu_core', schema: 'collection')]
@ -41,7 +39,7 @@ class GpuCore
public function __toString(): string public function __toString(): string
{ {
return "$this->brand $this->name ($this->variant/$this->generationName)"; return "{$this->brand} {$this->name} ({$this->variant}/{$this->generationName})";
} }
public function getId(): ?int public function getId(): ?int

View File

@ -65,11 +65,10 @@ trait LensTrait
public function __get(string $name): mixed public function __get(string $name): mixed
{ {
if (property_exists($this, $name)) if (property_exists($this, $name)) {
{ return $this->{$name};
return $this->$name;
} }
return null; return NULL;
} }
} }

View File

@ -1,10 +1,9 @@
<?php <?php declare(strict_types=1);
namespace App\Form; namespace App\Form;
use App\Entity\Brand; use App\Entity\Brand;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class BrandType extends AbstractType class BrandType extends AbstractType
@ -12,8 +11,7 @@ class BrandType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $builder
->add('name') ->add('name');
;
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void

View File

@ -1,10 +1,9 @@
<?php <?php declare(strict_types=1);
namespace App\Form; namespace App\Form;
use App\Entity\GpuCore; use App\Entity\GpuCore;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class GPUCoreType extends AbstractType class GPUCoreType extends AbstractType
@ -18,8 +17,7 @@ class GPUCoreType extends AbstractType
->add('architecture') ->add('architecture')
->add('architectureLink') ->add('architectureLink')
->add('generationName') ->add('generationName')
->add('processNode') ->add('processNode');
;
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void

View File

@ -7,18 +7,15 @@ use Doctrine\ORM\{EntityRepository};
use ReflectionObject; use ReflectionObject;
use Throwable; use Throwable;
abstract class AcquireRepository extends EntityRepository abstract class AcquireRepository extends EntityRepository
{ {
abstract public function reacquire(mixed $currentRecord): void; abstract public function reacquire(mixed $currentRecord): void;
abstract public function deacquire(mixed $currentRecord): void; abstract public function deacquire(mixed $currentRecord): void;
/** /**
* Move a record from the table represented by $currentRecord * Move a record from the table represented by $currentRecord
* into the table represented by $newRecord * into the table represented by $newRecord
*
* @param mixed $currentRecord
* @param mixed $newRecord
*/ */
protected function moveRecord(mixed $currentRecord, mixed $newRecord): void protected function moveRecord(mixed $currentRecord, mixed $newRecord): void
{ {

View File

@ -178,7 +178,7 @@ trait FormControllerTrait
protected function deleteCSRF(Request $request, mixed $item): RedirectResponse protected function deleteCSRF(Request $request, mixed $item): RedirectResponse
{ {
if ($this->isCsrfTokenValid('delete'.$item->getId(), $request->request->get('_token'))) { if ($this->isCsrfTokenValid('delete' . $item->getId(), $request->request->get('_token'))) {
$this->entityManager->remove($item); $this->entityManager->remove($item);
$this->entityManager->flush(); $this->entityManager->flush();
} }

View File

@ -4,10 +4,16 @@ namespace App\Types;
enum BusInterface: string { enum BusInterface: string {
case PCI = 'PCI'; case PCI = 'PCI';
case ISA = 'ISA'; case ISA = 'ISA';
case VLB = 'VLB (Vesa Local Bus)'; case VLB = 'VLB (Vesa Local Bus)';
case AGP = 'AGP'; case AGP = 'AGP';
case AGPX2 = 'AGP 2x'; case AGPX2 = 'AGP 2x';
case AGPX4 = 'AGP 4x'; case AGPX4 = 'AGP 4x';
case AGPX8 = 'AGP 8x'; case AGPX8 = 'AGP 8x';
} }

View File

@ -15,7 +15,7 @@ class Money implements Stringable
public function getValue(): float public function getValue(): float
{ {
return (float) str_replace(['$', ','], '', (string)$this->value); return (float) str_replace(['$', ','], '', (string) $this->value);
} }
public function __toString(): string public function __toString(): string