Skip to content

Commit

Permalink
PHP CS Fixer 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Mar 25, 2017
1 parent 361e69c commit 3a20928
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 43 deletions.
41 changes: 23 additions & 18 deletions .php_cs
@@ -1,24 +1,29 @@
<?php

return Symfony\CS\Config\Config::create()
->setUsingLinter(false)
->setUsingCache(true)
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
->fixers([
'concat_with_spaces',
'-concat_without_spaces',
'-empty_return',
'-phpdoc_params',
'-phpdoc_separation',
'-phpdoc_to_comment',
'-spaces_cast',
'-blankline_after_open_tag',
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => array('syntax' => 'long'),
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => false,
'phpdoc_order' => true,
'phpdoc_no_alias_tag' => false,
'psr4' => true,
'semicolon_after_instruction' => true,
'strict_comparison' => true,
'strict_param' => true,
])
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->setFinder(
PhpCsFixer\Finder::create()
->exclude(['vendor'])
->in(__DIR__)
->exclude([
'vendor',
])
)
;
41 changes: 21 additions & 20 deletions Core/FieldType/ContentTypeList/Type.php
Expand Up @@ -2,10 +2,10 @@

namespace Netgen\Bundle\ContentTypeListBundle\Core\FieldType\ContentTypeList;

use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType;
use eZ\Publish\Core\FieldType\FieldType;
use eZ\Publish\Core\FieldType\Value as BaseValue;
use eZ\Publish\SPI\FieldType\Value as SPIValue;
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType;

class Type extends FieldType
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public function getFieldTypeIdentifier()
*/
public function getName(SPIValue $value)
{
return (string)$value;
return (string) $value;
}

/**
Expand Down Expand Up @@ -104,6 +104,22 @@ public function toHash(SPIValue $value)
return $value->identifiers;
}

/**
* Returns if the given $value is considered empty by the field type.
*
* Default implementation, which performs a "==" check with the value
* returned by {@link getEmptyValue()}. Overwrite in the specific field
* type, if necessary.
*
* @param \eZ\Publish\SPI\FieldType\Value|\Netgen\Bundle\ContentTypeListBundle\Core\FieldType\ContentTypeList\Value $value
*
* @return bool
*/
public function isEmptyValue(SPIValue $value)
{
return $value === null || $value->identifiers === $this->getEmptyValue()->identifiers;
}

/**
* Inspects given $inputValue and potentially converts it into a dedicated value object.
*
Expand All @@ -114,7 +130,7 @@ public function toHash(SPIValue $value)
*
* @param mixed $inputValue
*
* @return mixed The potentially converted input value.
* @return mixed the potentially converted input value
*/
protected function createValueFromInput($inputValue)
{
Expand All @@ -140,9 +156,10 @@ protected function createValueFromInput($inputValue)
*
* This is an operation method for {@see acceptValue()}.
*
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the value does not match the expected structure.
*
* @param \eZ\Publish\Core\FieldType\Value|\Netgen\Bundle\ContentTypeListBundle\Core\FieldType\ContentTypeList\Value $value
*
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the value does not match the expected structure
*/
protected function checkValueStructure(BaseValue $value)
{
Expand Down Expand Up @@ -185,20 +202,4 @@ protected function getSortInfo(BaseValue $value)
{
return false;
}

/**
* Returns if the given $value is considered empty by the field type.
*
* Default implementation, which performs a "==" check with the value
* returned by {@link getEmptyValue()}. Overwrite in the specific field
* type, if necessary.
*
* @param \eZ\Publish\SPI\FieldType\Value|\Netgen\Bundle\ContentTypeListBundle\Core\FieldType\ContentTypeList\Value $value
*
* @return bool
*/
public function isEmptyValue(SPIValue $value)
{
return $value === null || $value->identifiers == $this->getEmptyValue()->identifiers;
}
}
8 changes: 4 additions & 4 deletions DependencyInjection/NetgenContentTypeListExtension.php
Expand Up @@ -2,12 +2,12 @@

namespace Netgen\Bundle\ContentTypeListBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Yaml\Yaml;

class NetgenContentTypeListExtension extends Extension implements PrependExtensionInterface
Expand Down
Expand Up @@ -2,12 +2,12 @@

namespace Netgen\Bundle\ContentTypeListBundle\Tests\Core\Persistence\Legacy\Content\FieldValue\Converter;

use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter;
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition;
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue;
use eZ\Publish\SPI\Persistence\Content\FieldValue;
use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition;
use Netgen\Bundle\ContentTypeListBundle\Core\Persistence\Legacy\Content\FieldValue\Converter\ContentTypeListConverter;
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter;

class ContentTypeListConverterTest extends \PHPUnit_Framework_TestCase
{
Expand Down

0 comments on commit 3a20928

Please sign in to comment.