Skip to content

Commit

Permalink
Minor improvments
Browse files Browse the repository at this point in the history
Add test file

Add test file
  • Loading branch information
Spomky committed Sep 22, 2023
1 parent f281efe commit 7a1d3b0
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 193 deletions.
145 changes: 73 additions & 72 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
]
);

$config->services()
->remove(PhpUnitTestClassRequiresCoversFixer::class);

$config->parallel();
$config->paths([__DIR__]);
$config->skip([
Expand All @@ -109,6 +106,7 @@
__DIR__ . '/heroku',
__DIR__ . '/public',
__DIR__ . '/var',
PhpUnitTestClassRequiresCoversFixer::class,
])
;
};
14 changes: 1 addition & 13 deletions importmap.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<?php

/**
* Returns the import map for this application.
*
* - "path" is a path inside the asset mapper system. Use the
* "debug:asset-map" command to see the full list of paths.
*
* - "preload" set to true for any modules that are loaded on the initial
* page load to help the browser download them earlier.
*
* The "importmap:require" command can be used to add new entries to this file.
*
* This file has been auto-generated by the importmap commands.
*/
declare(strict_types=1);
return [
'app' => [
'path' => 'app.js',
Expand Down
13 changes: 5 additions & 8 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,20 @@
$rectorConfig->sets([
SetList::DEAD_CODE,
LevelSetList::UP_TO_PHP_82,
SymfonyLevelSetList::UP_TO_SYMFONY_62,
SymfonyLevelSetList::UP_TO_SYMFONY_63,
SymfonySetList::SYMFONY_CODE_QUALITY,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
DoctrineSetList::DOCTRINE_ORM_214,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
PHPUnitLevelSetList::UP_TO_PHPUNIT_100,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::PHPUNIT_EXCEPTION,
PHPUnitSetList::REMOVE_MOCKS,
PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
]);
$rectorConfig->services()
->remove(RemoveExtraParametersRector::class);
$rectorConfig->phpVersion(PhpVersion::PHP_82);
$rectorConfig->paths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests']);
$rectorConfig->skip([__DIR__ . '/config/bundles.php']);
$rectorConfig->skip([__DIR__ . '/config/bundles.php', RemoveExtraParametersRector::class]);
$rectorConfig->parallel();
$rectorConfig->importNames();
$rectorConfig->importShortClasses();
Expand Down
6 changes: 3 additions & 3 deletions src/Command/Init/InitCitiesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
use App\Entity\City;
use App\Repository\CityRepository;
use App\Repository\DepartmentRepository;
use function count;
use function is_string;
use const JSON_THROW_ON_ERROR;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use function count;
use function is_string;
use const JSON_THROW_ON_ERROR;

#[AsCommand(name: 'app:init:cities', description: 'Initialisation des villes',)]
final class InitCitiesCommand extends Command
Expand Down
6 changes: 3 additions & 3 deletions src/Command/Init/InitDeparmentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
use App\Entity\Department;
use App\Repository\DepartmentRepository;
use App\Repository\RegionRepository;
use function count;
use function is_string;
use const JSON_THROW_ON_ERROR;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use function count;
use function is_string;
use const JSON_THROW_ON_ERROR;

#[AsCommand(name: 'app:init:departments', description: 'Initialisation des départements',)]
final class InitDeparmentsCommand extends Command
Expand Down
6 changes: 3 additions & 3 deletions src/Command/Init/InitRegionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

use App\Entity\Region;
use App\Repository\RegionRepository;
use function count;
use function is_string;
use const JSON_THROW_ON_ERROR;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use function count;
use function is_string;
use const JSON_THROW_ON_ERROR;

#[AsCommand(name: 'app:init:regions', description: 'Initialisation des régions',)]
final class InitRegionsCommand extends Command
Expand Down
10 changes: 4 additions & 6 deletions src/Command/Init/InitUsersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

use App\Entity\User;
use App\Repository\UserRepository;
use function count;
use function is_string;
use const JSON_THROW_ON_ERROR;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
Expand All @@ -17,6 +14,9 @@
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
use Symfony\Component\Uid\Ulid;
use function count;
use function is_string;
use const JSON_THROW_ON_ERROR;

#[AsCommand(name: 'app:init:users', description: 'User initialization')]
final class InitUsersCommand extends Command
Expand All @@ -35,9 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$hasher = $this->hasherFactory->getPasswordHasher(User::class);

$data = file_get_contents($this->projectDirectory . '/data/users.json');
is_string($data) || throw new RuntimeException(
'Unable to find user data.'
);
is_string($data) || throw new RuntimeException('Unable to find user data.');
/** @var array<array{username: string, email: string, password: string, name: string, roles: array<string>}> $users */
$users = json_decode($data, true, 512, JSON_THROW_ON_ERROR);

Expand Down
2 changes: 1 addition & 1 deletion src/Command/User/DemoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace App\Command\User;

use App\Repository\UserRepository;
use function is_array;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use function is_array;

#[AsCommand('app:user:demote')]
final class DemoteUserCommand extends Command
Expand Down
2 changes: 1 addition & 1 deletion src/Command/User/PromoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace App\Command\User;

use App\Repository\UserRepository;
use function is_array;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use function is_array;

#[AsCommand('app:user:promote')]
final class PromoteUserCommand extends Command
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

final class Kernel extends BaseKernel
class Kernel extends BaseKernel
{
use MicroKernelTrait;
}
46 changes: 23 additions & 23 deletions src/Repository/DepartmentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,28 @@ public function remove(Department $entity, bool $flush = false): void
}
}

// /**
// * @return Department[] Returns an array of Department objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('d')
// ->andWhere('d.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('d.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// /**
// * @return Department[] Returns an array of Department objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('d')
// ->andWhere('d.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('d.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }

// public function findOneBySomeField($value): ?Department
// {
// return $this->createQueryBuilder('d')
// ->andWhere('d.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
// public function findOneBySomeField($value): ?Department
// {
// return $this->createQueryBuilder('d')
// ->andWhere('d.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}
46 changes: 23 additions & 23 deletions src/Repository/MeasureRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ public function remove(Measure $entity, bool $flush = false): void
}
}

// /**
// * @return Measure[] Returns an array of Measure objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// /**
// * @return Measure[] Returns an array of Measure objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }

// public function findOneBySomeField($value): ?Measure
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
// public function findOneBySomeField($value): ?Measure
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}
46 changes: 23 additions & 23 deletions src/Repository/RegionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,28 @@ public function flush(): void
->clear();
}

// /**
// * @return Region[] Returns an array of Region objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('r.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// /**
// * @return Region[] Returns an array of Region objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('r.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }

// public function findOneBySomeField($value): ?Region
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
// public function findOneBySomeField($value): ?Region
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}
4 changes: 1 addition & 3 deletions src/Security/UserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
return $user;
}

/**
* {@inheritdoc}
*/

public function refreshUser(UserInterface $user): UserInterface
{
if (! $this->supportsClass($user::class)) {
Expand Down
4 changes: 3 additions & 1 deletion templates/components/search_cities.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
</ul>
</div>
{% else %}
<div>No city matches "{{ query }}"</div>
{% if not query == '' %}
<div>No city matches "{{ query }}"</div>
{% endif %}
{% endif %}
</div>
11 changes: 6 additions & 5 deletions templates/dashboard/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
{% block title %}Community records{% endblock %}

{% block content %}
<section class="bg-white border-b py-8">
<div class="container mx-auto flex flex-wrap p-4 pt-4 pb-12">
<section class="bg-white border-b py-8 my-6">
<div class="container mx-auto flex flex-wrap p-4">
<h2 class="w-full my-2 text-5xl font-bold leading-tight text-center text-gray-800">
Choose a city
</h2>
<div class="w-full mb-4">
<div class="h-1 mx-auto gradient w-64 opacity-25 my-0 py-0 rounded-t"></div>
</div>
<div class="text-gray-800 w-fullp-6 flex flex-col flex-grow flex-shrink">
<p class="text-gray-800 text-base px-6 mb-5">
{{ component('search_cities') }}
</p>
<p class="text-gray-800 text-base px-6 mb-5">
{{ component('search_cities') }}
</p>
</div>
</div>
</section>
{% endblock %}
Loading

0 comments on commit 7a1d3b0

Please sign in to comment.