apply rector rules: symfony **UP TO** 44

This commit is contained in:
2023-07-28 01:52:53 +02:00
parent b6a094aeee
commit c20f65eebb
88 changed files with 211 additions and 320 deletions

View File

@@ -66,16 +66,16 @@ class ChillMainBundle extends Bundle
$container->registerForAutoconfiguration(ViewEntityInfoProviderInterface::class)
->addTag('chill_main.entity_info_provider');
$container->addCompilerPass(new SearchableServicesCompilerPass());
$container->addCompilerPass(new ConfigConsistencyCompilerPass());
$container->addCompilerPass(new TimelineCompilerClass());
$container->addCompilerPass(new RoleProvidersCompilerPass());
$container->addCompilerPass(new ExportsCompilerPass());
$container->addCompilerPass(new WidgetsCompilerPass());
$container->addCompilerPass(new NotificationCounterCompilerPass());
$container->addCompilerPass(new MenuCompilerPass());
$container->addCompilerPass(new ACLFlagsCompilerPass());
$container->addCompilerPass(new CRUDControllerCompilerPass());
$container->addCompilerPass(new ShortMessageCompilerPass());
$container->addCompilerPass(new SearchableServicesCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new ConfigConsistencyCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new TimelineCompilerClass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new RoleProvidersCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new ExportsCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new WidgetsCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new NotificationCounterCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new MenuCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new ACLFlagsCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new CRUDControllerCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->addCompilerPass(new ShortMessageCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
}
}

View File

@@ -88,7 +88,7 @@ class LoadAndUpdateLanguagesCommand extends Command
$languages = [];
foreach ($chillAvailableLanguages as $avLang) {
$languages[$avLang] = $languageBundle->getLanguageNames($avLang);
$languages[$avLang] = \Symfony\Component\Intl\Languages::getNames();
}
$languageCodes = array_keys($languages[$chillAvailableLanguages[0]]);
@@ -125,7 +125,7 @@ class LoadAndUpdateLanguagesCommand extends Command
if ($langageDB) {
$em->remove($langageDB);
}
echo 'Code excluded : ' . $code . ' - ' . $languageBundle->getLanguageName($code) . "\n";
echo 'Code excluded : ' . $code . ' - ' . \Symfony\Component\Intl\Languages::getName() . "\n";
}
}

View File

@@ -36,7 +36,7 @@ class LoadCountriesCommand extends Command
$countries = [];
foreach ($languages as $language) {
$countries[$language] = $regionBundle->getCountryNames($language);
$countries[$language] = \Symfony\Component\Intl\Currencies::getNames();
}
$countryEntities = [];

View File

@@ -36,7 +36,7 @@ class AbsenceController extends AbstractController
$em = $this->getDoctrine()->getManager();
$em->flush();
return $this->redirect($this->generateUrl('chill_main_user_absence_index'));
return $this->redirectToRoute('chill_main_user_absence_index');
}
return $this->render('@ChillMain/Menu/absence.html.twig', [
@@ -60,6 +60,6 @@ class AbsenceController extends AbstractController
$em = $this->getDoctrine()->getManager();
$em->flush();
return $this->redirect($this->generateUrl('chill_main_user_absence_index'));
return $this->redirectToRoute('chill_main_user_absence_index');
}
}

View File

@@ -31,12 +31,12 @@ class CenterController extends AbstractController
$form = $this->createCreateForm($center);
$form->handleRequest($request);
if ($form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($center);
$em->flush();
return $this->redirect($this->generateUrl('admin_center'));
return $this->redirectToRoute('admin_center');
}
return $this->render('@ChillMain/Center/new.html.twig', [
@@ -128,10 +128,10 @@ class CenterController extends AbstractController
$editForm = $this->createEditForm($center);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('admin_center_edit', ['id' => $id]));
return $this->redirectToRoute('admin_center_edit', ['id' => $id]);
}
return $this->render('@ChillMain/Center/edit.html.twig', [

View File

@@ -29,7 +29,7 @@ class DefaultController extends AbstractController
public function indexWithoutLocaleAction()
{
return $this->redirect($this->generateUrl('chill_main_homepage'));
return $this->redirectToRoute('chill_main_homepage');
}
public function testAction()

View File

@@ -361,13 +361,11 @@ class ExportController extends AbstractController
$this->session->set('export_step', $data);
//redirect to next step
return $this->redirect(
$this->generateUrl('chill_main_export_new', [
'step' => $this->getNextStep('export', $export),
'alias' => $alias,
'from_saved' => $request->get('from_saved', '')
])
);
return $this->redirectToRoute('chill_main_export_new', [
'step' => $this->getNextStep('export', $export),
'alias' => $alias,
'from_saved' => $request->get('from_saved', '')
]);
}
$this->logger->debug('form export is invalid', [
'location' => __METHOD__, ]);
@@ -413,14 +411,11 @@ class ExportController extends AbstractController
);
//redirect to next step
return $this->redirect($this->generateUrl(
'chill_main_export_new',
[
'alias' => $alias,
'step' => $this->getNextStep('formatter', $export),
'from_saved' => $request->get('from_saved', ''),
]
));
return $this->redirectToRoute('chill_main_export_new', [
'alias' => $alias,
'step' => $this->getNextStep('formatter', $export),
'from_saved' => $request->get('from_saved', ''),
]);
}
}

View File

@@ -114,8 +114,8 @@ class PasswordController extends AbstractController
if (null === $user) {
$this->eventDispatcher->dispatch(
PasswordRecoverEvent::INVALID_TOKEN,
new PasswordRecoverEvent($token, null, $request->getClientIp())
new PasswordRecoverEvent($token, null, $request->getClientIp()),
PasswordRecoverEvent::INVALID_TOKEN
);
throw $this->createNotFoundException(sprintf('User %s not found', $username));
@@ -123,8 +123,8 @@ class PasswordController extends AbstractController
if (true !== $this->tokenManager->verify($hash, $token, $user, $timestamp)) {
$this->eventDispatcher->dispatch(
PasswordRecoverEvent::INVALID_TOKEN,
new PasswordRecoverEvent($token, $user, $request->getClientIp())
new PasswordRecoverEvent($token, $user, $request->getClientIp()),
PasswordRecoverEvent::INVALID_TOKEN
);
return new Response('Invalid token', Response::HTTP_FORBIDDEN);
@@ -214,16 +214,16 @@ class PasswordController extends AbstractController
);
$this->eventDispatcher->dispatch(
PasswordRecoverEvent::ASK_TOKEN_SUCCESS,
new PasswordRecoverEvent(null, $user, $request->getClientIp())
new PasswordRecoverEvent(null, $user, $request->getClientIp()),
PasswordRecoverEvent::ASK_TOKEN_SUCCESS
);
return $this->redirectToRoute('password_request_recover_confirm');
}
} elseif ($form->isSubmitted() && false === $form->isValid()) {
$this->eventDispatcher->dispatch(
PasswordRecoverEvent::ASK_TOKEN_INVALID_FORM,
new PasswordRecoverEvent(null, null, $request->getClientIp())
new PasswordRecoverEvent(null, null, $request->getClientIp()),
PasswordRecoverEvent::ASK_TOKEN_INVALID_FORM
);
}

View File

@@ -83,10 +83,7 @@ final class PermissionsGroupController extends AbstractController
$this->translator->trans('The permissions have been added')
);
return $this->redirect($this->generateUrl(
'admin_permissionsgroup_edit',
['id' => $id]
));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $id]);
}
foreach ($violations as $error) {
@@ -146,10 +143,7 @@ final class PermissionsGroupController extends AbstractController
$this->em->persist($permissionsGroup);
$this->em->flush();
return $this->redirect($this->generateUrl(
'admin_permissionsgroup_edit',
['id' => $permissionsGroup->getId()]
));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $permissionsGroup->getId()]);
}
return $this->render('@ChillMain/PermissionsGroup/new.html.twig', [
@@ -187,10 +181,7 @@ final class PermissionsGroupController extends AbstractController
])
);
return $this->redirect($this->generateUrl(
'admin_permissionsgroup_edit',
['id' => $pgid]
));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $pgid]);
}
$this->em->flush();
@@ -214,10 +205,7 @@ final class PermissionsGroupController extends AbstractController
);
}
return $this->redirect($this->generateUrl(
'admin_permissionsgroup_edit',
['id' => $pgid]
));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $pgid]);
}
/**
@@ -362,7 +350,7 @@ final class PermissionsGroupController extends AbstractController
if ($editForm->isValid()) {
$this->em->flush();
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', ['id' => $id]));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $id]);
}
$deleteRoleScopesForm = [];

View File

@@ -31,12 +31,12 @@ class ScopeController extends AbstractController
$form = $this->createCreateForm($scope);
$form->handleRequest($request);
if ($form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($scope);
$em->flush();
return $this->redirect($this->generateUrl('admin_scope'));
return $this->redirectToRoute('admin_scope');
}
return $this->render('@ChillMain/Scope/new.html.twig', [
@@ -128,10 +128,10 @@ class ScopeController extends AbstractController
$editForm = $this->createEditForm($scope);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('admin_scope_edit', ['id' => $id]));
return $this->redirectToRoute('admin_scope_edit', ['id' => $id]);
}
return $this->render('@ChillMain/Scope/edit.html.twig', [

View File

@@ -74,10 +74,7 @@ class UserController extends CRUDController
$returnPathParams = $request->query->has('returnPath') ?
['returnPath' => $request->query->get('returnPath')] : [];
return $this->redirect($this->generateUrl(
'chill_crud_admin_user_edit',
array_merge(['id' => $uid], $returnPathParams)
));
return $this->redirectToRoute('chill_crud_admin_user_edit', array_merge(['id' => $uid], $returnPathParams));
}
foreach ($this->validator->validate($user) as $error) {
@@ -123,7 +120,7 @@ class UserController extends CRUDController
} catch (RuntimeException $ex) {
$this->addFlash('error', $this->get('translator')->trans($ex->getMessage()));
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', ['id' => $uid]));
return $this->redirectToRoute('chill_crud_admin_user_edit', ['id' => $uid]);
}
$em->flush();
@@ -131,7 +128,7 @@ class UserController extends CRUDController
$this->addFlash('success', $this->get('translator')
->trans('The permissions where removed.'));
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', ['id' => $uid]));
return $this->redirectToRoute('chill_crud_admin_user_edit', ['id' => $uid]);
}
public function edit(Request $request, $id): Response

View File

@@ -48,7 +48,7 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
{
echo "loading languages... \n";
foreach (Intl::getLanguageBundle()->getLanguageNames() as $code => $language) {
foreach (\Symfony\Component\Intl\Languages::getNames() as $code => $language) {
if (
!in_array($code, $this->regionalVersionToInclude, true)
&& !in_array($code, $this->ancientToExclude, true)
@@ -78,7 +78,7 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
$names = [];
foreach ($this->container->getParameter('chill_main.available_languages') as $lang) {
$names[$lang] = Intl::getLanguageBundle()->getLanguageName($languageCode);
$names[$lang] = \Symfony\Component\Intl\Languages::getName();
}
return $names;

View File

@@ -13,7 +13,7 @@ namespace Chill\MainBundle\Form\Event;
use Symfony\Component\Form\FormBuilderInterface;
class CustomizeFormEvent extends \Symfony\Component\EventDispatcher\Event
class CustomizeFormEvent extends \Symfony\Contracts\EventDispatcher\Event
{
final public const NAME = 'chill_main.customize_form';

View File

@@ -29,11 +29,6 @@ class Select2ChoiceType extends AbstractType
);
}
public function getBlockPrefix()
{
return 'select2_choice';
}
public function getParent()
{
return ChoiceType::class;

View File

@@ -27,11 +27,6 @@ class Select2EntityType extends AbstractType
);
}
public function getBlockPrefix()
{
return 'select2_entity';
}
public function getParent()
{
return EntityType::class;

View File

@@ -14,7 +14,7 @@ namespace Chill\MainBundle\Security\PasswordRecover;
use Chill\MainBundle\Entity\User;
use Symfony\Component\EventDispatcher\Event;
class PasswordRecoverEvent extends Event
class PasswordRecoverEvent extends \Symfony\Contracts\EventDispatcher\Event
{
final public const ASK_TOKEN_INVALID_FORM = 'chill_main.ask_token_invalid_form';

View File

@@ -30,7 +30,7 @@ use Symfony\Component\EventDispatcher\Event;
* The keys are read-only: if you try to update the context using array access
* (example, using `$event['context_key'] = $bar;`, an error will be thrown.
*/
class DelegatedBlockRenderingEvent extends Event implements ArrayAccess
class DelegatedBlockRenderingEvent extends \Symfony\Contracts\EventDispatcher\Event implements ArrayAccess
{
/**
* The returned content of the event.

View File

@@ -128,7 +128,7 @@ class WidgetRenderingTwig extends AbstractExtension
// for old rendering events (deprecated)
$event = new DelegatedBlockRenderingEvent($context);
$this->eventDispatcher->dispatch('chill_block.' . $block, $event);
$this->eventDispatcher->dispatch($event, 'chill_block.' . $block);
return $content . ' ' . $event->getContent();
}

View File

@@ -22,7 +22,7 @@ class TestHelper
* create a client authenticated with an user.
*
*
* @return \Symfony\Component\BrowserKit\Client authenticated client
* @return \Symfony\Component\BrowserKit\AbstractBrowser authenticated client
*/
public static function getAuthenticatedClientOptions(
mixed $username = 'center a_social',

View File

@@ -12,7 +12,7 @@ services:
$logger: '@Psr\Log\LoggerInterface'
$em: '@Doctrine\ORM\EntityManagerInterface'
$recoverPasswordHelper: '@Chill\MainBundle\Security\PasswordRecover\RecoverPasswordHelper'
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
tags:
- { name: console.command }

View File

@@ -33,6 +33,10 @@ class Version20150821105642 extends AbstractMigration implements \Symfony\Compon
* @var ContainerInterface
*/
private $container;
public function __construct(\Doctrine\DBAL\Connection $connection, \Psr\Log\LoggerInterface $logger, private \Doctrine\ORM\EntityManager $entityManager)
{
parent::__construct($connection, $logger);
}
public function down(Schema $schema): void
{
@@ -56,7 +60,7 @@ class Version20150821105642 extends AbstractMigration implements \Symfony\Compon
*/
return;
//transform data from groupcenter_permissionsgroup table
$em = $this->container->get('doctrine.orm.entity_manager');
$em = $this->entityManager;
//get all existing associations
$rsm = new ResultSetMapping();