Skip to content

Commit

Permalink
style #166 Style and strict improvements (sstok)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.0-dev branch.

Discussion
----------

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | 
| License       | MIT
| Doc PR        | 

Commits
-------

24f0510 Mark more classes as final
52e2d3d Clean-up useless comments (fix author(s))
f22a08a Mark all tests as internal
  • Loading branch information
sstok authored Aug 16, 2017
2 parents 4a54d79 + f22a08a commit 55798d5
Show file tree
Hide file tree
Showing 131 changed files with 363 additions and 294 deletions.
5 changes: 1 addition & 4 deletions src/ConditionErrorMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ public function setTranslatedParameters(array $translatedParameters)
$this->translatedParameters = $translatedParameters;
}

/**
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->message;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ConditionOptimizer/ChainOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Sebastiaan Stok <[email protected]>
*/
class ChainOptimizer implements SearchConditionOptimizer
final class ChainOptimizer implements SearchConditionOptimizer
{
/**
* @var array<SearchConditionOptimizerInterface[]>
Expand Down
25 changes: 1 addition & 24 deletions src/ConditionOptimizer/DuplicateRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,13 @@
*
* @author Sebastiaan Stok <[email protected]>
*/
class DuplicateRemover implements SearchConditionOptimizer
final class DuplicateRemover implements SearchConditionOptimizer
{
/**
* {@inheritdoc}
*/
public function process(SearchCondition $condition)
{
$this->removeDuplicatesInGroup($condition->getValuesGroup(), $condition->getFieldSet());
}

/**
* {@inheritdoc}
*/
public function getPriority(): int
{
return 5;
Expand Down Expand Up @@ -83,13 +77,6 @@ private function removeDuplicatesInValuesBag(FieldConfig $config, ValuesBag $val
$this->removeDuplicateMatchers($valuesBag, $comparator, $options);
}

/**
* @param array $values
* @param ValuesBag $valuesBag
* @param ValueComparator $comparator
* @param array $options
* @param bool $exclude
*/
private function removeDuplicateValues(
array $values,
ValuesBag $valuesBag,
Expand Down Expand Up @@ -152,11 +139,6 @@ private function removeDuplicateRanges(
}
}

/**
* @param ValuesBag $valuesBag
* @param ValueComparator $comparator
* @param array $options
*/
private function removeDuplicateComparisons(ValuesBag $valuesBag, ValueComparator $comparator, array $options)
{
/** @var Compare[] $comparisons */
Expand All @@ -178,11 +160,6 @@ private function removeDuplicateComparisons(ValuesBag $valuesBag, ValueComparato
}
}

/**
* @param ValuesBag $valuesBag
* @param ValueComparator $comparator
* @param array $options
*/
private function removeDuplicateMatchers(ValuesBag $valuesBag, ValueComparator $comparator, array $options)
{
/** @var PatternMatch[] $matchers */
Expand Down
8 changes: 1 addition & 7 deletions src/ConditionOptimizer/RangeOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
*
* @author Sebastiaan Stok <[email protected]>
*/
class RangeOptimizer implements SearchConditionOptimizer
final class RangeOptimizer implements SearchConditionOptimizer
{
/**
* {@inheritdoc}
*/
public function process(SearchCondition $condition)
{
$fieldSet = $condition->getFieldSet();
Expand All @@ -54,9 +51,6 @@ public function process(SearchCondition $condition)
$this->normalizeRangesInGroup($condition->getValuesGroup(), $fieldSet);
}

/**
* {@inheritdoc}
*/
public function getPriority(): int
{
return -5;
Expand Down
8 changes: 1 addition & 7 deletions src/ConditionOptimizer/ValuesToRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@
*
* @author Sebastiaan Stok <[email protected]>
*/
class ValuesToRange implements SearchConditionOptimizer
final class ValuesToRange implements SearchConditionOptimizer
{
private $comparators = [];

/**
* {@inheritdoc}
*/
public function process(SearchCondition $condition)
{
$fieldSet = $condition->getFieldSet();
Expand All @@ -61,9 +58,6 @@ public function process(SearchCondition $condition)
$this->optimizeValuesInGroup($valuesGroup, $fieldSet);
}

/**
* {@inheritdoc}
*/
public function getPriority(): int
{
// run before range optimizer
Expand Down
3 changes: 3 additions & 0 deletions src/ErrorList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Rollerworks\Component\Search;

/**
* @author Sebastiaan Stok <[email protected]>
*/
final class ErrorList extends \ArrayObject
{
}
5 changes: 4 additions & 1 deletion src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Rollerworks\Component\Search\Exception;

class BadMethodCallException extends \BadMethodCallException implements SearchException
/**
* @author Sebastiaan Stok <[email protected]>
*/
final class BadMethodCallException extends \BadMethodCallException implements SearchException
{
}
3 changes: 3 additions & 0 deletions src/Exception/InvalidSearchConditionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Rollerworks\Component\Search\ConditionErrorMessage;

/**
* @author Sebastiaan Stok <[email protected]>
*/
final class InvalidSearchConditionException extends \InvalidArgumentException implements SearchException
{
private $errors;
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/TransformationFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
/**
* @author Sebastiaan Stok <[email protected]>
*/
class TransformationFailedException extends \RuntimeException implements SearchException
final class TransformationFailedException extends \RuntimeException implements SearchException
{
}
3 changes: 3 additions & 0 deletions src/Exception/UnsupportedFieldSetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Rollerworks\Component\Search\Exception;

/**
* @author Sebastiaan Stok <[email protected]>
*/
final class UnsupportedFieldSetException extends InvalidArgumentException
{
public function __construct(array $expected, string $provided)
Expand Down
9 changes: 1 addition & 8 deletions src/Exporter/AbstractExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,7 @@ public function exportCondition(SearchCondition $condition)
return $this->exportGroup($condition->getValuesGroup(), $condition->getFieldSet(), true);
}

/**
* @param ValuesGroup $valuesGroup
* @param FieldSet $fieldSet
* @param bool $isRoot
*
* @return mixed
*/
abstract protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, $isRoot = false);
abstract protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, bool $isRoot = false);

/**
* Transforms the model value to a view representation.
Expand Down
9 changes: 1 addition & 8 deletions src/Exporter/ArrayExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@
*/
final class ArrayExporter extends AbstractExporter
{
/**
* @param ValuesGroup $valuesGroup
* @param FieldSet $fieldSet
* @param bool $isRoot
*
* @return array
*/
protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, $isRoot = false)
protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, bool $isRoot = false): array
{
$result = [];
$fields = $valuesGroup->getFields();
Expand Down
13 changes: 3 additions & 10 deletions src/Exporter/StringQueryExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,16 @@ public function __construct(callable $labelResolver = null)
*
* @param SearchCondition $condition The search condition to export
*
* @return mixed
* @return string
*/
public function exportCondition(SearchCondition $condition)
public function exportCondition(SearchCondition $condition): string
{
$this->fields = $this->resolveLabels($condition->getFieldSet());

return $this->exportGroup($condition->getValuesGroup(), $condition->getFieldSet(), true);
}

/**
* @param ValuesGroup $valuesGroup
* @param FieldSet $fieldSet
* @param bool $isRoot
*
* @return string
*/
protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, $isRoot = false)
protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, bool $isRoot = false): string
{
$result = '';
$exportedGroups = '';
Expand Down
9 changes: 2 additions & 7 deletions src/Exporter/XmlExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class XmlExporter extends AbstractExporter
*
* @return string
*/
public function exportCondition(SearchCondition $condition, bool $formatOutput = true)
public function exportCondition(SearchCondition $condition, bool $formatOutput = true): string
{
$this->document = new \DOMDocument('1.0', 'utf-8');
$this->document->formatOutput = $formatOutput;
Expand All @@ -66,12 +66,7 @@ public function exportCondition(SearchCondition $condition, bool $formatOutput =
return $xml;
}

/**
* {@inheritdoc}
*
* @ignore
*/
protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, $isRoot = false)
protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, bool $isRoot = false): void
{
// no-op
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use Rollerworks\Component\Search\DataTransformer;
use Rollerworks\Component\Search\Exception\InvalidArgumentException;
use Rollerworks\Component\Search\Exception\UnexpectedTypeException;

/**
* @author Bernhard Schussek <[email protected]>
Expand Down Expand Up @@ -46,8 +45,6 @@ abstract class BaseDateTimeTransformer implements DataTransformer
*
* @param string|null $inputTimezone The name of the input timezone
* @param string|null $outputTimezone The name of the output timezone
*
* @throws UnexpectedTypeException if a timezone is not a string
*/
public function __construct(?string $inputTimezone = null, ?string $outputTimezone = null)
{
Expand Down
5 changes: 0 additions & 5 deletions src/Extension/Core/DataTransformer/BirthdayTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ final class BirthdayTransformer implements DataTransformer
*/
private $allowFutureDate;

/**
* @param DataTransformer $transformer
* @param bool $allowAge
* @param bool $allowFutureDate
*/
public function __construct(DataTransformer $transformer, bool $allowAge = true, bool $allowFutureDate = false)
{
$this->transformer = $transformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ final class ChoiceToLabelTransformer implements DataTransformer
private $choiceList;
private $choiceListView;

/**
* Constructor.
*
* @param ChoiceList $choiceList
* @param ChoiceListView $choiceListView
*/
public function __construct(ChoiceList $choiceList, ChoiceListView $choiceListView)
{
$this->choiceList = $choiceList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ protected function getIntlDateFormatter(bool $ignoreTimezone = false): \IntlDate
return $intlDateFormatter;
}

/**
* Checks if the pattern contains only a date.
*
* @return bool
*/
protected function isPatternDateOnly(): bool
{
if (null === $this->pattern) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @author Bernhard Schussek <[email protected]>
*/
class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransformer
final class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransformer
{
/**
* Constructs a transformer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @author Bernhard Schussek <[email protected]>
*/
class IntegerToStringTransformer extends NumberToStringTransformer
final class IntegerToStringTransformer extends NumberToStringTransformer
{
/**
* Constructs a transformer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ final class LocalizedBirthdayTransformer implements DataTransformer
private $allowAge;
private $allowFutureDate;

/**
* @param DataTransformer $transformer
* @param bool $allowAge
* @param bool $allowFutureDate
*/
public function __construct(DataTransformer $transformer, bool $allowAge = true, bool $allowFutureDate = false)
{
$this->transformer = $transformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ final class MoneyToLocalizedStringTransformer extends BaseNumberTransformer
/** None-breaking line */
private const NBL = "\xc2\xa0";

/**
* Constructor.
*
* @param string $defaultCurrency
* @param bool $grouping
*/
public function __construct(string $defaultCurrency, bool $grouping = false)
{
$this->defaultCurrency = $defaultCurrency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
/**
* Transforms between a normalized format and a money string.
*
* @author Bernhard Schussek <[email protected]>
* @author Florian Eckerstorfer <[email protected]>
* @author Sebastiaan Stok <[email protected]>
*/
final class MoneyToStringTransformer implements DataTransformer
Expand All @@ -33,11 +31,6 @@ final class MoneyToStringTransformer implements DataTransformer
private $moneyParser;
private $formatter;

/**
* Constructor.
*
* @param string $defaultCurrency
*/
public function __construct(string $defaultCurrency)
{
$this->defaultCurrency = $defaultCurrency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
*/
class NumberToStringTransformer extends BaseNumberTransformer
{
/**
* @param int $scale
* @param int $roundingMode
*/
public function __construct(int $scale = null, ?int $roundingMode = null)
public function __construct(?int $scale = null, ?int $roundingMode = null)
{
$this->scale = $scale;
$this->roundingMode = $roundingMode ?? self::ROUND_HALF_UP;
Expand Down
3 changes: 0 additions & 3 deletions src/Extension/Core/Type/BaseDateTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ abstract class BaseDateTimeType extends AbstractFieldType
public const DEFAULT_DATE_FORMAT = \IntlDateFormatter::MEDIUM;
public const DEFAULT_TIME_FORMAT = \IntlDateFormatter::MEDIUM;

/**
* @var array
*/
protected static $acceptedFormats = [
\IntlDateFormatter::FULL,
\IntlDateFormatter::LONG,
Expand Down
Loading

0 comments on commit 55798d5

Please sign in to comment.