Skip to content

Commit c8587c5

Browse files
authored
BH-681: Fix various deprecations (#15238)
* BH-681: Fix various deprecations * BH-681: Composer update
1 parent 612342d commit c8587c5

File tree

16 files changed

+168
-270
lines changed

16 files changed

+168
-270
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@
150150
"squizlabs/php_codesniffer": "2.*",
151151
"friends-of-behat/symfony-extension": "^2.2",
152152
"liuggio/fastest": "1.8.*",
153-
"phpstan/phpstan": "^0.12.25",
154-
"phpstan/phpstan-symfony": "^0.12.6",
153+
"phpstan/phpstan": "^0.12.97",
154+
"phpstan/phpstan-symfony": "0.12.42",
155155
"league/flysystem-aws-s3-v3": "^1.0",
156156
"mcustiel/phiremock": "2.1.1",
157157
"phpstan/phpstan-webmozart-assert": "^0.12.7",

composer.lock

Lines changed: 95 additions & 93 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Akeneo/Channel/Bundle/Doctrine/Repository/InternalApi/ChannelRepository.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
*/
1616
class ChannelRepository extends EntityRepository implements DatagridRepositoryInterface
1717
{
18-
/**
19-
* @param EntityManager $em
20-
* @param string $class
21-
*/
22-
public function __construct(EntityManager $em, $class)
18+
public function __construct(EntityManager $em, string $class)
2319
{
2420
parent::__construct($em, $em->getClassMetadata($class));
2521
}
@@ -30,7 +26,7 @@ public function __construct(EntityManager $em, $class)
3026
public function createDatagridQueryBuilder()
3127
{
3228
$qb = $this->createQueryBuilder('c');
33-
$rootAlias = $qb->getRootAlias();
29+
$rootAlias = $qb->getRootAliases()[0];
3430

3531
$treeExpr = '(CASE WHEN ct.label IS NULL THEN category.code ELSE ct.label END)';
3632

src/Akeneo/Pim/Enrichment/Bundle/Filter/ProductValuesEditDataFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function acceptValue(AttributeInterface $attribute, $value, array $opt
139139
return false;
140140
}
141141

142-
if ($attribute->isLocaleSpecific() && !in_array($value['locale'], $attribute->getLocaleSpecificCodes())) {
142+
if ($attribute->isLocaleSpecific() && !in_array($value['locale'], $attribute->getAvailableLocaleCodes())) {
143143
return false;
144144
}
145145
}

src/Akeneo/Pim/Enrichment/Bundle/Form/Subscriber/FilterLocaleSpecificValueSubscriber.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Akeneo\Pim\Enrichment\Bundle\Form\Subscriber;
44

5+
use Akeneo\Pim\Structure\Component\Model\AttributeInterface;
56
use Akeneo\Tool\Component\StorageUtils\Repository\IdentifiableObjectRepositoryInterface;
67
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
78
use Symfony\Component\Form\FormEvent;
@@ -16,32 +17,23 @@
1617
*/
1718
class FilterLocaleSpecificValueSubscriber implements EventSubscriberInterface
1819
{
19-
/** @var IdentifiableObjectRepositoryInterface */
20-
protected $attributeRepository;
21-
22-
/** @var string $currentLocale */
23-
protected $currentLocale;
20+
protected IdentifiableObjectRepositoryInterface $attributeRepository;
21+
protected ?string $currentLocale;
2422

2523
public function __construct(?string $currentLocale, IdentifiableObjectRepositoryInterface $attributeRepository)
2624
{
2725
$this->currentLocale = $currentLocale;
2826
$this->attributeRepository = $attributeRepository;
2927
}
3028

31-
/**
32-
* @return array
33-
*/
34-
public static function getSubscribedEvents()
29+
public static function getSubscribedEvents(): array
3530
{
3631
return [
3732
FormEvents::PRE_SET_DATA => 'preSetData',
3833
];
3934
}
4035

41-
/**
42-
* @param FormEvent $event
43-
*/
44-
public function preSetData(FormEvent $event)
36+
public function preSetData(FormEvent $event): void
4537
{
4638
$data = $event->getData();
4739
$form = $event->getForm();
@@ -51,10 +43,11 @@ public function preSetData(FormEvent $event)
5143
}
5244

5345
foreach ($data as $name => $value) {
46+
/** @var AttributeInterface $attribute */
5447
$attribute = $this->attributeRepository->findOneByIdentifier($value->getAttributeCode());
5548

5649
if ($attribute->isLocaleSpecific()) {
57-
$availableCodes = $attribute->getLocaleSpecificCodes();
50+
$availableCodes = $attribute->getAvailableLocaleCodes();
5851
if (!in_array($this->currentLocale, $availableCodes)) {
5952
$form->remove($name);
6053
}

src/Akeneo/Pim/Enrichment/Component/Product/Connector/ArrayConverter/FlatToStandard/AttributeColumnInfoExtractor.php

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,13 @@ class AttributeColumnInfoExtractor
1818
const FIELD_SEPARATOR = '-';
1919
const UNIT_SEPARATOR = ' ';
2020

21-
/** @var IdentifiableObjectRepositoryInterface */
22-
protected $attributeRepository;
21+
protected IdentifiableObjectRepositoryInterface $attributeRepository;
22+
protected IdentifiableObjectRepositoryInterface $channelRepository;
23+
protected IdentifiableObjectRepositoryInterface $localeRepository;
24+
protected AssociationColumnsResolver $assoColumnResolver;
25+
protected array $fieldNameInfoCache;
26+
protected array $excludedFieldNames;
2327

24-
/** @var IdentifiableObjectRepositoryInterface */
25-
protected $channelRepository;
26-
27-
/** @var IdentifiableObjectRepositoryInterface */
28-
protected $localeRepository;
29-
30-
/** @var AssociationColumnsResolver */
31-
protected $assoColumnResolver;
32-
33-
/** @var array */
34-
protected $fieldNameInfoCache;
35-
36-
/** @var array */
37-
protected $excludedFieldNames;
38-
39-
/**
40-
* @param IdentifiableObjectRepositoryInterface $attributeRepository
41-
* @param IdentifiableObjectRepositoryInterface $channelRepository
42-
* @param IdentifiableObjectRepositoryInterface $localeRepository
43-
* @param AssociationColumnsResolver $assoColumnResolver
44-
*/
4528
public function __construct(
4629
IdentifiableObjectRepositoryInterface $attributeRepository,
4730
IdentifiableObjectRepositoryInterface $channelRepository,
@@ -71,10 +54,8 @@ public function __construct(
7154
* Return null if the field name does not match an attribute.
7255
*
7356
* @param string $fieldName
74-
*
75-
* @return array|null
7657
*/
77-
public function extractColumnInfo($fieldName)
58+
public function extractColumnInfo($fieldName): ?array
7859
{
7960
if (
8061
in_array($fieldName, $this->assoColumnResolver->resolveAssociationColumns()) ||
@@ -98,19 +79,14 @@ public function extractColumnInfo($fieldName)
9879
}
9980
}
10081

101-
return isset($this->fieldNameInfoCache[$fieldName]) ? $this->fieldNameInfoCache[$fieldName] : null;
82+
return $this->fieldNameInfoCache[$fieldName] ?? null;
10283
}
10384

10485
/**
10586
* Extract information from an attribute and exploded field name
10687
* This method is used from extractColumnInfo and can be redefine to add new rules
107-
*
108-
* @param AttributeInterface $attribute
109-
* @param array $explodedFieldName
110-
*
111-
* @return array
11288
*/
113-
protected function extractAttributeInfo(AttributeInterface $attribute, array $explodedFieldName)
89+
protected function extractAttributeInfo(AttributeInterface $attribute, array $explodedFieldName): array
11490
{
11591
array_shift($explodedFieldName);
11692

@@ -132,13 +108,9 @@ protected function extractAttributeInfo(AttributeInterface $attribute, array $ex
132108
/**
133109
* Check the consistency of the field with the attribute and it properties locale, scope, currency
134110
*
135-
* @param AttributeInterface $attribute
136-
* @param string $fieldName
137-
* @param array $explodedFieldName
138-
*
139111
* @throws \InvalidArgumentException
140112
*/
141-
protected function checkFieldNameTokens(AttributeInterface $attribute, $fieldName, array $explodedFieldName)
113+
protected function checkFieldNameTokens(AttributeInterface $attribute, string $fieldName, array $explodedFieldName)
142114
{
143115
$isLocalizable = $attribute->isLocalizable();
144116
$isScopable = $attribute->isScopable();
@@ -172,11 +144,9 @@ protected function checkFieldNameTokens(AttributeInterface $attribute, $fieldNam
172144
/**
173145
* Calculates the expected size of the field with the attribute and its properties locale, scope, etc.
174146
*
175-
* @param AttributeInterface $attribute
176-
*
177-
* @return int
147+
* @return int[]
178148
*/
179-
protected function calculateExpectedSize(AttributeInterface $attribute)
149+
protected function calculateExpectedSize(AttributeInterface $attribute): array
180150
{
181151
// the expected number of tokens in a field may vary,
182152
// - with the current price import, the currency can be optionally present in the header,
@@ -205,13 +175,9 @@ protected function calculateExpectedSize(AttributeInterface $attribute)
205175
/**
206176
* Check the consistency of the field with channel associated
207177
*
208-
* @param AttributeInterface $attribute
209-
* @param string $fieldName
210-
* @param array $attributeInfo
211-
*
212178
* @throws \InvalidArgumentException
213179
*/
214-
protected function checkFieldNameLocaleByChannel(AttributeInterface $attribute, $fieldName, array $attributeInfo)
180+
protected function checkFieldNameLocaleByChannel(AttributeInterface $attribute, string $fieldName, array $attributeInfo)
215181
{
216182
if ($attribute->isScopable() &&
217183
$attribute->isLocalizable() &&
@@ -236,15 +202,12 @@ protected function checkFieldNameLocaleByChannel(AttributeInterface $attribute,
236202

237203
/**
238204
* Check if provided locales for an locale specific attribute exist
239-
*
240-
* @param AttributeInterface $attribute
241-
* @param array $explodedFieldNames
242205
*/
243-
protected function checkForLocaleSpecificValue(AttributeInterface $attribute, array $explodedFieldNames)
206+
protected function checkForLocaleSpecificValue(AttributeInterface $attribute, array $explodedFieldNames): void
244207
{
245208
if ($attribute->isLocaleSpecific()) {
246209
$attributeInfo = $this->extractAttributeInfo($attribute, $explodedFieldNames);
247-
$availableLocales = $attribute->getLocaleSpecificCodes();
210+
$availableLocales = $attribute->getAvailableLocaleCodes();
248211
if (!in_array($explodedFieldNames[1], $availableLocales)) {
249212
throw new \LogicException(
250213
sprintf(

src/Akeneo/Pim/Enrichment/Component/Product/Connector/Processor/Normalization/ProductProcessor.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Akeneo\Pim\Enrichment\Component\Product\Model\ProductInterface;
88
use Akeneo\Pim\Enrichment\Component\Product\Model\ProductModelInterface;
99
use Akeneo\Pim\Enrichment\Component\Product\ValuesFiller\FillMissingValuesInterface;
10+
use Akeneo\Pim\Structure\Component\Model\AttributeInterface;
1011
use Akeneo\Pim\Structure\Component\Repository\AttributeRepositoryInterface;
1112
use Akeneo\Tool\Component\Batch\Item\ItemProcessorInterface;
1213
use Akeneo\Tool\Component\Batch\Job\JobParameters;
@@ -109,8 +110,10 @@ protected function filterLocaleSpecificAttributes(array $values): array
109110
$valuesToExport = [];
110111
$jobLocales = $this->stepExecution->getJobParameters()->get('filters')['structure']['locales'];
111112
foreach ($values as $code => $value) {
113+
/** @var AttributeInterface $attribute */
112114
$attribute = $this->attributeRepository->findOneByIdentifier($code);
113-
if (!$attribute->isLocaleSpecific() || !empty(array_intersect($jobLocales, $attribute->getLocaleSpecificCodes()))) {
115+
if (!$attribute->isLocaleSpecific()
116+
|| !empty(array_intersect($jobLocales, $attribute->getAvailableLocaleCodes()))) {
114117
$valuesToExport[$code] = $value;
115118
}
116119
}

src/Akeneo/Pim/Structure/.php_cd.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
// TIP-907: Functionnal problem we should not create empty associations
3232
'Akeneo\Pim\Enrichment\Component\Product\Model\EntityWithAssociationsInterface',
3333

34+
'Akeneo\Pim\Enrichment\Component\Product\Query\ProductQueryBuilderInterface',
35+
3436
// TIP-1024: Drop UserContext
3537
'Akeneo\UserManagement\Bundle\Context\UserContext',
3638
'Akeneo\UserManagement\Component\Model\UserInterface',

src/Akeneo/Pim/Structure/Bundle/Doctrine/ORM/Repository/InternalApi/AttributeRepository.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ class AttributeRepository extends EntityRepository implements
1717
TranslatedLabelsProviderInterface,
1818
DatagridRepositoryInterface
1919
{
20-
/** @var UserContext */
21-
protected $userContext;
20+
protected UserContext $userContext;
2221

23-
/**
24-
* @param UserContext $userContext
25-
* @param EntityManager $em
26-
* @param string $class
27-
*/
28-
public function __construct(UserContext $userContext, EntityManager $em, $class)
22+
public function __construct(UserContext $userContext, EntityManager $em, string $class)
2923
{
3024
parent::__construct($em, $em->getClassMetadata($class));
3125

@@ -73,7 +67,7 @@ public function findTranslatedLabels(array $options = [])
7367
public function createDatagridQueryBuilder()
7468
{
7569
$qb = $this->createQueryBuilder('a');
76-
$rootAlias = $qb->getRootAlias();
70+
$rootAlias = $qb->getRootAliases()[0];
7771

7872
$labelExpr = sprintf(
7973
'(CASE WHEN translation.label IS NULL THEN %s.code ELSE translation.label END)',

src/Akeneo/Pim/Structure/Bundle/Doctrine/ORM/Repository/InternalApi/FamilyRepository.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace Akeneo\Pim\Structure\Bundle\Doctrine\ORM\Repository\InternalApi;
44

5+
use Akeneo\Pim\Enrichment\Component\Product\Query\ProductQueryBuilderInterface;
56
use Akeneo\Platform\Bundle\UIBundle\Provider\TranslatedLabelsProviderInterface;
67
use Akeneo\UserManagement\Bundle\Context\UserContext;
78
use Doctrine\ORM\EntityManager;
89
use Doctrine\ORM\EntityRepository;
10+
use Doctrine\ORM\QueryBuilder;
911
use Oro\Bundle\PimDataGridBundle\Doctrine\ORM\Repository\DatagridRepositoryInterface;
1012
use Oro\Bundle\PimDataGridBundle\Doctrine\ORM\Repository\MassActionRepositoryInterface;
1113

@@ -19,15 +21,9 @@ class FamilyRepository extends EntityRepository implements
1921
DatagridRepositoryInterface,
2022
MassActionRepositoryInterface
2123
{
22-
/** @var UserContext */
23-
protected $userContext;
24+
protected UserContext $userContext;
2425

25-
/**
26-
* @param UserContext $userContext
27-
* @param EntityManager $em
28-
* @param string $class
29-
*/
30-
public function __construct(UserContext $userContext, EntityManager $em, $class)
26+
public function __construct(UserContext $userContext, EntityManager $em, string $class)
3127
{
3228
parent::__construct($em, $em->getClassMetadata($class));
3329

@@ -61,7 +57,7 @@ public function findTranslatedLabels(array $options = [])
6157
public function createDatagridQueryBuilder()
6258
{
6359
$qb = $this->createQueryBuilder('f');
64-
$rootAlias = $qb->getRootAlias();
60+
$rootAlias = $qb->getRootAliases()[0];
6561

6662
$labelExpr = sprintf(
6763
'(CASE WHEN translation.label IS NULL THEN %s.code ELSE translation.label END)',
@@ -82,11 +78,13 @@ public function createDatagridQueryBuilder()
8278

8379
/**
8480
* {@inheritdoc}
81+
*
82+
* @param QueryBuilder|ProductQueryBuilderInterface $qb
8583
*/
8684
public function applyMassActionParameters($qb, $inset, array $values)
8785
{
8886
if ($values) {
89-
$rootAlias = $qb->getRootAlias();
87+
$rootAlias = $qb->getRootAliases()[0];
9088
$valueWhereCondition =
9189
$inset
9290
? $qb->expr()->in($rootAlias, $values)

0 commit comments

Comments
 (0)