diff --git a/.editorconfig b/.editorconfig index abe48c71..dca0534c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ charset = utf-8 insert_final_newline = true trim_trailing_whitespace = true -[*.{yml,twig,php}] +[*.{yaml,yml,twig,php}] indent_size = 4 [*.{js,json,scss,css}] diff --git a/.php_cs.dist b/.php_cs.dist index c4875241..bc32a66b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -43,10 +43,10 @@ $rules = [ '@PHP71Migration:risky' => true, 'compact_nullable_typehint' => true, 'void_return' => null, - // To be tested before insertion: -// 'strict_comparison' => true, -// 'strict_param' => true, -// 'php_unit_strict' => true, + 'static_lambda' => true, + 'strict_comparison' => true, + 'strict_param' => true, + 'php_unit_strict' => true, ]; diff --git a/.travis.yml b/.travis.yml index 9ef15d5a..fa94f548 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,7 @@ php: - '7.3' - nightly -sudo: false -dist: trusty +dist: xenial addons: apt: @@ -31,7 +30,7 @@ cache: env: global: - PATH="$HOME/.local/bin:$PATH" - - SYMFONY_DEPRECATIONS_HELPER=weak + - SYMFONY_DEPRECATIONS_HELPER=weak_vendors - TARGET=test - UPSTREAM_URL=https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle.git - PHPUNIT_VERSION=7 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef98ec92..f7656543 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -173,7 +173,7 @@ your work, please do another PR for that. In some rare cases, you might be forced to do it on the same PR. In this kind of situation, please add a comment on your PR explaining why you feel it is the case. -#### The Change log +#### The Changelog For each PR, a change log must be provided. @@ -271,7 +271,7 @@ For class definitions, methods (or first level functions) and properties, use th ```php /** - * @deprecated since 42.x, to be removed in 43.0. Use Shiny\New\ClassOfTheMonth instead. + * @deprecated since sonata-project/foo-lib 42.x, to be removed in 43.0. Use Shiny\New\ClassOfTheMonth instead. */ final class IAmOldAndUseless { @@ -280,12 +280,12 @@ final class IAmOldAndUseless final class StillUsedClass { /** - * @deprecated since 42.x, to be removed in 43.0. + * @deprecated since sonata-project/foo-lib 42.x, to be removed in 43.0. */ public $butNotThisProperty; /** - * @deprecated since 42.x, to be removed in 43.0. + * @deprecated since sonata-project/foo-lib 42.x, to be removed in 43.0. */ public function iAmBatman() { @@ -299,7 +299,7 @@ If the deprecated thing is a service, you **MUST** specify it on the service def ```xml - The "%service_id%" service is deprecated since 42.x and will be removed in 43.0. + The "%service_id%" service is deprecated since sonata-project/bar-bundle 42.x and will be removed in 43.0. ``` @@ -311,7 +311,7 @@ For everything else, not managed by the `@deprecated` tag, you **MUST** trigger setDefaults([ - 'template' => function (Options $options, $value) { + 'template' => static function (Options $options, $value) { return $value ?: '@SonataDoctrinePHPCRAdmin/Block/tree.html.twig'; }, - 'id' => function (Options $options, $value) { + 'id' => static function (Options $options, $value) { return $value ?: '/'; }, - 'selected' => function (Options $options, $value) { + 'selected' => static function (Options $options, $value) { return $value ?: null; }, 'routing_defaults' => function (Options $options, $value) { diff --git a/src/Builder/DatagridBuilder.php b/src/Builder/DatagridBuilder.php index d84fd1a1..ad5337e8 100644 --- a/src/Builder/DatagridBuilder.php +++ b/src/Builder/DatagridBuilder.php @@ -103,7 +103,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter if (isset($metadata->mappings[$fieldDescription->getName()])) { $fieldDescription->setFieldMapping($metadata->mappings[$fieldDescription->getName()]); - if ('string' == $metadata->mappings[$fieldDescription->getName()]['type']) { + if ('string' === $metadata->mappings[$fieldDescription->getName()]['type']) { $fieldDescription->setOption('global_search', $fieldDescription->getOption('global_search', true)); // always search on string field only } } @@ -125,7 +125,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter */ public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin) { - if (null == $type) { + if (null === $type) { $guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager()); $type = $guessType->getType(); $fieldDescription->setType($type); diff --git a/src/Builder/FormContractor.php b/src/Builder/FormContractor.php index 2c05de1b..9de63508 100644 --- a/src/Builder/FormContractor.php +++ b/src/Builder/FormContractor.php @@ -79,7 +79,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter 'referrers', ]; - if ($metadata && $metadata->hasAssociation($fieldDescription->getName()) && \in_array($fieldDescription->getMappingType(), $mappingTypes)) { + if ($metadata && $metadata->hasAssociation($fieldDescription->getName()) && \in_array($fieldDescription->getMappingType(), $mappingTypes, true)) { $admin->attachAdminClass($fieldDescription); } } diff --git a/src/Builder/ListBuilder.php b/src/Builder/ListBuilder.php index 7434450e..22a2a3ac 100644 --- a/src/Builder/ListBuilder.php +++ b/src/Builder/ListBuilder.php @@ -56,7 +56,7 @@ public function getBaseList(array $options = []) */ public function buildField($type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin) { - if (null == $type) { + if (null === $type) { $guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager()); $fieldDescription->setType($guessType instanceof TypeGuess ? $guessType->getType() : null); } else { @@ -84,7 +84,7 @@ public function addField(FieldDescriptionCollection $list, $type, FieldDescripti */ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription) { - if ('_action' == $fieldDescription->getName() || 'actions' === $fieldDescription->getType()) { + if ('_action' === $fieldDescription->getName() || 'actions' === $fieldDescription->getType()) { $this->buildActionFieldDescription($fieldDescription); } @@ -163,19 +163,19 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter if (!$fieldDescription->getTemplate()) { $fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType())); - if (ClassMetadata::MANY_TO_ONE == $fieldDescription->getMappingType()) { + if (ClassMetadata::MANY_TO_ONE === $fieldDescription->getMappingType()) { $fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_many_to_one.html.twig'); } - if (ClassMetadata::MANY_TO_MANY == $fieldDescription->getMappingType()) { + if (ClassMetadata::MANY_TO_MANY === $fieldDescription->getMappingType()) { $fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_many_to_many.html.twig'); } - if ('child' == $fieldDescription->getMappingType() || 'parent' == $fieldDescription->getMappingType()) { + if ('child' === $fieldDescription->getMappingType() || 'parent' === $fieldDescription->getMappingType()) { $fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_one_to_one.html.twig'); } - if ('children' == $fieldDescription->getMappingType() || 'referrers' == $fieldDescription->getMappingType()) { + if ('children' === $fieldDescription->getMappingType() || 'referrers' === $fieldDescription->getMappingType()) { $fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_one_to_many.html.twig'); } } diff --git a/src/Builder/ShowBuilder.php b/src/Builder/ShowBuilder.php index 8690a8a7..3ac4bd24 100644 --- a/src/Builder/ShowBuilder.php +++ b/src/Builder/ShowBuilder.php @@ -55,7 +55,7 @@ public function getBaseList(array $options = []) */ public function addField(FieldDescriptionCollection $list, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin) { - if (null == $type) { + if (null === $type) { $guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager()); $fieldDescription->setType($guessType->getType()); } else { @@ -105,11 +105,11 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter if (!$fieldDescription->getTemplate()) { $fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType())); - if (ClassMetadata::MANY_TO_ONE == $fieldDescription->getMappingType()) { + if (ClassMetadata::MANY_TO_ONE === $fieldDescription->getMappingType()) { $fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/show_many_to_one.html.twig'); } - if (ClassMetadata::MANY_TO_MANY == $fieldDescription->getMappingType()) { + if (ClassMetadata::MANY_TO_MANY === $fieldDescription->getMappingType()) { $fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/show_many_to_many.html.twig'); } } diff --git a/src/Controller/AutocompleteController.php b/src/Controller/AutocompleteController.php index 821e73c6..586c4154 100644 --- a/src/Controller/AutocompleteController.php +++ b/src/Controller/AutocompleteController.php @@ -110,7 +110,7 @@ public function autoCompleteAction(Request $request) } //did we max out x+1 - $more = (\count($results) == $itemsPerPage + 1); + $more = (\count($results) === $itemsPerPage + 1); $method = $request->get('_method_name'); $items = []; diff --git a/src/Controller/TreeController.php b/src/Controller/TreeController.php index f30a5b40..ab8b619a 100644 --- a/src/Controller/TreeController.php +++ b/src/Controller/TreeController.php @@ -104,18 +104,18 @@ public function reorderAction(Request $request) return new JsonResponse(['Parameters parent, dropped and target has to be set to reorder.'], Response::HTTP_BAD_REQUEST); } - if (\in_array($position, ['over', 'child'])) { + if (\in_array($position, ['over', 'child'], true)) { return new JsonResponse(['Can not reorder when dropping into a collection.'], Response::HTTP_BAD_REQUEST); } - $before = 'before' == $position; + $before = 'before' === $position; $parentNode = $this->session->getNode($parentPath); $targetName = PathHelper::getNodeName($targetPath); if (!$before) { $nodesIterator = $parentNode->getNodes(); $nodesIterator->rewind(); while ($nodesIterator->valid()) { - if ($nodesIterator->key() == $targetName) { + if ($nodesIterator->key() === $targetName) { break; } $nodesIterator->next(); diff --git a/src/Datagrid/Pager.php b/src/Datagrid/Pager.php index e13e07d4..4307c7fd 100644 --- a/src/Datagrid/Pager.php +++ b/src/Datagrid/Pager.php @@ -61,7 +61,7 @@ public function init() $this->resetIterator(); $this->setNbResults($this->computeNbResult()); - if (0 == $this->getPage() || 0 == $this->getMaxPerPage() || 0 == $this->getNbResults()) { + if (0 === $this->getPage() || 0 === $this->getMaxPerPage() || 0 === $this->getNbResults()) { $this->setLastPage(0); $this->getQuery()->setFirstResult(0); $this->getQuery()->setMaxResults(0); diff --git a/src/Datagrid/ProxyQuery.php b/src/Datagrid/ProxyQuery.php index a519eaed..4e0db200 100644 --- a/src/Datagrid/ProxyQuery.php +++ b/src/Datagrid/ProxyQuery.php @@ -187,7 +187,7 @@ public function getSortBy() */ public function setSortOrder($sortOrder) { - if (!\in_array($sortOrder, ['ASC', 'DESC'])) { + if (!\in_array($sortOrder, ['ASC', 'DESC'], true)) { throw new \InvalidArgumentException(sprintf('The parameter $sortOrder must be one of "ASC" or "DESC", got "%s"', $sortOrder)); } $this->sortOrder = $sortOrder; diff --git a/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php b/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php index cc8927b4..fc7cea9e 100644 --- a/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php @@ -29,7 +29,7 @@ public function process(ContainerBuilder $container) { $settings = $this->fixSettings($container); foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) { - if (!isset($attributes[0]['manager_type']) || 'doctrine_phpcr' != $attributes[0]['manager_type']) { + if (!isset($attributes[0]['manager_type']) || 'doctrine_phpcr' !== $attributes[0]['manager_type']) { continue; } @@ -60,7 +60,7 @@ protected function fixSettings(ContainerBuilder $container) $settings = false; $methods = $pool->getMethodCalls(); foreach ($methods as $pos => $calls) { - if ('__hack_doctrine_phpcr__' == $calls[0]) { + if ('__hack_doctrine_phpcr__' === $calls[0]) { $settings = $calls[1]; break; diff --git a/src/Filter/BooleanFilter.php b/src/Filter/BooleanFilter.php index 788fae43..ca5775e0 100644 --- a/src/Filter/BooleanFilter.php +++ b/src/Filter/BooleanFilter.php @@ -33,7 +33,7 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) } $where = $this->getWhere($proxyQuery); - $where->eq()->field('a.'.$field)->literal(BooleanType::TYPE_YES == $data['value'] ? true : false); + $where->eq()->field('a.'.$field)->literal(BooleanType::TYPE_YES === $data['value'] ? true : false); // filter is active as we have now modified the query $this->active = true; diff --git a/src/Filter/ChoiceFilter.php b/src/Filter/ChoiceFilter.php index fedf15ed..597558e1 100644 --- a/src/Filter/ChoiceFilter.php +++ b/src/Filter/ChoiceFilter.php @@ -48,11 +48,11 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) $andX = $this->getWhere($proxyQuery)->andX(); foreach ($values as $value) { - if (ChoiceType::TYPE_NOT_CONTAINS == $type) { + if (ChoiceType::TYPE_NOT_CONTAINS === $type) { $andX->not()->like()->field('a.'.$field)->literal('%'.$value.'%'); - } elseif (ChoiceType::TYPE_CONTAINS == $type) { + } elseif (ChoiceType::TYPE_CONTAINS === $type) { $andX->like()->field('a.'.$field)->literal('%'.$value.'%'); - } elseif (ChoiceType::TYPE_EQUAL == $type) { + } elseif (ChoiceType::TYPE_EQUAL === $type) { $andX->like()->field('a.'.$field)->literal($value); } } diff --git a/src/Filter/Filter.php b/src/Filter/Filter.php index ecb753d0..d0e5fc40 100644 --- a/src/Filter/Filter.php +++ b/src/Filter/Filter.php @@ -49,7 +49,7 @@ public function isActive() protected function getWhere(ProxyQuery $proxy) { $queryBuilder = $proxy->getQueryBuilder(); - if (self::CONDITION_OR == $this->getCondition()) { + if (self::CONDITION_OR === $this->getCondition()) { return $queryBuilder->orWhere(); } diff --git a/src/Filter/NodeNameFilter.php b/src/Filter/NodeNameFilter.php index ee3aa01c..fcb65bfe 100644 --- a/src/Filter/NodeNameFilter.php +++ b/src/Filter/NodeNameFilter.php @@ -30,7 +30,7 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) $data['value'] = trim((string) $data['value']); $data['type'] = empty($data['type']) ? ChoiceType::TYPE_CONTAINS : $data['type']; - if (0 == \strlen($data['value'])) { + if (0 === \strlen($data['value'])) { return; } diff --git a/src/Filter/StringFilter.php b/src/Filter/StringFilter.php index d1d7776e..17e29f10 100644 --- a/src/Filter/StringFilter.php +++ b/src/Filter/StringFilter.php @@ -30,7 +30,7 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) $value = trim((string) $data['value']); $data['type'] = empty($data['type']) ? ChoiceType::TYPE_CONTAINS : $data['type']; - if (0 == \strlen($value)) { + if (0 === \strlen($value)) { return; } diff --git a/src/Form/Extension/CollectionTypeExtension.php b/src/Form/Extension/CollectionTypeExtension.php index f02cd6b0..08a20679 100644 --- a/src/Form/Extension/CollectionTypeExtension.php +++ b/src/Form/Extension/CollectionTypeExtension.php @@ -29,7 +29,7 @@ class CollectionTypeExtension extends AbstractTypeExtension */ public function buildForm(FormBuilderInterface $builder, array $options) { - if ('doctrine_phpcr' != $options['sonata_field_description']->getAdmin()->getManagerType() || !$options['sonata_field_description']->getOption('sortable')) { + if ('doctrine_phpcr' !== $options['sonata_field_description']->getAdmin()->getManagerType() || !$options['sonata_field_description']->getOption('sortable')) { return; } $listener = new CollectionOrderListener($options['sonata_field_description']->getName()); diff --git a/src/Form/Type/TreeModelType.php b/src/Form/Type/TreeModelType.php index 5feb7751..b0eeab9c 100644 --- a/src/Form/Type/TreeModelType.php +++ b/src/Form/Type/TreeModelType.php @@ -88,7 +88,7 @@ public function configureOptions(OptionsResolver $resolver) 'parent' => 'choice', 'repository_name' => 'default', 'preferred_choices' => [], - 'choice_list' => function (Options $options, $previousValue) { + 'choice_list' => static function (Options $options, $previousValue) { return new ModelChoiceList( $options['model_manager'], $options['class'], diff --git a/src/Model/ModelManager.php b/src/Model/ModelManager.php index 840facb7..3151d955 100644 --- a/src/Model/ModelManager.php +++ b/src/Model/ModelManager.php @@ -347,7 +347,7 @@ public function batchDelete($class, ProxyQueryInterface $queryProxy) foreach ($res as $object) { $this->dm->remove($object); - if (0 == (++$i % 20)) { + if (0 === (++$i % 20)) { $this->dm->flush(); $this->dm->clear(); } @@ -377,8 +377,8 @@ public function getSortParameters(FieldDescriptionInterface $fieldDescription, D { $values = $datagrid->getValues(); - if ($fieldDescription->getName() == $values['_sort_by']->getName()) { - if ('ASC' == $values['_sort_order']) { + if ($fieldDescription->getName() === $values['_sort_by']->getName()) { + if ('ASC' === $values['_sort_order']) { $values['_sort_order'] = 'DESC'; } else { $values['_sort_order'] = 'ASC'; diff --git a/tests/Unit/Datagrid/PagerTest.php b/tests/Unit/Datagrid/PagerTest.php index 2f1192fb..5b094b32 100644 --- a/tests/Unit/Datagrid/PagerTest.php +++ b/tests/Unit/Datagrid/PagerTest.php @@ -45,7 +45,7 @@ public function testInitNumPages(): void $this->pager->setQuery($this->proxyQuery); $this->pager->init(); - $this->assertEquals(2, $this->pager->getLastPage()); + $this->assertSame(2, $this->pager->getLastPage()); } public function testInitOffset(): void @@ -68,7 +68,7 @@ public function testInitOffset(): void $this->pager->setPage(2); $this->pager->init(); - $this->assertEquals(2, $this->pager->getLastPage()); + $this->assertSame(2, $this->pager->getLastPage()); } public function testNoPagesPerConfig(): void @@ -92,7 +92,7 @@ public function testNoPagesPerConfig(): void $this->pager->setMaxPerPage(0); $this->pager->init(); - $this->assertEquals(0, $this->pager->getLastPage()); + $this->assertSame(0, $this->pager->getLastPage()); } public function testNoPagesForNoResults(): void diff --git a/tests/Unit/Datagrid/ProxyQueryTest.php b/tests/Unit/Datagrid/ProxyQueryTest.php index d6ad6789..6ec7938f 100644 --- a/tests/Unit/Datagrid/ProxyQueryTest.php +++ b/tests/Unit/Datagrid/ProxyQueryTest.php @@ -47,13 +47,13 @@ public function testConstructor(): void public function testSetSortBy(): void { $this->pq->setSortBy([], ['fieldName' => 'field']); - $this->assertEquals('field', $this->pq->getSortBy()); + $this->assertSame('field', $this->pq->getSortBy()); } public function testSetSortOrder(): void { $this->pq->setSortOrder('ASC'); - $this->assertEquals('ASC', $this->pq->getSortOrder()); + $this->assertSame('ASC', $this->pq->getSortOrder()); } public function testSetSortOrderInvalid(): void @@ -61,7 +61,7 @@ public function testSetSortOrderInvalid(): void $this->expectException(\InvalidArgumentException::class); $this->pq->setSortOrder('SOME_ORDER'); - $this->assertEquals('SOME_ORDER', $this->pq->getSortOrder()); + $this->assertSame('SOME_ORDER', $this->pq->getSortOrder()); } public function testSetFirstResult(): void @@ -108,13 +108,13 @@ public function testExecute(): void ->will($this->returnValue('test')); $res = $this->pq->execute(); - $this->assertEquals('test', $res); + $this->assertSame('test', $res); } public function testGetAndSetDocumentManager(): void { $dm = $this->createMock(DocumentManager::class); $this->pq->setDocumentManager($dm); - $this->assertEquals($dm, $this->pq->getDocumentManager()); + $this->assertSame($dm, $this->pq->getDocumentManager()); } } diff --git a/tests/Unit/Filter/BooleanFilterTest.php b/tests/Unit/Filter/BooleanFilterTest.php index 28cbd773..cb20e74c 100644 --- a/tests/Unit/Filter/BooleanFilterTest.php +++ b/tests/Unit/Filter/BooleanFilterTest.php @@ -76,9 +76,9 @@ public function testFilterSwitch($operatorMethod, $value, $expectedValue): void $opDynamic = $this->qbTester->getNode('where.constraint.operand_dynamic'); $opStatic = $this->qbTester->getNode('where.constraint.operand_static'); - $this->assertEquals('a', $opDynamic->getAlias()); - $this->assertEquals('somefield', $opDynamic->getField()); - $this->assertEquals($expectedValue, $opStatic->getValue()); + $this->assertSame('a', $opDynamic->getAlias()); + $this->assertSame('somefield', $opDynamic->getField()); + $this->assertSame($expectedValue, $opStatic->getValue()); $this->assertTrue($this->filter->isActive()); } diff --git a/tests/Unit/Filter/CallBackFilterTest.php b/tests/Unit/Filter/CallBackFilterTest.php index 786267ea..8eeb8f47 100644 --- a/tests/Unit/Filter/CallBackFilterTest.php +++ b/tests/Unit/Filter/CallBackFilterTest.php @@ -21,7 +21,7 @@ class CallBackFilterTest extends BaseTestCase public function testFilterNullData(): void { $filter = new CallbackFilter(); - $filter->initialize('field_name', ['callback' => function (): void { + $filter->initialize('field_name', ['callback' => static function (): void { }]); $res = $filter->filter($this->proxyQuery, null, 'somefield', null); $this->assertNull($res); @@ -32,7 +32,7 @@ public function testFilterEmptyArrayData(): void { $filter = new CallbackFilter(); - $filter->initialize('field_name', ['callback' => function (): void { + $filter->initialize('field_name', ['callback' => static function (): void { }]); $res = $filter->filter($this->proxyQuery, null, 'somefield', []); $this->assertNull($res); @@ -55,9 +55,9 @@ public function testFilterMethod(): void $opDynamic = $this->qbTester->getNode('where.constraint.operand_dynamic'); $opStatic = $this->qbTester->getNode('where.constraint.operand_static'); - $this->assertEquals('a', $opDynamic->getAlias()); - $this->assertEquals('somefield', $opDynamic->getField()); - $this->assertEquals('somevalue', $opStatic->getValue()); + $this->assertSame('a', $opDynamic->getAlias()); + $this->assertSame('somefield', $opDynamic->getField()); + $this->assertSame('somevalue', $opStatic->getValue()); $this->assertTrue($filter->isActive()); } @@ -78,7 +78,7 @@ public function testFilterClosure(): void $filter = new CallbackFilter(); $filter->initialize('field_name', [ - 'callback' => function (ProxyQueryInterface $proxyQuery, $alias, $field, $data) { + 'callback' => static function (ProxyQueryInterface $proxyQuery, $alias, $field, $data) { $queryBuilder = $proxyQuery->getQueryBuilder(); $queryBuilder->andWhere()->eq()->field('a.'.$field)->literal($data['value']); @@ -91,9 +91,9 @@ public function testFilterClosure(): void $opDynamic = $this->qbTester->getNode('where.constraint.operand_dynamic'); $opStatic = $this->qbTester->getNode('where.constraint.operand_static'); - $this->assertEquals('a', $opDynamic->getAlias()); - $this->assertEquals('somefield', $opDynamic->getField()); - $this->assertEquals('somevalue', $opStatic->getValue()); + $this->assertSame('a', $opDynamic->getAlias()); + $this->assertSame('somefield', $opDynamic->getField()); + $this->assertSame('somevalue', $opStatic->getValue()); $this->assertTrue($filter->isActive()); } diff --git a/tests/Unit/Filter/ChoiceFilterTest.php b/tests/Unit/Filter/ChoiceFilterTest.php index 791d1a7b..3799063b 100644 --- a/tests/Unit/Filter/ChoiceFilterTest.php +++ b/tests/Unit/Filter/ChoiceFilterTest.php @@ -275,11 +275,11 @@ public function testFilterMultipleSwitch($options): void $node = $this->qbTester->getNode($path); foreach ($methodAssertions as $methodName => $expectedValue) { $res = $node->$methodName(); - $this->assertEquals($expectedValue, $res); + $this->assertSame($expectedValue, $res); } } $this->assertTrue($this->filter->isActive()); - $this->assertEquals($options['qbNodeCount'], \count($this->qbTester->getAllNodes())); + $this->assertSame($options['qbNodeCount'], \count($this->qbTester->getAllNodes())); } } diff --git a/tests/Unit/Filter/DateFilterTest.php b/tests/Unit/Filter/DateFilterTest.php index 6d828c3c..a44bc084 100644 --- a/tests/Unit/Filter/DateFilterTest.php +++ b/tests/Unit/Filter/DateFilterTest.php @@ -61,7 +61,7 @@ public function testFilterSwitch($operatorMethod, $choiceType, $expectedValue = { $value = new \DateTime('2013/01/16 00:00:00'); - if ('__null__' == $expectedValue) { + if ('__null__' === $expectedValue) { $expectedValue = new \DateTime('2013/01/16 00:00:00'); } @@ -75,9 +75,9 @@ public function testFilterSwitch($operatorMethod, $choiceType, $expectedValue = $opDynamic = $this->qbTester->getNode('where.constraint.operand_dynamic'); $opStatic = $this->qbTester->getNode('where.constraint.operand_static'); - $this->assertEquals('a', $opDynamic->getAlias()); - $this->assertEquals('somefield', $opDynamic->getField()); - $this->assertEquals($expectedValue, $opStatic->getValue()); + $this->assertSame('a', $opDynamic->getAlias()); + $this->assertSame('somefield', $opDynamic->getField()); + $this->assertSame($expectedValue, $opStatic->getValue()); $this->assertTrue($this->filter->isActive()); } @@ -100,9 +100,9 @@ public function testFilterEquals(): void $opStatic = $this->qbTester->getNode( 'where.constraint.constraint.operand_static'); - $this->assertEquals('a', $opDynamic->getAlias()); - $this->assertEquals('somefield', $opDynamic->getField()); - $this->assertEquals($from, $opStatic->getValue()); + $this->assertSame('a', $opDynamic->getAlias()); + $this->assertSame('somefield', $opDynamic->getField()); + $this->assertSame($from, $opStatic->getValue()); // TO $opDynamic = $this->qbTester->getNode( @@ -110,9 +110,9 @@ public function testFilterEquals(): void $opStatic = $this->qbTester->getNode( 'where.constraint.constraint[1].operand_static'); - $this->assertEquals('a', $opDynamic->getAlias()); - $this->assertEquals('somefield', $opDynamic->getField()); - $this->assertEquals($to, $opStatic->getValue()); + $this->assertSame('a', $opDynamic->getAlias()); + $this->assertSame('somefield', $opDynamic->getField()); + $this->assertSame($to, $opStatic->getValue()); $this->assertTrue($this->filter->isActive()); } diff --git a/tests/Unit/Filter/NodeNameFilterTest.php b/tests/Unit/Filter/NodeNameFilterTest.php index 7545549e..616bccfa 100644 --- a/tests/Unit/Filter/NodeNameFilterTest.php +++ b/tests/Unit/Filter/NodeNameFilterTest.php @@ -85,8 +85,8 @@ public function testFilterSwitch($operatorMethod, $choiceType, $expectedValue = $localName = $this->qbTester->getNode('where.constraint.operand_dynamic'); $literal = $this->qbTester->getNode('where.constraint.operand_static'); - $this->assertEquals('a', $localName->getAlias()); - $this->assertEquals($expectedValue, $literal->getValue()); + $this->assertSame('a', $localName->getAlias()); + $this->assertSame($expectedValue, $literal->getValue()); $this->assertTrue($this->filter->isActive()); } diff --git a/tests/Unit/Filter/NumberFilterTest.php b/tests/Unit/Filter/NumberFilterTest.php index 68ee8b5d..e6601cbb 100644 --- a/tests/Unit/Filter/NumberFilterTest.php +++ b/tests/Unit/Filter/NumberFilterTest.php @@ -81,9 +81,9 @@ public function testFilterSwitch($operatorMethod, $choiceType, $expectedValue = $opDynamic = $this->qbTester->getNode('where.constraint.operand_dynamic'); $opStatic = $this->qbTester->getNode('where.constraint.operand_static'); - $this->assertEquals('a', $opDynamic->getAlias()); - $this->assertEquals('somefield', $opDynamic->getField()); - $this->assertEquals($expectedValue, $opStatic->getValue()); + $this->assertSame('a', $opDynamic->getAlias()); + $this->assertSame('somefield', $opDynamic->getField()); + $this->assertSame($expectedValue, $opStatic->getValue()); $this->assertTrue($this->filter->isActive()); } diff --git a/tests/Unit/Filter/StringFilterTest.php b/tests/Unit/Filter/StringFilterTest.php index 59b8c414..0b489e01 100644 --- a/tests/Unit/Filter/StringFilterTest.php +++ b/tests/Unit/Filter/StringFilterTest.php @@ -131,7 +131,7 @@ public function testFilterSwitch($choiceType, $assertPaths, $isLowerCase = false $node = $this->qbTester->getNode($path); foreach ($assertions as $methodName => $expectedValue) { $res = $node->$methodName(); - $this->assertEquals($expectedValue, $res); + $this->assertSame($expectedValue, $res); } } diff --git a/tests/Unit/Guesser/FilterTypeGuesserTest.php b/tests/Unit/Guesser/FilterTypeGuesserTest.php index 8ef872bb..14d4d084 100644 --- a/tests/Unit/Guesser/FilterTypeGuesserTest.php +++ b/tests/Unit/Guesser/FilterTypeGuesserTest.php @@ -68,7 +68,7 @@ public function testGuessType(): void $typeGuess->getOptions() ); - $this->assertEquals( + $this->assertSame( Guess::LOW_CONFIDENCE, $typeGuess->getConfidence() ); diff --git a/tests/WebTest/Admin/ContentAdminTest.php b/tests/WebTest/Admin/ContentAdminTest.php index bfc9875e..2b15d750 100644 --- a/tests/WebTest/Admin/ContentAdminTest.php +++ b/tests/WebTest/Admin/ContentAdminTest.php @@ -84,7 +84,7 @@ public function testContentCreate(): void $res = $this->client->getResponse(); // If we have a 302 redirect, then all is well - $this->assertEquals(302, $res->getStatusCode()); + $this->assertSame(302, $res->getStatusCode()); } public function testShowContent(): void