Skip to content

Commit

Permalink
fix regex capturing phone number in html
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Jan 26, 2024
1 parent 5c3988f commit af760dc
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions packages/admin/src/Menu/PageMenuProvider.php
Expand Up @@ -21,13 +21,13 @@ final class PageMenuProvider
#[Required]
public \Pushword\Core\Component\App\AppPool $apps;

#[\Symfony\Contracts\Service\Attribute\Required]
#[Required]
public ManagerRegistry $doctrine;

#[\Symfony\Contracts\Service\Attribute\Required]
#[Required]
public TranslatorInterface $translator;

#[\Symfony\Contracts\Service\Attribute\Required]
#[Required]
public RequestStack $requestStack;

public function __construct(private readonly FactoryInterface $factory)
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/PageAbstractAdmin.php
Expand Up @@ -217,7 +217,7 @@ protected function configureDatagridFilters(DatagridMapper $filter): void

$filter
->add('h1', CallbackFilter::class, [
'callback' => fn (\Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery $queryBuilder, string $alias, string $field, \Sonata\AdminBundle\Filter\Model\FilterData $filterData): ?bool => $this->getSearchFilterForTitle($queryBuilder, $alias, $field, $filterData),
'callback' => fn (ProxyQuery $queryBuilder, string $alias, string $field, FilterData $filterData): ?bool => $this->getSearchFilterForTitle($queryBuilder, $alias, $field, $filterData),
'label' => 'admin.page.h1.label',
]);

Expand Down
2 changes: 1 addition & 1 deletion packages/conversation/src/Entity/Message.php
Expand Up @@ -152,7 +152,7 @@ public function setAuthorIp(?int $authorIp): self

public function setAuthorIpRaw(string $authorIp): self
{
return $this->setAuthorIp((int) ip2long(IPUtils::anonymize($authorIp)));
return $this->setAuthorIp((int) ip2long(IpUtils::anonymize($authorIp)));
}

public function getAuthorIpRaw(): bool|string
Expand Down
4 changes: 2 additions & 2 deletions packages/conversation/src/Form/FormTrait.php
Expand Up @@ -39,9 +39,9 @@ trait FormTrait
/** @var string */
protected $successMessage = 'conversation.send.success';

protected \Symfony\Component\HttpFoundation\Request $request;
protected Request $request;

protected \Doctrine\Bundle\DoctrineBundle\Registry $doctrine;
protected Registry $doctrine;

protected Twig $twig;

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Component/App/AppPool.php
Expand Up @@ -15,7 +15,7 @@ final class AppPool

/**
* Why there ? Because often, need to check current page don't override App Config. */
private ?\Pushword\Core\Entity\PageInterface $currentPage = null;
private ?PageInterface $currentPage = null;

/** @param array<string, array<string, mixed>> $rawApps */
public function __construct(array $rawApps, Twig $twig, ParameterBagInterface $parameterBag)
Expand Down
Expand Up @@ -19,7 +19,7 @@ public function apply(mixed $propertyValue): string

private function convertPhoneNumber(string $body): string
{
$rgx = '/ (?:(?:\+|00)33|0)\s*[1-9](?:[\s.-]*\d{2}){4}(?P<after> |\.<\/|\. |$)/iU';
$rgx = '/ (?:(?:\+|00)33|0)(\s|\xC2\xA0|&nbsp;)*[1-9](?:([\s.-\xC2\xA0]|&nbsp;)*\d{2}){4}(?P<after>( |&nbsp;)|\.<\/|\. |$)/iU';
\Safe\preg_match_all($rgx, $body, $matches);

if (! isset($matches[0])) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/EventListener/MediaListener.php
Expand Up @@ -35,7 +35,7 @@ final class MediaListener
public function __construct(
private readonly string $projectDir,
private readonly EntityManagerInterface $em,
private readonly FileSystem $filesystem,
private readonly Filesystem $filesystem,
private readonly ImageManager $imageManager,
private readonly RequestStack $requestStack,
private readonly RouterInterface $router,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Service/ImageManager.php
Expand Up @@ -20,7 +20,7 @@ final class ImageManager

private ?ImageInterface $lastThumb = null;

private readonly FileSystem $fileSystem;
private readonly Filesystem $fileSystem;

/**
* @param array<string, array<string, mixed>> $filterSets
Expand All @@ -32,7 +32,7 @@ public function __construct(
private readonly string $publicMediaDir,
private readonly string $mediaDir
) {
$this->fileSystem = new FileSystem();
$this->fileSystem = new Filesystem();
$this->optimizer = OptimizerChainFactory::create(); // t o d o make optimizer bin path configurable
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Service/TailwindGenerator.php
Expand Up @@ -30,7 +30,7 @@ public function run(PageInterface $page): void
return;
}

$fs = new FileSystem();
$fs = new Filesystem();
$fs->dumpFile(
$this->projectDir.'/var/TailwindGeneratorCache/'.$page->getId(),
serialize($page)
Expand Down
2 changes: 1 addition & 1 deletion packages/flat/src/Importer/PageImporter.php
Expand Up @@ -28,7 +28,7 @@ class PageImporter extends AbstractImporter
*/
protected array $toAddAtTheEnd = [];

protected ?\Pushword\Flat\FlatFileContentDirFinder $contentDirFinder = null;
protected ?FlatFileContentDirFinder $contentDirFinder = null;

/**
* @var class-string<MediaInterface>
Expand Down
6 changes: 3 additions & 3 deletions packages/flat/tests/FlatFileImporterTest.php
Expand Up @@ -81,9 +81,9 @@ private function prepare()
self::bootKernel();
$newName = 'logo-test'.uniqid().rand().'.png';

(new FileSystem())->copy(__DIR__.'/content/test-content.md', $this->getContentDir().'/test-content.md');
(new FileSystem())->copy(__DIR__.'/content/media/logo-test.png', $this->getContentDir().'/media/logo-test.png');
(new FileSystem())->copy(__DIR__.'/content/media/logo-test.png', $this->getContentDir().'/media/'.$newName);
(new Filesystem())->copy(__DIR__.'/content/test-content.md', $this->getContentDir().'/test-content.md');
(new Filesystem())->copy(__DIR__.'/content/media/logo-test.png', $this->getContentDir().'/media/logo-test.png');
(new Filesystem())->copy(__DIR__.'/content/media/logo-test.png', $this->getContentDir().'/media/'.$newName);

return $newName;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/page-scanner/src/Scanner/ParentPageScanner.php
Expand Up @@ -14,7 +14,7 @@ protected function run(): void
$this->checkParentPageHost($this->page);
}

private function checkParentPageHost(Pageinterface $pageinterface): void
private function checkParentPageHost(PageInterface $pageinterface): void
{
$parent = $pageinterface->getParentPage();
if (! $parent instanceof PageInterface) {
Expand Down
2 changes: 1 addition & 1 deletion packages/template-editor/src/ElementAdmin.php
Expand Up @@ -24,7 +24,7 @@ final class ElementAdmin extends AbstractController
{
private KernelInterface $kernel;

private twig $twig;
private Twig $twig;

/** @param string[] $canBeEditedList */
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion packages/version/src/VersionController.php
Expand Up @@ -52,7 +52,7 @@ public function setTranslator(TranslatorInterface $translator): void
* @psalm-suppress PossiblyInvalidArgument
* @psalm-suppress InvalidPropertyAssignmentValue
*/
#[\Symfony\Contracts\Service\Attribute\Required]
#[Required]
public function setParams(ParameterBagInterface $parameterBag): void
{
$this->pageClass = $parameterBag->get('pw.entity_page'); // @phpstan-ignore-line
Expand Down

0 comments on commit af760dc

Please sign in to comment.