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;
@ -7,8 +7,7 @@ use App\Form\BrandType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand')]
@ -29,7 +28,7 @@ class BrandController extends AbstractController
public function index(): Response
{
return $this->itemListView('brands', [
'name' => 'asc'
'name' => 'asc',
]);
}
@ -49,20 +48,6 @@ class BrandController extends AbstractController
public function edit(Request $request, Brand $brand): Response
{
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'])]

View File

@ -4,10 +4,8 @@ namespace App\Controller;
use App\Entity\Camera;
use App\Form\CameraType;
use App\Traits\DeleteFormTrait;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\ORMInvalidArgumentException;
use App\Traits\{DeleteFormTrait, FormControllerTrait};
use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
@ -69,7 +67,7 @@ class CameraController extends AbstractController
#[Route(path: '/new', name: 'camera_new', methods: ['GET', 'POST'])]
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'])]
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'])]
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
*/
#[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
{
return $this->itemDelete($request, $camera);

View File

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

View File

@ -4,8 +4,7 @@ namespace App\Controller;
use App\Entity\Film;
use App\Form\FilmType;
use App\Traits\DeleteFormTrait;
use App\Traits\FormControllerTrait;
use App\Traits\{DeleteFormTrait, FormControllerTrait};
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityManagerInterface;
use LogicException;
@ -95,7 +94,7 @@ class FilmController extends AbstractController
*
* @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
{
return $this->itemDelete($request, $film);

View File

@ -4,11 +4,9 @@ namespace App\Controller;
use App\Entity\Flash;
use App\Form\FlashType;
use App\Traits\DeleteFormTrait;
use App\Traits\FormControllerTrait;
use App\Traits\{DeleteFormTrait, FormControllerTrait};
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
use Symfony\Component\Routing\Annotation\Route;
@ -45,7 +43,7 @@ class FlashController extends AbstractController
#[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])]
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'])]
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;
@ -7,8 +7,7 @@ use App\Form\GPUCoreType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route;
#[Route('/gpu-core')]
@ -57,7 +56,7 @@ class GpuCoreController extends AbstractController
#[Route('/{id}', name: 'gpu-core_delete', methods: ['POST'])]
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->flush();
}

View File

@ -4,8 +4,7 @@ namespace App\Controller;
use App\Entity\Lenses;
use App\Form\LensesType;
use App\Traits\DeleteFormTrait;
use App\Traits\FormControllerTrait;
use App\Traits\{DeleteFormTrait, FormControllerTrait};
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
@ -67,7 +66,7 @@ class LensesController extends AbstractController
#[Route(path: '/new', name: 'lens_new', methods: ['GET', 'POST'])]
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.
*/
#[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
{
return $this->itemDelete($request, $lens);

View File

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

View File

@ -33,7 +33,7 @@ class PreviouslyOwnedFlashController extends AbstractController
#[Route(path: '/', name: 'previously-owned-flash_index', methods: ['GET'])]
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)]
private int $id;
#[ORM\Column(name: 'name', unique: true, nullable: FALSE)]
#[ORM\Column(name: 'name', unique: TRUE, nullable: FALSE)]
private string $name;
public function __toString(): string

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,6 @@
namespace App\Entity;
use App\Repository\GPURepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'gpu_core', schema: 'collection')]
@ -41,7 +39,7 @@ class GpuCore
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

View File

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

View File

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

View File

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

View File

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

View File

@ -178,7 +178,7 @@ trait FormControllerTrait
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->flush();
}

View File

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

View File

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