diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6aa8f46..00a823a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -16,6 +16,8 @@ jobs: - 7.2 - 7.3 - 7.4 + - 8.0 + - 8.1 steps: - name: Checkout @@ -33,11 +35,6 @@ jobs: with: composer-options: --prefer-dist - - name: Setup PCOV - run: | - composer require pcov/clobber - vendor/bin/pcov clobber - - name: Run Tests run: composer tests diff --git a/composer.json b/composer.json index eaecfbe..303c363 100644 --- a/composer.json +++ b/composer.json @@ -30,14 +30,13 @@ } ], "require": { - "php": "~7.1", + "php": ">=7.1.3", "lstrojny/functional-php": "~0.1|~1.0", "internations/solr-utils": "~0.8" }, "require-dev": { - "internations/testing-component": "dev-master", - "internations/kodierungsregelwerksammlung": "^0.35.0", - "phpunit/phpunit": "~6" + "internations/kodierungsregelwerksammlung": "~0.35", + "phpunit/phpunit": "~7 || ~8 || ~9" }, "autoload": { "psr-0": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3daf7f2..c40d338 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,9 +3,7 @@ convertErrorsToExceptions="true" convertWarningsToExceptions="true" convertNoticesToExceptions="true" - mapTestClassNameToCoveredClassName="true" bootstrap="vendor/autoload.php" - strict="true" verbose="true" colors="true" timeoutForLargeTests="100"> @@ -16,21 +14,6 @@ - - - - - - - - - vendor/ - tests/ - - - diff --git a/src/InterNations/Component/Solr/Expression/BooleanExpression.php b/src/InterNations/Component/Solr/Expression/BooleanExpression.php index ddae845..6291f43 100644 --- a/src/InterNations/Component/Solr/Expression/BooleanExpression.php +++ b/src/InterNations/Component/Solr/Expression/BooleanExpression.php @@ -33,8 +33,9 @@ class BooleanExpression extends Expression * * @param ExpressionInterface|string $expr * @param bool $useNotNotation use the NOT notation: (*:* NOT ), e.g. (*:* NOT fieldName:*) + * @no-named-arguments */ - public function __construct(string $operator, $expr, bool$useNotNotation = false) + public function __construct(string $operator, $expr, bool $useNotNotation = false) { $this->operator = $operator; $this->useNotNotation = $useNotNotation; diff --git a/src/InterNations/Component/Solr/Expression/BoostExpression.php b/src/InterNations/Component/Solr/Expression/BoostExpression.php index 189d871..3a5c39d 100644 --- a/src/InterNations/Component/Solr/Expression/BoostExpression.php +++ b/src/InterNations/Component/Solr/Expression/BoostExpression.php @@ -20,10 +20,11 @@ class BoostExpression extends Expression /** * @param ExpressionInterface|string|null $expr + * @no-named-arguments */ public function __construct(float $boost, $expr) { - $this->boost = is_int($boost) ? $boost : (float) $boost; + $this->boost = $boost; parent::__construct($expr); } diff --git a/src/InterNations/Component/Solr/Expression/CompositeExpression.php b/src/InterNations/Component/Solr/Expression/CompositeExpression.php index c96e071..cb15ab1 100644 --- a/src/InterNations/Component/Solr/Expression/CompositeExpression.php +++ b/src/InterNations/Component/Solr/Expression/CompositeExpression.php @@ -19,17 +19,16 @@ class CompositeExpression extends Expression * * @var array */ - private $expressions = []; + private $expressions; - /** - * @var string - */ + /** @var string */ private $type; /** * Create new group of expression * * @param mixed[] $expressions + * @no-named-arguments */ public function __construct(array $expressions, ?string $type = self::TYPE_SPACE) { @@ -62,6 +61,7 @@ public function __toString(): string return implode($glue, array_filter($parts)); } + /** @no-named-arguments */ public static function isValidType(?string $type): bool { return $type === static::TYPE_OR diff --git a/src/InterNations/Component/Solr/Expression/DateTimeExpression.php b/src/InterNations/Component/Solr/Expression/DateTimeExpression.php index 9c04de5..500b8da 100644 --- a/src/InterNations/Component/Solr/Expression/DateTimeExpression.php +++ b/src/InterNations/Component/Solr/Expression/DateTimeExpression.php @@ -10,28 +10,21 @@ class DateTimeExpression extends Expression public const FORMAT_START_OF_DAY = 'Y-m-d\T00:00:00\Z'; public const FORMAT_END_OF_DAY = 'Y-m-d\T23:59:59\Z'; - /** - * @var DateTimeZone - */ + /** @var DateTimeZone */ private static $utcTimezone; - /** - * @var DateTime - */ + /** @var DateTime */ private $date; - /** - * @var string|DateTimeZone - */ + /** @var string|DateTimeZone */ private $timezone; - /** - * @var string - */ + /** @var string */ private $format; /** * @param string|DateTimeZone $timezone + * @no-named-arguments */ public function __construct(DateTime $date, ?string $format = null, $timezone = 'UTC') { diff --git a/src/InterNations/Component/Solr/Expression/Exception/InvalidArgumentException.php b/src/InterNations/Component/Solr/Expression/Exception/InvalidArgumentException.php index 755685f..79872ea 100644 --- a/src/InterNations/Component/Solr/Expression/Exception/InvalidArgumentException.php +++ b/src/InterNations/Component/Solr/Expression/Exception/InvalidArgumentException.php @@ -8,6 +8,7 @@ class InvalidArgumentException extends BaseInvalidArgumentException implements E /** * @param string|array $expectation * @param mixed $actual + * @no-named-arguments */ public static function invalidArgument(int $position, string $name, $expectation, $actual): self { @@ -24,7 +25,10 @@ public static function invalidArgument(int $position, string $name, $expectation ); } - /** @param string[] $expectations */ + /** + * @param string[] $expectations + * @no-named-arguments + */ private static function formatExpectations(array $expectations): string { $last = array_pop($expectations); @@ -36,7 +40,10 @@ private static function formatExpectations(array $expectations): string return implode(', ', $expectations) . ' or ' . $last; } - /** @param mixed $actual */ + /** + * @param mixed $actual + * @no-named-arguments + */ private static function getType($actual): string { return is_object($actual) ? get_class($actual) : gettype($actual); diff --git a/src/InterNations/Component/Solr/Expression/Expression.php b/src/InterNations/Component/Solr/Expression/Expression.php index a10bda9..f1cc121 100644 --- a/src/InterNations/Component/Solr/Expression/Expression.php +++ b/src/InterNations/Component/Solr/Expression/Expression.php @@ -14,23 +14,25 @@ class Expression implements ExpressionInterface /** * Expression object or string * - * @var Expression|string + * @var ExpressionInterface|string */ protected $expr; /** * Create new expression object * - * @param Expression|string $expr + * @param ExpressionInterface|string $expr + * @no-named-arguments */ public function __construct($expr) { $this->expr = $expr; } + /** @no-named-arguments */ public function isEqual(string $expr): bool { - return (string) $expr === (string) $this; + return $expr === (string) $this; } public function __toString(): string diff --git a/src/InterNations/Component/Solr/Expression/ExpressionBuilder.php b/src/InterNations/Component/Solr/Expression/ExpressionBuilder.php index 44e7a21..66f8efe 100644 --- a/src/InterNations/Component/Solr/Expression/ExpressionBuilder.php +++ b/src/InterNations/Component/Solr/Expression/ExpressionBuilder.php @@ -9,9 +9,7 @@ class ExpressionBuilder { - /** - * @var string|DateTimeZone - */ + /** @var string|DateTimeZone */ private $defaultTimezone = 'UTC'; /** @@ -22,6 +20,7 @@ class ExpressionBuilder * * @param DateTimeZone|string $timezone * @throws InvalidArgumentException + * @no-named-arguments */ public function setDefaultTimezone($timezone): void { @@ -36,6 +35,7 @@ public function setDefaultTimezone($timezone): void * Create term expression: * * @param ExpressionInterface|string|null $expr + * @no-named-arguments */ public function eq($expr): ?ExpressionInterface { @@ -56,6 +56,7 @@ public function eq($expr): ?ExpressionInterface * * @param ExpressionInterface|string $field * @param ExpressionInterface|string|array $expr + * @no-named-arguments */ public function field($field, $expr): ?ExpressionInterface { @@ -70,6 +71,7 @@ public function field($field, $expr): ?ExpressionInterface /** * Create phrase expression: "term1 term2" + * @no-named-arguments */ public function phrase(?string $str): ?ExpressionInterface { @@ -84,6 +86,7 @@ public function phrase(?string $str): ?ExpressionInterface * Create boost expression: ^ * * @param ExpressionInterface|string|null $expr + * @no-named-arguments */ public function boost($expr, ?float $boost): ?ExpressionInterface { @@ -99,6 +102,7 @@ public function boost($expr, ?float $boost): ?ExpressionInterface * * @param ExpressionInterface|string $word * @param int|mixed $proximity + * @no-named-arguments */ public function prx($word = null, $proximity = null): ?ExpressionInterface { @@ -119,6 +123,7 @@ public function prx($word = null, $proximity = null): ?ExpressionInterface * * @param ExpressionInterface|string|null $expr * @param float $similarity Similarity between 0.0 und 1.0 + * @no-named-arguments */ public function fzz($expr, ?float $similarity = null): ?ExpressionInterface { @@ -134,6 +139,7 @@ public function fzz($expr, ?float $similarity = null): ?ExpressionInterface * * @param string|int|float|ExpressionInterface $start * @param string|int|float|ExpressionInterface $end + * @no-named-arguments */ public function range($start = null, $end = null, bool $inclusive = true): ExpressionInterface { @@ -145,6 +151,7 @@ public function range($start = null, $end = null, bool $inclusive = true): Expre * * @param string|int|float|ExpressionInterface $start * @param string|int|float|ExpressionInterface $end + * @no-named-arguments */ public function btwnRange($start = null, $end = null): ExpressionInterface { @@ -156,6 +163,7 @@ public function btwnRange($start = null, $end = null): ExpressionInterface * * @param ExpressionInterface|string $prefix * @param ExpressionInterface|string $suffix + * @no-named-arguments */ public function wild($prefix, ?string $wildcard = '?', $suffix = null): ?ExpressionInterface { @@ -170,9 +178,9 @@ public function wild($prefix, ?string $wildcard = '?', $suffix = null): ?Express * Create bool, required expression: + * * @param ExpressionInterface|string|null $expr - * @return ExpressionInterface|null + * @no-named-arguments */ - public function req($expr) + public function req($expr): ?ExpressionInterface { if ($this->ignore($expr)) { return null; @@ -186,6 +194,7 @@ public function req($expr) * * @param ExpressionInterface|string|null $expr * @return ExpressionInterface|null + * @no-named-arguments */ public function prhb($expr) { @@ -202,6 +211,7 @@ public function prhb($expr) * * @param ExpressionInterface|string|null $expr * @return ExpressionInterface|null + * @no-named-arguments */ public function not($expr) { @@ -220,11 +230,10 @@ public function not($expr) * null => neutral () * * @param ExpressionInterface|string|null $expr - * @param bool|null $operator @codingStandardsIgnoreLine - * @return ExpressionInterface|null + * @return ExpressionInterface|string|null + * @no-named-arguments */ - public function bool($expr, $operator) // @codingStandardsIgnoreLine - + public function bool($expr, ?bool $operator = null) { if ($operator === null) { return $expr; @@ -241,6 +250,7 @@ public function bool($expr, $operator) // @codingStandardsIgnoreLine * Return string treated as literal (unescaped, unquoted) * * @param ExpressionInterface|string|null $expr + * @no-named-arguments */ public function lit($expr): ?ExpressionInterface { @@ -256,6 +266,7 @@ public function lit($expr): ?ExpressionInterface * * @param ExpressionInterface|string|null $expr * @param string|mixed $type + * @no-named-arguments */ public function grp($expr = null, $type = CompositeExpression::TYPE_SPACE): ?ExpressionInterface { @@ -272,6 +283,7 @@ public function grp($expr = null, $type = CompositeExpression::TYPE_SPACE): ?Exp * Create AND grouped expression: ( AND AND ) * * @param ExpressionInterface[]|string[] $args + * @no-named-arguments */ public function andX(...$args): ?ExpressionInterface { @@ -281,13 +293,14 @@ public function andX(...$args): ?ExpressionInterface return null; } - return new GroupExpression($args, GroupExpression::TYPE_AND); + return new GroupExpression($args, CompositeExpression::TYPE_AND); } /** * Create OR grouped expression: ( OR OR ) * * @param ExpressionInterface[]|string[] $args + * @no-named-arguments */ public function orX(...$args): ?ExpressionInterface { @@ -297,7 +310,7 @@ public function orX(...$args): ?ExpressionInterface return null; } - return new GroupExpression($args, GroupExpression::TYPE_OR); + return new GroupExpression($args, CompositeExpression::TYPE_OR); } /** @@ -305,6 +318,7 @@ public function orX(...$args): ?ExpressionInterface * * @param ExpressionInterface|string|null $expr * @return ExpressionInterface|mixed + * @no-named-arguments */ public function all($expr = null) { @@ -319,6 +333,7 @@ public function all($expr = null) * Create a date expression for a specific day * * @param DateTime|mixed $date + * @no-named-arguments */ public function day($date = null): ?ExpressionInterface { @@ -333,6 +348,7 @@ public function day($date = null): ?ExpressionInterface * Expression for the start of the given date * * @param bool|string $timezone + * @no-named-arguments */ public function startOfDay(?DateTime $date = null, $timezone = false): ?ExpressionInterface { @@ -351,6 +367,7 @@ public function startOfDay(?DateTime $date = null, $timezone = false): ?Expressi * Expression for the end of the given date * * @param bool|string $timezone + * @no-named-arguments */ public function endOfDay(?DateTime $date = null, $timezone = false): ?ExpressionInterface { @@ -365,7 +382,10 @@ public function endOfDay(?DateTime $date = null, $timezone = false): ?Expression ); } - /** @param bool|string $timezone */ + /** + * @param bool|string $timezone + * @no-named-arguments + */ public function date(?DateTime $date = null, $timezone = false): ExpressionInterface { if ($date === null) { @@ -383,6 +403,7 @@ public function date(?DateTime $date = null, $timezone = false): ExpressionInter * Create a range between two dates (one side may be unlimited which is indicated by passing null) * * @param bool|string $timezone + * @no-named-arguments */ public function dateRange( ?DateTime $from = null, @@ -407,7 +428,8 @@ public function dateRange( * * You can either pass an array of parameters, a single parameter or a ParameterExpression * - * @param array|ParameterExpressionInterface|string|null $parameters + * @param array|ExpressionInterface|string|null $parameters + * @no-named-arguments */ public function func(string $function, $parameters = null): ExpressionInterface { @@ -418,6 +440,7 @@ public function func(string $function, $parameters = null): ExpressionInterface * Create a function parameters expression * * @param mixed $parameters + * @no-named-arguments */ public function params(...$parameters): ExpressionInterface { @@ -429,6 +452,7 @@ public function params(...$parameters): ExpressionInterface /** * @param mixed[]|mixed $params * @param bool|mixed $shortForm + * @no-named-arguments */ public function localParams(string $type, $params = [], $shortForm = true): ?ExpressionInterface { @@ -449,7 +473,10 @@ public function localParams(string $type, $params = [], $shortForm = true): ?Exp return new LocalParamsExpression($type, $params, $shortForm); } - /** @param mixed[] $additionalParams */ + /** + * @param mixed[] $additionalParams + * @no-named-arguments + */ public function geofilt( string $field, ?GeolocationExpression $geolocation = null, @@ -464,6 +491,7 @@ public function geofilt( * Create composite expression: * * @param ExpressionInterface|string|null $expr + * @no-named-arguments */ public function comp($expr = null, ?string $type = CompositeExpression::TYPE_SPACE): ?ExpressionInterface { @@ -478,13 +506,17 @@ public function comp($expr = null, ?string $type = CompositeExpression::TYPE_SPA /** * Create a geo location expression: "," using the given precision + * @no-named-arguments */ public function latLong(float $latitude, float $longitude, int $precision = 12): ExpressionInterface { return new GeolocationExpression($latitude, $longitude, $precision); } - /** @param string|ExpressionInterface|null $expr */ + /** + * @param ExpressionInterface|string|null $expr + * @no-named-arguments + */ public function noCache($expr = null): ?ExpressionInterface { if ($this->ignore($expr)) { @@ -494,7 +526,10 @@ public function noCache($expr = null): ?ExpressionInterface return $this->comp([$this->shortLocalParams('cache', false), $expr], null); } - /** @param string|ExpressionInterface|null $expr */ + /** + * @param ExpressionInterface|string|null $expr + * @no-named-arguments + */ public function tag(string $tagName, $expr = null): ?ExpressionInterface { if ($this->ignore($expr)) { @@ -504,7 +539,10 @@ public function tag(string $tagName, $expr = null): ?ExpressionInterface return $this->comp([$this->shortLocalParams('tag', $tagName), $expr], null); } - /** @param string|ExpressionInterface|null $expr */ + /** + * @param ExpressionInterface|string|null $expr + * @no-named-arguments + */ public function excludeTag(string $tagName, $expr = null): ?ExpressionInterface { if ($this->ignore($expr)) { @@ -517,6 +555,7 @@ public function excludeTag(string $tagName, $expr = null): ?ExpressionInterface /** * @param ExpressionInterface|string $tag * @param mixed $value + * @no-named-arguments */ private function shortLocalParams($tag, $value): LocalParamsExpression { @@ -526,6 +565,7 @@ private function shortLocalParams($tag, $value): LocalParamsExpression /** * @param mixed[] $args * @return mixed[] + * @no-named-arguments */ private function parseCompositeArgs(array $args): array { @@ -545,13 +585,19 @@ private function parseCompositeArgs(array $args): array return [$args, $type]; } - /** @param mixed $expr */ + /** + * @param mixed $expr + * @no-named-arguments + */ private function ignore($expr): bool { return $expr === null || (is_string($expr) && trim($expr) === ''); } - /** @param mixed $expr */ + /** + * @param mixed $expr + * @no-named-arguments + */ private function permit($expr): bool { return !$this->ignore($expr); diff --git a/src/InterNations/Component/Solr/Expression/FieldExpression.php b/src/InterNations/Component/Solr/Expression/FieldExpression.php index f8991bb..3a4b8b1 100644 --- a/src/InterNations/Component/Solr/Expression/FieldExpression.php +++ b/src/InterNations/Component/Solr/Expression/FieldExpression.php @@ -1,6 +1,7 @@ similarity = (float) $similarity; + $this->similarity = $similarity; } } diff --git a/src/InterNations/Component/Solr/Expression/GeofiltExpression.php b/src/InterNations/Component/Solr/Expression/GeofiltExpression.php index 067fe68..0a0bd42 100644 --- a/src/InterNations/Component/Solr/Expression/GeofiltExpression.php +++ b/src/InterNations/Component/Solr/Expression/GeofiltExpression.php @@ -10,6 +10,7 @@ class GeofiltExpression extends Expression /** * @param mixed[] $additionalParams + * @no-named-arguments */ public function __construct( string $field, @@ -18,7 +19,7 @@ public function __construct( array $additionalParams = [] ) { - $this->field = (string) $field; + $this->field = $field; $this->geolocation = $geolocation; $this->distance = (int) $distance; $this->additionalParams = $additionalParams; diff --git a/src/InterNations/Component/Solr/Expression/GeolocationExpression.php b/src/InterNations/Component/Solr/Expression/GeolocationExpression.php index c64ba5c..888b36a 100644 --- a/src/InterNations/Component/Solr/Expression/GeolocationExpression.php +++ b/src/InterNations/Component/Solr/Expression/GeolocationExpression.php @@ -7,11 +7,12 @@ class GeolocationExpression extends Expression private $longitude; private $precision; + /** @no-named-arguments */ public function __construct(float $latitude, float $longitude, int $precision) { - $this->latitude = (float) $latitude; - $this->longitude = (float) $longitude; - $this->precision = (int) $precision; + $this->latitude = $latitude; + $this->longitude = $longitude; + $this->precision = $precision; } public function __toString(): string diff --git a/src/InterNations/Component/Solr/Expression/LocalParamsExpression.php b/src/InterNations/Component/Solr/Expression/LocalParamsExpression.php index 2a49984..8a451a2 100644 --- a/src/InterNations/Component/Solr/Expression/LocalParamsExpression.php +++ b/src/InterNations/Component/Solr/Expression/LocalParamsExpression.php @@ -1,28 +1,24 @@ parameters = $parameters; @@ -26,6 +27,7 @@ public function __toString(): string /** * @param mixed $value * @return PhraseExpression|mixed + * @no-named-arguments */ private function replaceNull($value) { diff --git a/src/InterNations/Component/Solr/Expression/ProximityExpression.php b/src/InterNations/Component/Solr/Expression/ProximityExpression.php index 49e48f3..e71268a 100644 --- a/src/InterNations/Component/Solr/Expression/ProximityExpression.php +++ b/src/InterNations/Component/Solr/Expression/ProximityExpression.php @@ -10,10 +10,8 @@ */ class ProximityExpression extends Expression { - /** - * @var array - */ - private $words = []; + /** @var array */ + private $words; /** * Maximum distance between the two words @@ -26,11 +24,12 @@ class ProximityExpression extends Expression * Create new proximity query object * * @param string[] $words + * @no-named-arguments */ public function __construct(array $words, int $proximity) { $this->words = $words; - $this->proximity = (int) $proximity; + $this->proximity = $proximity; } public function __toString(): string diff --git a/src/InterNations/Component/Solr/Expression/RangeExpression.php b/src/InterNations/Component/Solr/Expression/RangeExpression.php index 754a3e2..cd58783 100644 --- a/src/InterNations/Component/Solr/Expression/RangeExpression.php +++ b/src/InterNations/Component/Solr/Expression/RangeExpression.php @@ -37,12 +37,13 @@ class RangeExpression extends Expression * * @param string|int|Expression $start * @param string|int|Expression $end + * @no-named-arguments */ public function __construct($start = null, $end = null, bool $inclusive = true) { $this->start = $start; $this->end = $end; - $this->inclusive = (bool) $inclusive; + $this->inclusive = $inclusive; } public function __toString(): string @@ -59,6 +60,7 @@ public function __toString(): string /** * @param ExpressionInterface|string|null $value * @return ExpressionInterface|string + * @no-named-arguments */ private function cast($value) { diff --git a/src/InterNations/Component/Solr/Expression/WildcardExpression.php b/src/InterNations/Component/Solr/Expression/WildcardExpression.php index 04a178d..6a35c94 100644 --- a/src/InterNations/Component/Solr/Expression/WildcardExpression.php +++ b/src/InterNations/Component/Solr/Expression/WildcardExpression.php @@ -1,6 +1,7 @@ wildcard = $wildcard === '*' ? '*' : '?'; $this->prefix = $prefix; diff --git a/src/InterNations/Component/Solr/Query/QueryString.php b/src/InterNations/Component/Solr/Query/QueryString.php index 634a951..2515a84 100644 --- a/src/InterNations/Component/Solr/Query/QueryString.php +++ b/src/InterNations/Component/Solr/Query/QueryString.php @@ -8,16 +8,13 @@ class QueryString { - /** - * @var string - */ + /** @var string */ private $query; - /** - * @var array - */ + /** @var array */ private $placeholders = []; + /** @no-named-arguments */ public function __construct(string $query) { $this->query = $query; @@ -27,6 +24,7 @@ public function __construct(string $query) * Add a value for a placeholder * * @param mixed $value + * @no-named-arguments */ public function setPlaceholder(string $placeholder, $value): self { @@ -39,6 +37,7 @@ public function setPlaceholder(string $placeholder, $value): self * Add values for several placeholders as key => value pairs * * @param mixed[] $placeholders + * @no-named-arguments */ public function setPlaceholders(array $placeholders): self { diff --git a/tests/InterNations/Component/Solr/AnnotationsTest.php b/tests/InterNations/Component/Solr/AnnotationsTest.php new file mode 100644 index 0000000..ac6c3b1 --- /dev/null +++ b/tests/InterNations/Component/Solr/AnnotationsTest.php @@ -0,0 +1,58 @@ +getFilesAsArray(__DIR__ . '/../../../../src', '.php') + ); + + return array_map( + static function (string $class) { + return [$class]; + }, + array_filter( + get_declared_classes(), + static function (string $class) { + return strpos($class, 'InterNations\\Component\\Solr\\') === 0 + && strpos($class, 'InterNations\\Component\\Solr\\Tests\\') === false; + } + ) + ); + } + + /** @dataProvider getClasses */ + public function testOptOutOfNamedArgumentSupportIsInPlace(string $className): void + { + $class = new ReflectionClass($className); + foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { + if (count($method->getParameters()) > 0 && $method->getDeclaringClass()->getName() === $className) { + self::assertStringContainsString( + '@no-named-arguments', + $method->getDocComment(), + sprintf( + 'Expected "%s::%s()" to have annotation @no-named-arguments', + $method->getDeclaringClass()->getName(), + $method->getName() + ) + ); + } + } + $this->addToAssertionCount(1); + } +} diff --git a/tests/InterNations/Component/Solr/Tests/Expression/ExpressionBuilderTest.php b/tests/InterNations/Component/Solr/Tests/Expression/ExpressionBuilderTest.php index 887ff17..e03a58c 100644 --- a/tests/InterNations/Component/Solr/Tests/Expression/ExpressionBuilderTest.php +++ b/tests/InterNations/Component/Solr/Tests/Expression/ExpressionBuilderTest.php @@ -4,12 +4,11 @@ use InterNations\Component\Solr\Expression\CompositeExpression; use InterNations\Component\Solr\Expression\ExpressionBuilder; use InterNations\Component\Solr\Expression\GroupExpression; -use InterNations\Component\Solr\Expression\ParameterExpression; -use InterNations\Component\Testing\AbstractTestCase; use DateTime; use DateTimeZone; +use PHPUnit\Framework\TestCase; -class ExpressionBuilderTest extends AbstractTestCase +class ExpressionBuilderTest extends TestCase { /** * @var ExpressionBuilder @@ -62,6 +61,10 @@ public function testBoost() $this->assertInstanceOf('InterNations\Component\Solr\Expression\BoostExpression', $b); $this->assertSame('"foo bar"^10', (string) $b); + $b = $this->eb->boost($this->eb->phrase('foo bar'), 10.1); + $this->assertInstanceOf('InterNations\Component\Solr\Expression\BoostExpression', $b); + $this->assertSame('"foo bar"^10.1', (string) $b); + $b = $this->eb->field('field', $this->eb->boost($this->eb->phrase('foo bar'), 10)); $this->assertInstanceOf('InterNations\Component\Solr\Expression\FieldExpression', $b); $this->assertSame('field:"foo bar"^10', (string) $b); diff --git a/tests/InterNations/Component/Solr/Tests/Expression/ExpressionTest.php b/tests/InterNations/Component/Solr/Tests/Expression/ExpressionTest.php index 0723f5a..8442fd4 100644 --- a/tests/InterNations/Component/Solr/Tests/Expression/ExpressionTest.php +++ b/tests/InterNations/Component/Solr/Tests/Expression/ExpressionTest.php @@ -5,7 +5,6 @@ use InterNations\Component\Solr\Expression\GeolocationExpression; use InterNations\Component\Solr\Expression\LocalParamsExpression; use InterNations\Component\Solr\Expression\ParameterExpression; -use InterNations\Component\Testing\AbstractTestCase; use InterNations\Component\Solr\Expression\DateTimeExpression; use InterNations\Component\Solr\Expression\PhraseExpression; use InterNations\Component\Solr\Expression\WildcardExpression; @@ -18,8 +17,9 @@ use InterNations\Component\Solr\Expression\BooleanExpression; use DateTime; use DateTimeZone; +use PHPUnit\Framework\TestCase; -class ExpressionTest extends AbstractTestCase +class ExpressionTest extends TestCase { public function testPhraseExpression() { diff --git a/tests/InterNations/Component/Solr/Tests/Expression/PerformanceTest.php b/tests/InterNations/Component/Solr/Tests/Expression/PerformanceTest.php index c887b88..70d637d 100644 --- a/tests/InterNations/Component/Solr/Tests/Expression/PerformanceTest.php +++ b/tests/InterNations/Component/Solr/Tests/Expression/PerformanceTest.php @@ -1,17 +1,15 @@