Skip to content

Commit

Permalink
Migrate to PHP-CS-Fixer v2
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Feb 8, 2017
1 parent 6ec1f96 commit a6c3598
Show file tree
Hide file tree
Showing 84 changed files with 950 additions and 948 deletions.
44 changes: 23 additions & 21 deletions .php_cs
@@ -1,27 +1,29 @@
<?php

return Symfony\CS\Config\Config::create()
->setUsingLinter(false)
->setUsingCache(true)
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
->fixers([
'concat_with_spaces',
'phpdoc_order',
'long_array_syntax',
'-short_array_syntax',
'-psr0',
'-concat_without_spaces',
'-phpdoc_params',
'-phpdoc_to_comment',
'-spaces_cast',
return PhpCsFixer\Config::create()
->setRiskyAllowed(false)
->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', 'node_modules'])
->in(__DIR__)
->exclude([
'vendor',
'node_modules',
])
->files()->name('*.php')
)
;
2 changes: 1 addition & 1 deletion API/Repository/TagsService.php
Expand Up @@ -2,10 +2,10 @@

namespace Netgen\TagsBundle\API\Repository;

use Netgen\TagsBundle\API\Repository\Values\Tags\SynonymCreateStruct;
use Netgen\TagsBundle\API\Repository\Values\Tags\Tag;
use Netgen\TagsBundle\API\Repository\Values\Tags\TagCreateStruct;
use Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct;
use Netgen\TagsBundle\API\Repository\Values\Tags\SynonymCreateStruct;

interface TagsService
{
Expand Down
2 changes: 1 addition & 1 deletion API/Repository/Values/Content/Query/Criterion/TagId.php
Expand Up @@ -3,9 +3,9 @@
namespace Netgen\TagsBundle\API\Repository\Values\Content\Query\Criterion;

use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\Specifications;
use eZ\Publish\API\Repository\Values\Content\Query\CriterionInterface;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator;

/**
* A criterion that matches content based on tag ID that is located in one of the fields.
Expand Down
4 changes: 2 additions & 2 deletions API/Repository/Values/Content/Query/Criterion/TagKeyword.php
Expand Up @@ -3,10 +3,10 @@
namespace Netgen\TagsBundle\API\Repository\Values\Content\Query\Criterion;

use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\Specifications;
use eZ\Publish\API\Repository\Values\Content\Query\CriterionInterface;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\Specifications;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Value;
use eZ\Publish\API\Repository\Values\Content\Query\CriterionInterface;

/**
* A criterion that matches content based on tag keyword that is located in one of the fields.
Expand Down
76 changes: 38 additions & 38 deletions API/Repository/Values/Tags/Tag.php
Expand Up @@ -102,44 +102,6 @@ class Tag extends ValueObject
*/
protected $languageCodes = array();

/**
* Returns the keyword in the given language.
*
* If no language is given, the keyword in main language of the tag if present, otherwise null
*
* @param string $languageCode
*
* @return string
*/
public function getKeyword($languageCode = null)
{
if ($languageCode === null) {
$languageCode = $this->mainLanguageCode;
}

if (isset($this->keywords[$languageCode])) {
return $this->keywords[$languageCode];
}

return null;
}

/**
* Function where list of properties are returned.
*
* Override to add dynamic properties
*
* @uses \parent::getProperties()
*
* @param array $dynamicProperties
*
* @return array
*/
protected function getProperties($dynamicProperties = array('keyword'))
{
return parent::getProperties($dynamicProperties);
}

/**
* Magic getter for retrieving convenience properties.
*
Expand Down Expand Up @@ -173,6 +135,28 @@ public function __isset($property)
return parent::__isset($property);
}

/**
* Returns the keyword in the given language.
*
* If no language is given, the keyword in main language of the tag if present, otherwise null
*
* @param string $languageCode
*
* @return string
*/
public function getKeyword($languageCode = null)
{
if ($languageCode === null) {
$languageCode = $this->mainLanguageCode;
}

if (isset($this->keywords[$languageCode])) {
return $this->keywords[$languageCode];
}

return null;
}

/**
* Returns if the current tag has a parent or not.
*
Expand All @@ -192,4 +176,20 @@ public function isSynonym()
{
return $this->mainTagId > 0;
}

/**
* Function where list of properties are returned.
*
* Override to add dynamic properties
*
* @uses \parent::getProperties()
*
* @param array $dynamicProperties
*
* @return array
*/
protected function getProperties($dynamicProperties = array('keyword'))
{
return parent::getProperties($dynamicProperties);
}
}
14 changes: 7 additions & 7 deletions API/Repository/Values/Tags/TagStruct.php
Expand Up @@ -15,6 +15,13 @@ abstract class TagStruct extends ValueObject
*/
public $mainLanguageCode;

/**
* A global unique ID of the tag.
*
* @var string
*/
public $remoteId;

/**
* Tag keywords in the target languages
* Eg. array( "cro-HR" => "Hrvatska", "eng-GB" => "Croatia" ).
Expand All @@ -25,13 +32,6 @@ abstract class TagStruct extends ValueObject
*/
protected $keywords;

/**
* A global unique ID of the tag.
*
* @var string
*/
public $remoteId;

/**
* Returns keywords available in the struct.
*
Expand Down
8 changes: 4 additions & 4 deletions ApiLoader/LegacyTagsHandlerFactory.php
Expand Up @@ -3,12 +3,12 @@
namespace Netgen\TagsBundle\ApiLoader;

use eZ\Publish\Core\Persistence\Database\DatabaseHandler;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Netgen\TagsBundle\Core\Persistence\Legacy\Tags\Handler;
use Netgen\TagsBundle\Core\Persistence\Legacy\Tags\Mapper;
use Netgen\TagsBundle\Core\Persistence\Legacy\Tags\Gateway\DoctrineDatabase;
use Netgen\TagsBundle\Core\Persistence\Legacy\Tags\Gateway\ExceptionConversion;
use Netgen\TagsBundle\Core\Persistence\Legacy\Tags\Handler;
use Netgen\TagsBundle\Core\Persistence\Legacy\Tags\Mapper;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class LegacyTagsHandlerFactory implements ContainerAwareInterface
{
Expand Down
2 changes: 1 addition & 1 deletion Controller/Admin/RelatedContentController.php
Expand Up @@ -35,7 +35,7 @@ public function relatedContentAction(Request $request, Tag $tag)
{
$this->denyAccessUnlessGranted('ez:tags:read');

$currentPage = (int)$request->query->get('page');
$currentPage = (int) $request->query->get('page');
$configResolver = $this->getConfigResolver();

$pager = $this->createPager(
Expand Down
6 changes: 3 additions & 3 deletions Controller/Admin/TagController.php
Expand Up @@ -5,6 +5,8 @@
use eZ\Publish\API\Repository\ContentTypeService;
use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use eZ\Publish\API\Repository\SearchService;
use eZ\Publish\API\Repository\Values\Content\Query;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Search\SearchHit;
use Netgen\TagsBundle\API\Repository\TagsService;
use Netgen\TagsBundle\API\Repository\Values\Content\Query\Criterion\TagId;
Expand All @@ -18,8 +20,6 @@
use Netgen\TagsBundle\Form\Type\TagUpdateType;
use Pagerfanta\Adapter\AdapterInterface;
use Symfony\Component\HttpFoundation\Request;
use eZ\Publish\API\Repository\Values\Content\Query;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use Symfony\Component\Translation\TranslatorInterface;

class TagController extends Controller
Expand Down Expand Up @@ -89,7 +89,7 @@ public function showTagAction(Request $request, Tag $tag = null)
if (!$tag instanceof Tag || !$tag->isSynonym()) {
$configResolver = $this->getConfigResolver();

$currentPage = (int)$request->query->get('page');
$currentPage = (int) $request->query->get('page');
$pager = $this->createPager(
$this->tagChildrenAdapter,
$currentPage,
Expand Down
2 changes: 1 addition & 1 deletion Core/FieldType/Tags/FormMapper.php
Expand Up @@ -2,9 +2,9 @@

namespace Netgen\TagsBundle\Core\FieldType\Tags;

use Netgen\TagsBundle\Form\Type\TagTreeType;
use EzSystems\RepositoryForms\Data\FieldDefinitionData;
use EzSystems\RepositoryForms\FieldType\FieldDefinitionFormMapperInterface;
use Netgen\TagsBundle\Form\Type\TagTreeType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
Expand Down
2 changes: 1 addition & 1 deletion Core/FieldType/Tags/SearchField.php
Expand Up @@ -2,9 +2,9 @@

namespace Netgen\TagsBundle\Core\FieldType\Tags;

use eZ\Publish\SPI\FieldType\Indexable;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition;
use eZ\Publish\SPI\FieldType\Indexable;
use eZ\Publish\SPI\Search;

class SearchField implements Indexable
Expand Down
2 changes: 1 addition & 1 deletion Core/FieldType/Tags/TagsStorage.php
Expand Up @@ -3,8 +3,8 @@
namespace Netgen\TagsBundle\Core\FieldType\Tags;

use eZ\Publish\Core\FieldType\GatewayBasedStorage;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;

/**
* Converter for Tags field type external storage.
Expand Down
4 changes: 2 additions & 2 deletions Core/FieldType/Tags/TagsStorage/Gateway.php
Expand Up @@ -2,9 +2,9 @@

namespace Netgen\TagsBundle\Core\FieldType\Tags\TagsStorage;

use eZ\Publish\SPI\Persistence\Content\VersionInfo;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\Core\FieldType\StorageGateway;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;

abstract class Gateway extends StorageGateway
{
Expand Down
54 changes: 27 additions & 27 deletions Core/FieldType/Tags/TagsStorage/Gateway/LegacyStorage.php
Expand Up @@ -2,13 +2,13 @@

namespace Netgen\TagsBundle\Core\FieldType\Tags\TagsStorage\Gateway;

use Netgen\TagsBundle\Core\FieldType\Tags\TagsStorage\Gateway;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
use eZ\Publish\Core\Persistence\Database\DatabaseHandler;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\Language\Handler as LanguageHandler;
use RuntimeException;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
use Netgen\TagsBundle\Core\FieldType\Tags\TagsStorage\Gateway;
use PDO;
use RuntimeException;

class LegacyStorage extends Gateway
{
Expand Down Expand Up @@ -58,22 +58,6 @@ public function setConnection($connection)
$this->connection = $connection;
}

/**
* Returns the active connection.
*
* @throws \RuntimeException if no connection has been set, yet
*
* @return \eZ\Publish\Core\Persistence\Database\DatabaseHandler
*/
protected function getConnection()
{
if ($this->connection === null) {
throw new RuntimeException('Missing database connection.');
}

return $this->connection;
}

/**
* Stores the tags in the database based on the given field data.
*
Expand Down Expand Up @@ -150,6 +134,22 @@ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds)
$query->prepare()->execute();
}

/**
* Returns the active connection.
*
* @throws \RuntimeException if no connection has been set, yet
*
* @return \eZ\Publish\Core\Persistence\Database\DatabaseHandler
*/
protected function getConnection()
{
if ($this->connection === null) {
throw new RuntimeException('Missing database connection.');
}

return $this->connection;
}

/**
* Returns the data for the given $fieldId and $versionNo.
*
Expand Down Expand Up @@ -217,18 +217,18 @@ protected function loadFieldData($fieldId, $versionNo)

$tagList = array();
foreach ($rows as $row) {
$tagId = (int)$row['eztags_id'];
$tagId = (int) $row['eztags_id'];
if (!isset($tagList[$tagId])) {
$tagList[$tagId] = array();
$tagList[$tagId]['id'] = (int)$row['eztags_id'];
$tagList[$tagId]['parent_id'] = (int)$row['eztags_parent_id'];
$tagList[$tagId]['main_tag_id'] = (int)$row['eztags_main_tag_id'];
$tagList[$tagId]['id'] = (int) $row['eztags_id'];
$tagList[$tagId]['parent_id'] = (int) $row['eztags_parent_id'];
$tagList[$tagId]['main_tag_id'] = (int) $row['eztags_main_tag_id'];
$tagList[$tagId]['keywords'] = array();
$tagList[$tagId]['depth'] = (int)$row['eztags_depth'];
$tagList[$tagId]['depth'] = (int) $row['eztags_depth'];
$tagList[$tagId]['path_string'] = $row['eztags_path_string'];
$tagList[$tagId]['modified'] = (int)$row['eztags_modified'];
$tagList[$tagId]['modified'] = (int) $row['eztags_modified'];
$tagList[$tagId]['remote_id'] = $row['eztags_remote_id'];
$tagList[$tagId]['always_available'] = ((int)$row['eztags_language_mask'] & 1) ? true : false;
$tagList[$tagId]['always_available'] = ((int) $row['eztags_language_mask'] & 1) ? true : false;
$tagList[$tagId]['main_language_code'] = $this->languageHandler->load($row['eztags_main_language_id'])->languageCode;
$tagList[$tagId]['language_codes'] = array();
}
Expand Down

0 comments on commit a6c3598

Please sign in to comment.