Skip to content

Commit

Permalink
refactor #138 Remove "Interface" suffix usage (sstok)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.0-dev branch.

Discussion
----------

The (new) style guide of Rollerworks forbids that Interfaces are suffixed with “Interface” as this breaks ambiguous naming.

Say we had the SearchFactory class but like to introduce a SearchFactory (Interface), renaming the class is one thing. But now all the typehints and references need to be updated, which can cause some serieus BC breakage.

Second Interfaces suffixes are a form Hungarian notations, which is considered a bad practice for a really long time now. Only traits should be suffixed as they can never change there intention, not can they be type-hinted.

Commits
-------

0307f56 Rename some classes to remove interfaces suffix
11565b6 Remove usage of Interface suffix
  • Loading branch information
sstok committed Jan 15, 2017
2 parents 97542a2 + 11565b6 commit d3f4337
Show file tree
Hide file tree
Showing 111 changed files with 1,192 additions and 1,194 deletions.
18 changes: 9 additions & 9 deletions src/AbstractExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
*
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
*/
abstract class AbstractExtension implements SearchExtensionInterface
abstract class AbstractExtension implements SearchExtension
{
private $typesExtensions;
private $types;

/**
* {@inheritdoc}
*/
public function getType(string $name): FieldTypeInterface
public function getType(string $name): FieldType
{
if (null === $this->types) {
$this->initTypes();
Expand Down Expand Up @@ -86,12 +86,12 @@ public function getTypeExtensions(string $type): array

/**
* If extension needs to provide new field types this function
* should be overloaded in child class and return an array of FieldTypeInterface
* should be overloaded in child class and return an array of FieldType
* instances.
*
* This is only required for types that have a constructor with (required) arguments.
*
* @return FieldTypeInterface[]
* @return FieldType[]
*/
protected function loadTypes(): array
{
Expand All @@ -100,7 +100,7 @@ protected function loadTypes(): array

/**
* If extension needs to provide field type extensions this function
* should be overloaded in child class and return array of FieldTypeExtensionInterface
* should be overloaded in child class and return array of FieldTypeExtension
* instances per type: `TypeClassName => [FieldTypeExtensionInterface, ...]`.
*
* @return array
Expand All @@ -115,8 +115,8 @@ private function initTypes()
$this->types = [];

foreach ($this->loadTypes() as $type) {
if (!$type instanceof FieldTypeInterface) {
throw new UnexpectedTypeException($type, FieldTypeInterface::class);
if (!$type instanceof FieldType) {
throw new UnexpectedTypeException($type, FieldType::class);
}

$this->types[get_class($type)] = $type;
Expand All @@ -128,8 +128,8 @@ private function initTypesExtensions()
$this->typesExtensions = [];

foreach ($this->loadTypesExtensions() as $extension) {
if (!$extension instanceof FieldTypeExtensionInterface) {
throw new UnexpectedTypeException($extension, FieldTypeExtensionInterface::class);
if (!$extension instanceof FieldTypeExtension) {
throw new UnexpectedTypeException($extension, FieldTypeExtension::class);
}

$this->typesExtensions[$extension->getExtendedType()][] = $extension;
Expand Down
10 changes: 5 additions & 5 deletions src/AbstractFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Rollerworks\Component\Search;

use Rollerworks\Component\Search\Extension\Core\Type\FieldType;
use Rollerworks\Component\Search\Extension\Core\Type\SearchFieldType;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
Expand All @@ -25,19 +25,19 @@
*
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
*/
abstract class AbstractFieldType implements FieldTypeInterface
abstract class AbstractFieldType implements FieldType
{
/**
* {@inheritdoc}
*/
public function buildType(FieldConfigInterface $config, array $options)
public function buildType(FieldConfig $config, array $options)
{
}

/**
* {@inheritdoc}
*/
public function buildView(SearchFieldView $view, FieldConfigInterface $config, array $options)
public function buildView(SearchFieldView $view, FieldConfig $config, array $options)
{
}

Expand All @@ -53,6 +53,6 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return FieldType::class;
return SearchFieldType::class;
}
}
6 changes: 3 additions & 3 deletions src/AbstractFieldTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
* {@link FieldTypeExtensionInterface} is that any new methods added the
* FieldTypeExtensionInterface will not break existing implementations.
*/
abstract class AbstractFieldTypeExtension implements FieldTypeExtensionInterface
abstract class AbstractFieldTypeExtension implements FieldTypeExtension
{
/**
* {@inheritdoc}
*/
public function buildType(FieldConfigInterface $builder, array $options)
public function buildType(FieldConfig $builder, array $options)
{
}

/**
* {@inheritdoc}
*/
public function buildView(FieldConfigInterface $config, SearchFieldView $view)
public function buildView(FieldConfig $config, SearchFieldView $view)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/ExporterInterface.php → src/ConditionExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
namespace Rollerworks\Component\Search;

/**
* ExporterInterface defines the interface for SearchCondition exporters.
* ConditionExporter defines the interface for SearchCondition exporters.
*
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
*/
interface ExporterInterface
interface ConditionExporter
{
/**
* Exports the SearchCondition to a portable format.
Expand Down
10 changes: 5 additions & 5 deletions src/ConditionOptimizer/ChainOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
namespace Rollerworks\Component\Search\ConditionOptimizer;

use Rollerworks\Component\Search\SearchCondition;
use Rollerworks\Component\Search\SearchConditionOptimizerInterface;
use Rollerworks\Component\Search\SearchConditionOptimizer;

/**
* ChainOptimizer performs the registered optimizers in order of priority.
*
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
*/
class ChainOptimizer implements SearchConditionOptimizerInterface
class ChainOptimizer implements SearchConditionOptimizer
{
/**
* @var array<SearchConditionOptimizerInterface[]>
Expand All @@ -45,13 +45,13 @@ public static function create(): ChainOptimizer
}

/**
* @param SearchConditionOptimizerInterface $optimizer
* @param SearchConditionOptimizer $optimizer
*
* @throws \InvalidArgumentException
*
* @return self
*/
public function addOptimizer(SearchConditionOptimizerInterface $optimizer)
public function addOptimizer(SearchConditionOptimizer $optimizer)
{
// Ensure we got no end-less loops
if ($optimizer === $this) {
Expand All @@ -77,7 +77,7 @@ public function process(SearchCondition $condition)
krsort($this->optimizers, SORT_NUMERIC);

foreach ($this->optimizers as $optimizers) {
/** @var SearchConditionOptimizerInterface[] $optimizers */
/** @var SearchConditionOptimizer[] $optimizers */
foreach ($optimizers as $optimizer) {
$optimizer->process($condition);
}
Expand Down
50 changes: 25 additions & 25 deletions src/ConditionOptimizer/DuplicateRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

namespace Rollerworks\Component\Search\ConditionOptimizer;

use Rollerworks\Component\Search\FieldConfigInterface;
use Rollerworks\Component\Search\FieldConfig;
use Rollerworks\Component\Search\FieldSet;
use Rollerworks\Component\Search\SearchCondition;
use Rollerworks\Component\Search\SearchConditionOptimizerInterface;
use Rollerworks\Component\Search\SearchConditionOptimizer;
use Rollerworks\Component\Search\Value\Compare;
use Rollerworks\Component\Search\Value\ExcludedRange;
use Rollerworks\Component\Search\Value\PatternMatch;
use Rollerworks\Component\Search\Value\Range;
use Rollerworks\Component\Search\Value\ValuesBag;
use Rollerworks\Component\Search\Value\ValuesGroup;
use Rollerworks\Component\Search\ValueComparisonInterface;
use Rollerworks\Component\Search\ValueComparator;

/**
* Removes duplicated values.
Expand All @@ -38,7 +38,7 @@
*
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
*/
class DuplicateRemover implements SearchConditionOptimizerInterface
class DuplicateRemover implements SearchConditionOptimizer
{
/**
* {@inheritdoc}
Expand Down Expand Up @@ -68,7 +68,7 @@ private function removeDuplicatesInGroup(ValuesGroup $valuesGroup, FieldSet $fie
}
}

private function removeDuplicatesInValuesBag(FieldConfigInterface $config, ValuesBag $valuesBag)
private function removeDuplicatesInValuesBag(FieldConfig $config, ValuesBag $valuesBag)
{
$comparison = $config->getValueComparison();
$options = $config->getOptions();
Expand All @@ -84,16 +84,16 @@ private function removeDuplicatesInValuesBag(FieldConfigInterface $config, Value
}

/**
* @param array $values
* @param ValuesBag $valuesBag
* @param ValueComparisonInterface $comparison
* @param array $options
* @param bool $exclude
* @param array $values
* @param ValuesBag $valuesBag
* @param ValueComparator $comparison
* @param array $options
* @param bool $exclude
*/
private function removeDuplicateValues(
array $values,
ValuesBag $valuesBag,
ValueComparisonInterface $comparison,
ValueComparator $comparison,
array $options,
$exclude = false
) {
Expand All @@ -115,16 +115,16 @@ private function removeDuplicateValues(
}

/**
* @param Range[] $ranges
* @param ValuesBag $valuesBag
* @param ValueComparisonInterface $comparison
* @param array $options
* @param bool $exclude
* @param Range[] $ranges
* @param ValuesBag $valuesBag
* @param ValueComparator $comparison
* @param array $options
* @param bool $exclude
*/
private function removeDuplicateRanges(
array $ranges,
ValuesBag $valuesBag,
ValueComparisonInterface $comparison,
ValueComparator $comparison,
array $options,
$exclude = false
) {
Expand Down Expand Up @@ -155,11 +155,11 @@ private function removeDuplicateRanges(
}

/**
* @param ValuesBag $valuesBag
* @param ValueComparisonInterface $comparison
* @param array $options
* @param ValuesBag $valuesBag
* @param ValueComparator $comparison
* @param array $options
*/
private function removeDuplicateComparisons(ValuesBag $valuesBag, ValueComparisonInterface $comparison, array $options)
private function removeDuplicateComparisons(ValuesBag $valuesBag, ValueComparator $comparison, array $options)
{
/** @var Compare[] $comparisons */
$comparisons = $valuesBag->get(Compare::class);
Expand All @@ -181,11 +181,11 @@ private function removeDuplicateComparisons(ValuesBag $valuesBag, ValueCompariso
}

/**
* @param ValuesBag $valuesBag
* @param ValueComparisonInterface $comparison
* @param array $options
* @param ValuesBag $valuesBag
* @param ValueComparator $comparison
* @param array $options
*/
private function removeDuplicateMatchers(ValuesBag $valuesBag, ValueComparisonInterface $comparison, array $options)
private function removeDuplicateMatchers(ValuesBag $valuesBag, ValueComparator $comparison, array $options)
{
/** @var PatternMatch[] $matchers */
$matchers = $valuesBag->get(PatternMatch::class);
Expand Down

0 comments on commit d3f4337

Please sign in to comment.