diff --git a/rector.php b/rector.php index f6381f1eb..5065b4484 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,7 @@ use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonySetList; +use Rector\Symfony\Set\TwigSetList; return RectorConfig::configure() ->withPaths([ @@ -26,5 +27,6 @@ SymfonySetList::SYMFONY_44, SymfonySetList::SYMFONY_CODE_QUALITY, SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION, + TwigSetList::TWIG_UNDERSCORE_TO_NAMESPACE ]) ; diff --git a/sources/Afup/Utils/Mail.php b/sources/Afup/Utils/Mail.php index 5ef49f82f..9f483166c 100644 --- a/sources/Afup/Utils/Mail.php +++ b/sources/Afup/Utils/Mail.php @@ -7,8 +7,8 @@ use AppBundle\Email\Mailer\Adapter\PhpMailerAdapter; use AppBundle\Email\Mailer\Mailer; use Psr\Log\NullLogger; +use Twig\Environment; use Twig\Loader\FilesystemLoader; -use Twig_Environment; class Mail { @@ -20,7 +20,7 @@ public static function createMailer(): Mailer return new Mailer( new NullLogger(), - new Twig_Environment(new FilesystemLoader(self::PROJECT_DIR . '/app/Resources/views/')), + new Environment(new FilesystemLoader(self::PROJECT_DIR . '/app/Resources/views/')), PhpMailerAdapter::createFromConfiguration($configuration), $configuration ); diff --git a/sources/AppBundle/Controller/Event/CFP/EditAction.php b/sources/AppBundle/Controller/Event/CFP/EditAction.php index c5fe90024..6af7e0037 100644 --- a/sources/AppBundle/Controller/Event/CFP/EditAction.php +++ b/sources/AppBundle/Controller/Event/CFP/EditAction.php @@ -29,12 +29,12 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Translation\TranslatorInterface; -use Twig_Environment; +use Twig\Environment; class EditAction { private UrlGeneratorInterface $urlGenerator; - private \Twig_Environment $twig; + private Environment $twig; private SpeakerFactory $speakerFactory; private FormFactoryInterface $formFactory; private TranslatorInterface $translator; @@ -52,7 +52,7 @@ class EditAction public function __construct( EventActionHelper $eventActionHelper, UrlGeneratorInterface $urlGenerator, - Twig_Environment $twig, + Environment $twig, FormFactoryInterface $formFactory, TalkRepository $talkRepository, TalkInvitationRepository $talkInvitationRepository, diff --git a/sources/AppBundle/Controller/Event/CFP/IndexAction.php b/sources/AppBundle/Controller/Event/CFP/IndexAction.php index f8b16d25b..cc5a4ef78 100644 --- a/sources/AppBundle/Controller/Event/CFP/IndexAction.php +++ b/sources/AppBundle/Controller/Event/CFP/IndexAction.php @@ -17,14 +17,14 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Twig_Environment; +use Twig\Environment; class IndexAction { const MAX_EVENTS_HISTORY = 50; private TalkRepository $talkRepository; private UrlGeneratorInterface $urlGenerator; - private \Twig_Environment $twig; + private Environment $twig; private SpeakerFactory $speakerFactory; private PhotoStorage $photoStorage; private SidebarRenderer $sidebarRenderer; @@ -36,7 +36,7 @@ public function __construct( EventRepository $eventRepository, TalkRepository $talkRepository, UrlGeneratorInterface $urlGenerator, - Twig_Environment $twig, + Environment $twig, SpeakerFactory $speakerFactory, PhotoStorage $photoStorage, SidebarRenderer $sidebarRenderer diff --git a/sources/AppBundle/Controller/Event/CFP/ProposeAction.php b/sources/AppBundle/Controller/Event/CFP/ProposeAction.php index 5ff61f2a4..c63b1ad4f 100644 --- a/sources/AppBundle/Controller/Event/CFP/ProposeAction.php +++ b/sources/AppBundle/Controller/Event/CFP/ProposeAction.php @@ -17,12 +17,12 @@ use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Translation\TranslatorInterface; -use Twig_Environment; +use Twig\Environment; class ProposeAction { private UrlGeneratorInterface $urlGenerator; - private \Twig_Environment $twig; + private Environment $twig; private SpeakerFactory $speakerFactory; private FormFactoryInterface $formFactory; private TranslatorInterface $translator; @@ -33,7 +33,7 @@ class ProposeAction public function __construct( UrlGeneratorInterface $urlGenerator, - Twig_Environment $twig, + Environment $twig, FormFactoryInterface $formFactory, TalkFormHandler $talkFormHandler, SpeakerFactory $speakerFactory, diff --git a/sources/AppBundle/Controller/Event/CFP/SidebarRenderer.php b/sources/AppBundle/Controller/Event/CFP/SidebarRenderer.php index 588aabfd6..667716544 100644 --- a/sources/AppBundle/Controller/Event/CFP/SidebarRenderer.php +++ b/sources/AppBundle/Controller/Event/CFP/SidebarRenderer.php @@ -8,18 +8,18 @@ use AppBundle\Event\Model\Event; use AppBundle\Event\Model\Repository\TalkRepository; use DateTime; -use Twig_Environment; +use Twig\Environment; class SidebarRenderer { private TalkRepository $talkRepository; private SpeakerFactory $speakerFactory; - private \Twig_Environment $twig; + private Environment $twig; public function __construct( TalkRepository $talkRepository, SpeakerFactory $speakerFactory, - Twig_Environment $twig + Environment $twig ) { $this->talkRepository = $talkRepository; $this->speakerFactory = $speakerFactory; diff --git a/sources/AppBundle/Controller/Event/CFP/SpeakerAction.php b/sources/AppBundle/Controller/Event/CFP/SpeakerAction.php index 8dfb44080..c1cca0b0c 100644 --- a/sources/AppBundle/Controller/Event/CFP/SpeakerAction.php +++ b/sources/AppBundle/Controller/Event/CFP/SpeakerAction.php @@ -19,12 +19,12 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Translation\TranslatorInterface; -use Twig_Environment; +use Twig\Environment; class SpeakerAction { private UrlGeneratorInterface $urlGenerator; - private \Twig_Environment $twig; + private Environment $twig; private SpeakerFactory $speakerFactory; private PhotoStorage $photoStorage; private SpeakerRepository $speakerRepository; @@ -38,7 +38,7 @@ class SpeakerAction public function __construct( EventActionHelper $eventActionHelper, UrlGeneratorInterface $urlGenerator, - Twig_Environment $twig, + Environment $twig, FormFactoryInterface $formFactory, SpeakerFactory $speakerFactory, SpeakerRepository $speakerRepository, diff --git a/sources/AppBundle/Controller/Website/MemberController.php b/sources/AppBundle/Controller/Website/MemberController.php index 0e060c946..2983764eb 100644 --- a/sources/AppBundle/Controller/Website/MemberController.php +++ b/sources/AppBundle/Controller/Website/MemberController.php @@ -61,7 +61,7 @@ public function index(): Response if ($hasGeneralMeetingPlanned && null !== $latestDate - && ($latestDate->format('Y-m-d') == (new \DateTime('-1 day'))->format('Y-m-d')) + && ($latestDate->format('Y-m-d') === (new \DateTime('-1 day'))->format('Y-m-d')) && count($generalMeetingQuestionRepository->loadByDate($latestDate)) > 0 ) { $displayLinkToGeneralMeetingVote = true; diff --git a/sources/AppBundle/Email/Mailer/Mailer.php b/sources/AppBundle/Email/Mailer/Mailer.php index 9063ced55..28e12e154 100644 --- a/sources/AppBundle/Email/Mailer/Mailer.php +++ b/sources/AppBundle/Email/Mailer/Mailer.php @@ -7,7 +7,7 @@ use Afup\Site\Utils\Configuration; use AppBundle\Email\Mailer\Adapter\MailerAdapter; use Psr\Log\LoggerInterface; -use Twig_Environment; +use Twig\Environment; /** * Send emails @@ -15,7 +15,7 @@ class Mailer { private LoggerInterface $logger; - private \Twig_Environment $twig; + private Environment $twig; private MailerAdapter $adapter; /** @var string|null */ private $forcedRecipient; @@ -24,7 +24,7 @@ class Mailer public function __construct( LoggerInterface $logger, - Twig_Environment $twig, + Environment $twig, MailerAdapter $adapter, Configuration $configuration ) { diff --git a/sources/AppBundle/Offices/OfficeFinder.php b/sources/AppBundle/Offices/OfficeFinder.php index 6119d915d..713420e8d 100644 --- a/sources/AppBundle/Offices/OfficeFinder.php +++ b/sources/AppBundle/Offices/OfficeFinder.php @@ -148,10 +148,10 @@ protected function locateNearestLocalOffice(Coordinates $coordinates): array private function haversineGreatCircleDistance(float $latitudeFrom, float $longitudeFrom, float $latitudeTo, float $longitudeTo, int $earthRadius = 6371000): float { // convert from degrees to radians - $latFrom = deg2rad((float) $latitudeFrom); - $lonFrom = deg2rad((float) $longitudeFrom); - $latTo = deg2rad((float) $latitudeTo); - $lonTo = deg2rad((float) $longitudeTo); + $latFrom = deg2rad($latitudeFrom); + $lonFrom = deg2rad($longitudeFrom); + $latTo = deg2rad($latitudeTo); + $lonTo = deg2rad($longitudeTo); $latDelta = $latTo - $latFrom; $lonDelta = $lonTo - $lonFrom; diff --git a/sources/AppBundle/Twig/AssetsExtension.php b/sources/AppBundle/Twig/AssetsExtension.php index 08d76146d..56cacae61 100644 --- a/sources/AppBundle/Twig/AssetsExtension.php +++ b/sources/AppBundle/Twig/AssetsExtension.php @@ -5,7 +5,11 @@ namespace AppBundle\Twig; -class AssetsExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; +use Twig\TwigFunction; + +class AssetsExtension extends AbstractExtension implements GlobalsInterface { private $kernelRootDir; @@ -20,7 +24,7 @@ public function __construct($kernelRootDir) public function getFunctions() { return [ - new \Twig_SimpleFunction('asset_md5_start', function (string $url) { + new TwigFunction('asset_md5_start', function (string $url) { $path = $this->kernelRootDir . '/../htdocs/' . $url; return substr(md5_file($path), 0, 8); diff --git a/sources/AppBundle/Twig/OfficesExtension.php b/sources/AppBundle/Twig/OfficesExtension.php index b3e14808f..ed798e538 100644 --- a/sources/AppBundle/Twig/OfficesExtension.php +++ b/sources/AppBundle/Twig/OfficesExtension.php @@ -5,8 +5,10 @@ namespace AppBundle\Twig; use AppBundle\Offices\OfficesCollection; +use Twig\Extension\AbstractExtension; +use Twig\TwigFunction; -class OfficesExtension extends \Twig_Extension +class OfficesExtension extends AbstractExtension { /** * {@inheritdoc} @@ -14,15 +16,15 @@ class OfficesExtension extends \Twig_Extension public function getFunctions() { return [ - new \Twig_SimpleFunction('office_name', function ($code) { + new TwigFunction('office_name', function ($code) { $collection = new OfficesCollection(); return $collection->findByCode($code)['label']; }), - new \Twig_SimpleFunction('office_logo', function ($code) { + new TwigFunction('office_logo', function ($code) { $collection = new OfficesCollection(); return $collection->findByCode($code)['logo_url']; }), - new \Twig_SimpleFunction('office_meetup_urlname', function ($code) { + new TwigFunction('office_meetup_urlname', function ($code) { $collection = new OfficesCollection(); return $collection->findByCode($code)['meetup_urlname']; }),