DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

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

View File

@@ -20,11 +20,8 @@ use function in_array;
class SearchUserApiProvider implements SearchApiInterface
{
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
public function __construct(private UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function getResult(string $key, array $metadata, float $pertinence)

View File

@@ -13,20 +13,16 @@ namespace Chill\MainBundle\Search\Model;
class Result
{
private float $relevance;
/**
* mixed an arbitrary result.
*/
private $result;
/**
* @param $result
*/
public function __construct(float $relevance, $result)
{
$this->relevance = $relevance;
$this->result = $result;
public function __construct(
private float $relevance,
/**
* mixed an arbitrary result.
*/
private $result
) {
}
public function getRelevance(): float

View File

@@ -26,20 +26,8 @@ use function strtr;
class SearchApi
{
private EntityManagerInterface $em;
private PaginatorFactory $paginator;
private iterable $providers;
public function __construct(
EntityManagerInterface $em,
iterable $providers,
PaginatorFactory $paginator
) {
$this->em = $em;
$this->providers = $providers;
$this->paginator = $paginator;
public function __construct(private EntityManagerInterface $em, private iterable $providers, private PaginatorFactory $paginator)
{
}
public function getResults(string $pattern, array $types, array $parameters): Collection

View File

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

View File

@@ -17,13 +17,10 @@ class SearchApiResult
{
private float $pertinence;
private float $relevance;
private $result;
public function __construct(float $relevance)
public function __construct(private float $relevance)
{
$this->relevance = $relevance;
}
/**

View File

@@ -62,13 +62,11 @@ class SearchProvider
* return search services with a specific name, defined in service
* definition.
*
* @param mixed $name
*
* @throws UnknowSearchNameException if not exists
*
* @return SearchInterface
*/
public function getByName($name)
public function getByName(mixed $name)
{
if (isset($this->searchServices[$name])) {
return $this->searchServices[$name];

View File

@@ -13,14 +13,8 @@ namespace Chill\MainBundle\Search\Utils;
class SearchExtractionResult
{
private string $filteredSubject;
private array $found;
public function __construct(string $filteredSubject, array $found)
public function __construct(private string $filteredSubject, private array $found)
{
$this->filteredSubject = $filteredSubject;
$this->found = $found;
}
public function getFilteredSubject(): string