apply rector rules: php up to php82

This commit is contained in:
2023-07-19 23:16:01 +02:00
parent 7b637d1287
commit 023a29cb78
744 changed files with 1369 additions and 1381 deletions

View File

@@ -65,12 +65,12 @@ abstract class AbstractSearch implements SearchInterface
foreach ($supportedTerms as $term) {
if (array_key_exists($term, $terms) && '_default' !== $term) {
$recomposed .= ' ' . $term . ':';
$containsSpace = str_contains($terms[$term], ' ');
$containsSpace = str_contains((string) $terms[$term], ' ');
if ($containsSpace) {
$recomposed .= '"';
}
$recomposed .= (mb_stristr(' ', $terms[$term]) === false) ? $terms[$term] : '(' . $terms[$term] . ')';
$recomposed .= (mb_stristr(' ', (string) $terms[$term]) === false) ? $terms[$term] : '(' . $terms[$term] . ')';
if ($containsSpace) {
$recomposed .= '"';

View File

@@ -20,7 +20,7 @@ use function in_array;
class SearchUserApiProvider implements SearchApiInterface
{
public function __construct(private UserRepository $userRepository)
public function __construct(private readonly UserRepository $userRepository)
{
}

View File

@@ -17,7 +17,7 @@ class Result
* @param $result
*/
public function __construct(
private float $relevance,
private readonly float $relevance,
/**
* mixed an arbitrary result.
*/

View File

@@ -26,7 +26,7 @@ use function strtr;
class SearchApi
{
public function __construct(private EntityManagerInterface $em, private iterable $providers, private PaginatorFactory $paginator)
public function __construct(private readonly EntityManagerInterface $em, private readonly iterable $providers, private readonly PaginatorFactory $paginator)
{
}

View File

@@ -18,11 +18,11 @@ use function implode;
class SearchApiNoQueryException extends RuntimeException
{
private string $pattern;
private readonly string $pattern;
private array $types;
private readonly array $types;
public function __construct(string $pattern = '', array $types = [], private array $parameters = [], $code = 0, ?Throwable $previous = null)
public function __construct(string $pattern = '', array $types = [], private readonly array $parameters = [], $code = 0, ?Throwable $previous = null)
{
$typesStr = implode(', ', $types);
$message = "No query for this search: pattern : {$pattern}, types: {$typesStr}";

View File

@@ -15,11 +15,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
class SearchApiResult
{
private float $pertinence;
private mixed $result;
private $result;
public function __construct(private float $relevance)
public function __construct(private readonly float $relevance)
{
}
@@ -39,7 +37,7 @@ class SearchApiResult
return $this->result;
}
public function setResult($result): self
public function setResult(mixed $result): self
{
$this->result = $result;

View File

@@ -252,17 +252,17 @@ class SearchProvider
{
$terms = [];
$matches = [];
preg_match_all('/([a-z\-]+):(([^"][\S\-]+)|"[^"]*")/', $subject, $matches);
preg_match_all('/([a-z\-]+):(([^"][\S\-]+)|"[^"]*")/', (string) $subject, $matches);
foreach ($matches[2] as $key => $match) {
//remove from search pattern
$this->mustBeExtracted[] = $matches[0][$key];
//strip parenthesis
if (
mb_substr($match, 0, 1) === '"'
&& mb_substr($match, mb_strlen($match) - 1) === '"'
mb_substr((string) $match, 0, 1) === '"'
&& mb_substr((string) $match, mb_strlen((string) $match) - 1) === '"'
) {
$match = trim(mb_substr($match, 1, mb_strlen($match) - 2));
$match = trim(mb_substr((string) $match, 1, mb_strlen((string) $match) - 2));
}
$terms[$matches[1][$key]] = $match;
}

View File

@@ -26,7 +26,7 @@ class ExtractPhonenumberFromPattern
{
private const PATTERN = '([\\+]{0,1}[0-9\\ ]{5,})';
private string $defaultCarrierCode;
private readonly string $defaultCarrierCode;
public function __construct(ParameterBagInterface $parameterBag)
{

View File

@@ -13,7 +13,7 @@ namespace Chill\MainBundle\Search\Utils;
class SearchExtractionResult
{
public function __construct(private string $filteredSubject, private array $found)
public function __construct(private readonly string $filteredSubject, private readonly array $found)
{
}