Skip to content

Commit

Permalink
Allow risky fixers
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Feb 8, 2017
1 parent a6c3598 commit 267ae9c
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 28 deletions.
10 changes: 5 additions & 5 deletions .php_cs
@@ -1,10 +1,10 @@
<?php

return PhpCsFixer\Config::create()
->setRiskyAllowed(false)
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
// '@Symfony:risky' => true,
'@Symfony:risky' => true,
'array_syntax' => array('syntax' => 'long'),
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
Expand All @@ -16,10 +16,10 @@ return PhpCsFixer\Config::create()
'phpdoc_align' => false,
'phpdoc_order' => true,
'phpdoc_no_alias_tag' => false,
// 'psr4' => true,
'psr4' => true,
'semicolon_after_instruction' => true,
// 'strict_comparison' => true,
// 'strict_param' => true,
'strict_comparison' => true,
'strict_param' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
2 changes: 1 addition & 1 deletion Controller/Admin/TagController.php
Expand Up @@ -501,7 +501,7 @@ public function translationAction(Request $request, Tag $tag)
} elseif ($request->request->has('UpdateMainTranslationButton')) {
$newMainTranslation = $request->request->get('MainLocale');

if (!in_array($newMainTranslation, $tag->languageCodes)) {
if (!in_array($newMainTranslation, $tag->languageCodes, true)) {
$this->addFlashMessage('errors', 'no_translation', array('%locale%', $newMainTranslation));
} else {
$tagUpdateStruct->mainLanguageCode = $newMainTranslation;
Expand Down
2 changes: 1 addition & 1 deletion Core/FieldType/Tags/TagsStorage/Gateway/LegacyStorage.php
Expand Up @@ -237,7 +237,7 @@ protected function loadFieldData($fieldId, $versionNo)
$tagList[$tagId]['keywords'][$row['eztags_keyword_locale']] = $row['eztags_keyword_keyword'];
}

if (!in_array(array($row['eztags_keyword_locale']), $tagList[$tagId]['language_codes'])) {
if (!in_array(array($row['eztags_keyword_locale']), $tagList[$tagId]['language_codes'], true)) {
$tagList[$tagId]['language_codes'][] = $row['eztags_keyword_locale'];
}
}
Expand Down
2 changes: 1 addition & 1 deletion Core/FieldType/Tags/Type.php
Expand Up @@ -223,7 +223,7 @@ public function fromPersistenceValue(FieldValue $fieldValue)
*/
public function isEmptyValue(SPIValue $value)
{
return $value === null || $value->tags == $this->getEmptyValue()->tags;
return $value === null || $value->tags === $this->getEmptyValue()->tags;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion Core/Limitation/TagLimitationType.php
Expand Up @@ -141,7 +141,14 @@ public function evaluate(APILimitationValue $value, UserReference $currentUser,
return false;
}

return in_array($object->id, $value->limitationValues);
$limitationValues = array_map(
function ($value) {
return (int) $value;
},
$value->limitationValues
);

return in_array($object->id, $limitationValues, true);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Core/Pagination/Pagerfanta/View/TagsAdminView.php
Expand Up @@ -136,8 +136,8 @@ protected function calculateStartAndEndPage()
$endPage = $nbPages;
}

$this->startPage = $startPage;
$this->endPage = $endPage;
$this->startPage = (int) $startPage;
$this->endPage = (int) $endPage;
}

/**
Expand Down Expand Up @@ -184,7 +184,7 @@ protected function getPages()
$pages['first_page'] = $this->startPage > 1 ? $this->generateUrl(1) : false;
$pages['mobile_first_page'] = $this->pagerfanta->getCurrentPage() > 2 ? $this->generateUrl(1) : false;

$pages['second_page'] = $this->startPage == 3 ? $this->generateUrl(2) : false;
$pages['second_page'] = $this->startPage === 3 ? $this->generateUrl(2) : false;

$pages['separator_before'] = $this->startPage > 3 ? true : false;

Expand All @@ -197,7 +197,7 @@ protected function getPages()

$pages['separator_after'] = $this->endPage < $this->pagerfanta->getNbPages() - 2 ? true : false;

$pages['second_to_last_page'] = $this->endPage == $this->pagerfanta->getNbPages() - 2 ?
$pages['second_to_last_page'] = $this->endPage === $this->pagerfanta->getNbPages() - 2 ?
$this->generateUrl($this->pagerfanta->getNbPages() - 1) :
false;

Expand Down
2 changes: 1 addition & 1 deletion Core/Persistence/Legacy/Tags/Gateway/DoctrineDatabase.php
Expand Up @@ -921,7 +921,7 @@ public function moveSubtree(array $sourceTagData, array $destinationParentTagDat
);

$newParentId = $row['parent_id'];
if ($row['path_string'] === $sourceTagData['path_string'] || $row['main_tag_id'] == $sourceTagData['id']) {
if ($row['path_string'] === $sourceTagData['path_string'] || (int) $row['main_tag_id'] === (int) $sourceTagData['id']) {
$newParentId = (int) implode('', array_slice(explode('/', $newPathString), -3, 1));
}

Expand Down
2 changes: 1 addition & 1 deletion Core/REST/Server/Controller/Tags.php
Expand Up @@ -76,7 +76,7 @@ public function loadTag($tagPath)
$this->extractTagIdFromPath($tagPath)
);

if (trim($tag->pathString, '/') != $tagPath) {
if (trim($tag->pathString, '/') !== $tagPath) {
throw new Exceptions\NotFoundException(
"Could not find tag with path string $tagPath"
);
Expand Down
8 changes: 4 additions & 4 deletions Core/Repository/TagsService.php
Expand Up @@ -826,9 +826,9 @@ public function copySubtree(Tag $tag, Tag $targetParentTag = null)
throw new InvalidArgumentException('tag', 'Source tag is a synonym');
}

if (!$targetParentTag instanceof Tag && $tag->parentTagId == 0) {
if (!$targetParentTag instanceof Tag && $tag->parentTagId === 0) {
throw new InvalidArgumentException('targetParentTag', 'Tag is already located at the root of the tree');
} elseif ($targetParentTag instanceof Tag && $tag->parentTagId == $targetParentTag->id) {
} elseif ($targetParentTag instanceof Tag && $tag->parentTagId === $targetParentTag->id) {
throw new InvalidArgumentException('targetParentTag', 'Target parent tag is already the parent of the given tag');
}

Expand Down Expand Up @@ -887,9 +887,9 @@ public function moveSubtree(Tag $tag, Tag $targetParentTag = null)
throw new InvalidArgumentException('tag', 'Source tag is a synonym');
}

if (!$targetParentTag instanceof Tag && $tag->parentTagId == 0) {
if (!$targetParentTag instanceof Tag && $tag->parentTagId === 0) {
throw new InvalidArgumentException('targetParentTag', 'Tag is already located at the root of the tree');
} elseif ($targetParentTag instanceof Tag && $tag->parentTagId == $targetParentTag->id) {
} elseif ($targetParentTag instanceof Tag && $tag->parentTagId === $targetParentTag->id) {
throw new InvalidArgumentException('targetParentTag', 'Target parent tag is already the parent of the given tag');
}

Expand Down
Expand Up @@ -107,7 +107,7 @@ public function handle(CriteriaConverter $converter, SelectQuery $query, Criteri
}
}

if ($criterion->operator == Criterion\Operator::LIKE) {
if ($criterion->operator === Criterion\Operator::LIKE) {
$subSelect->where(
$subSelect->expr->like(
$this->dbHandler->quoteColumn('keyword', 'eztags_keyword'),
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/NetgenTagsExtension.php
Expand Up @@ -49,11 +49,11 @@ public function load(array $configs, ContainerBuilder $container)

$activatedBundles = array_keys($container->getParameter('kernel.bundles'));

if (in_array('EzSystemsEzPlatformSolrSearchEngineBundle', $activatedBundles)) {
if (in_array('EzSystemsEzPlatformSolrSearchEngineBundle', $activatedBundles, true)) {
$loader->load('storage_engines/solr/criterion_visitors.yml');
}

if (in_array('EzPublishLegacySearchEngineBundle', $activatedBundles)) {
if (in_array('EzPublishLegacySearchEngineBundle', $activatedBundles, true)) {
$loader->load('storage_engines/legacy/search_query_handlers.yml');
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Core/FieldType/TagsTest.php
Expand Up @@ -36,7 +36,7 @@ class TagsTest extends FieldTypeTest
*/
public function getTagsServiceLoadTagValues($tagId)
{
if ($tagId < 0 || $tagId == PHP_INT_MAX) {
if ($tagId < 0 || $tagId === PHP_INT_MAX) {
throw new NotFoundException('tag', $tagId);
}

Expand Down
1 change: 1 addition & 0 deletions Tests/Core/Limitation/TagLimitationTypeTest.php
Expand Up @@ -314,6 +314,7 @@ public function providerForTestEvaluate()
/**
* @depends testConstruct
* @dataProvider providerForTestEvaluate
*
* @param mixed $expected
*/
public function testEvaluate(TagLimitation $limitation, ValueObject $object, $expected, TagLimitationType $limitationType)
Expand Down
5 changes: 3 additions & 2 deletions Tests/Core/Persistence/Legacy/Content/LanguageHandlerMock.php
Expand Up @@ -71,8 +71,9 @@ public function update(Language $struct)
*/
public function load($id)
{
$id = (int) $id;
foreach ($this->languages as $language) {
if ($language->id == $id) {
if ($language->id === $id) {
return $language;
}
}
Expand All @@ -91,7 +92,7 @@ public function load($id)
public function loadByLanguageCode($languageCode)
{
foreach ($this->languages as $language) {
if ($language->languageCode == $languageCode) {
if ($language->languageCode === $languageCode) {
return $language;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Core/Repository/Service/Integration/TagsBase.php
Expand Up @@ -90,10 +90,10 @@ public function testIsPropertySet()
{
$tag = new Tag();
$value = isset($tag->notDefined);
$this->assertEquals(false, $value);
$this->assertFalse($value);

$value = isset($tag->id);
$this->assertEquals(true, $value);
$this->assertTrue($value);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion View/Builder/ParametersFilter/CurrentPage.php
Expand Up @@ -32,7 +32,7 @@ public function addCurrentPage(FilterViewBuilderParametersEvent $event)
$parameterBag = $event->getParameters();

$route = $parameterBag->get('_route');
if (!in_array($route, array(TagRouter::TAG_URL_ROUTE_NAME, TagUrlGenerator::INTERNAL_TAG_ROUTE))) {
if (!in_array($route, array(TagRouter::TAG_URL_ROUTE_NAME, TagUrlGenerator::INTERNAL_TAG_ROUTE), true)) {
return;
}

Expand Down

0 comments on commit 267ae9c

Please sign in to comment.