Skip to content

Commit 8aebc96

Browse files
committed
Allow SF6
1 parent b3377be commit 8aebc96

17 files changed

Lines changed: 75 additions & 81 deletions

File tree

composer.json

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,28 @@
44
"description": "Add barcodes to your products using this plugin",
55
"license": "MIT",
66
"require": {
7-
"php": ">=7.4",
8-
"doctrine/persistence": "^1.3 || ^2.0",
7+
"php": ">=8.1",
8+
"doctrine/persistence": "^1.3 || ^2.0 || ^3.0",
99
"setono/doctrine-orm-batcher-bundle": "^0.3.1",
10-
"sylius/sylius": "^1.3",
11-
"symfony/config": "^4.4 || ^5.4",
12-
"symfony/event-dispatcher": "^4.4 || ^5.4",
10+
"symfony/config": "^5.4 || ^6.4",
11+
"symfony/event-dispatcher": "^5.4 || ^6.4",
1312
"symfony/event-dispatcher-contracts": "^1.0 || ^2.0 || ^3.0",
14-
"symfony/messenger": "^4.4 || ^5.4",
15-
"thecodingmachine/safe": "^1.0",
13+
"symfony/messenger": "^5.4 || ^6.4",
1614
"violuke/php-barcodes": "^1.0"
1715
},
1816
"require-dev": {
19-
"behat/behat": "^3.4",
20-
"behat/mink": "^1.7@dev",
21-
"behat/mink-browserkit-driver": "^1.3",
22-
"behat/mink-extension": "^2.2",
23-
"behat/mink-selenium2-driver": "^1.3",
24-
"friends-of-behat/page-object-extension": "^0.3",
25-
"friends-of-behat/suite-settings-extension": "^1.0",
26-
"friends-of-behat/symfony-extension": "^2.0",
27-
"friends-of-behat/variadic-extension": "^1.1",
28-
"lakion/mink-debug-extension": "^1.2.3",
29-
"phpspec/phpspec": "^6.1",
30-
"phpunit/phpunit": "^8.3",
31-
"roave/security-advisories": "dev-latest",
32-
"sensiolabs/security-checker": "^5.0",
17+
"phpspec/phpspec": "^7.5",
18+
"phpspec/prophecy-phpunit": "^2.3",
19+
"phpunit/phpunit": "^9.5",
20+
"psalm/plugin-phpunit": "^0.19.2",
21+
"psalm/plugin-symfony": "^5.2",
3322
"setono/code-quality-pack": "^2.1.3",
34-
"symfony/browser-kit": "^4.4 || ^5.0",
35-
"symfony/debug-bundle": "^4.4 || ^5.0",
36-
"symfony/dotenv": "^4.4 || ^5.0",
37-
"symfony/intl": "^4.4 || ^5.0",
38-
"symfony/web-profiler-bundle": "^4.4 || ^5.0",
39-
"symfony/web-server-bundle": "^4.4 || ^5.0"
23+
"sylius/sylius": "~1.10.0",
24+
"symfony/browser-kit": "^5.4 || ^6.4",
25+
"symfony/debug-bundle": "^5.4 || ^6.4",
26+
"symfony/dotenv": "^5.4 || ^6.4",
27+
"symfony/intl": "^5.4 || ^6.4",
28+
"symfony/web-profiler-bundle": "^5.4 || ^6.4"
4029
},
4130
"config": {
4231
"sort-packages": true,
@@ -46,18 +35,15 @@
4635
"dealerdirect/phpcodesniffer-composer-installer": false
4736
}
4837
},
49-
"extra": {
50-
"branch-alias": {
51-
"dev-master": "1.4-dev"
52-
}
53-
},
5438
"autoload": {
5539
"psr-4": {
56-
"Loevgaard\\SyliusBarcodePlugin\\": "src/",
57-
"Tests\\Loevgaard\\SyliusBarcodePlugin\\": "tests/"
40+
"Loevgaard\\SyliusBarcodePlugin\\": "src/"
5841
}
5942
},
6043
"autoload-dev": {
44+
"psr-4": {
45+
"Tests\\Loevgaard\\SyliusBarcodePlugin\\": "tests/"
46+
},
6147
"classmap": [
6248
"tests/Application/Kernel.php"
6349
]

ecs.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
declare(strict_types=1);
44

5-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
6-
use Symplify\EasyCodingStandard\ValueObject\Option;
7-
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
5+
use Symplify\EasyCodingStandard\Config\ECSConfig;
86

9-
return static function (ContainerConfigurator $containerConfigurator): void {
10-
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
11-
12-
$containerConfigurator->parameters()->set(Option::PATHS, [
13-
'src', 'tests', 'spec'
7+
return static function (ECSConfig $config): void {
8+
$config->import('vendor/sylius-labs/coding-standard/ecs.php');
9+
$config->paths([
10+
'src',
11+
'tests',
1412
]);
15-
16-
$containerConfigurator->parameters()->set(Option::SKIP, [
17-
VisibilityRequiredFixer::class => ['*Spec.php'],
13+
$config->skip([
14+
'tests/Application/node_modules/**',
15+
'tests/Application/var/**',
1816
]);
1917
};

psalm.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
<?xml version="1.0"?>
22
<psalm
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
errorLevel="4"
54
xmlns="https://getpsalm.org/schema/config"
65
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
6+
phpVersion="8.1"
7+
errorLevel="2"
8+
findUnusedBaselineEntry="false"
9+
findUnusedPsalmSuppress="false"
10+
findUnusedCode="false"
11+
findUnusedVariablesAndParams="false"
712
>
813
<projectFiles>
914
<directory name="src"/>
15+
<!-- todo readd -->
16+
<!--<directory name="tests"/>-->
1017
<ignoreFiles>
18+
<directory name="tests/Application"/>
1119
<directory name="vendor"/>
1220
</ignoreFiles>
1321
</projectFiles>
22+
<plugins>
23+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
24+
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
25+
</plugins>
1426
<forbiddenFunctions>
1527
<function name="dd"/>
1628
<function name="dump"/>
29+
<function name="exit"/>
30+
<function name="var_dump"/>
31+
<function name="print_r"/>
1732
</forbiddenFunctions>
33+
<issueHandlers>
34+
<DeprecatedConstant errorLevel="suppress"/>
35+
</issueHandlers>
1836
</psalm>

src/BarcodeChecker/BarcodeChecker.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,24 @@
77
use Loevgaard\SyliusBarcodePlugin\Event\PostBarcodeCheckEvent;
88
use Loevgaard\SyliusBarcodePlugin\Event\PreBarcodeCheckEvent;
99
use Loevgaard\SyliusBarcodePlugin\Model\BarcodeAwareInterface;
10-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1110
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
1211
use violuke\Barcodes\BarcodeValidator;
1312

1413
final class BarcodeChecker implements BarcodeCheckerInterface
1514
{
16-
/** @var LegacyEventDispatcherProxy */
17-
private $eventDispatcher;
18-
19-
public function __construct(EventDispatcherInterface $eventDispatcher)
15+
public function __construct(private readonly EventDispatcherInterface $eventDispatcher)
2016
{
21-
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
2217
}
2318

2419
public function check(BarcodeAwareInterface $barcodeAware): void
2520
{
2621
$this->eventDispatcher->dispatch(new PreBarcodeCheckEvent($barcodeAware), PreBarcodeCheckEvent::NAME);
2722

2823
$validator = new BarcodeValidator($barcodeAware->getBarcode());
29-
$valid = (bool) $validator->isValid();
24+
$valid = $validator->isValid();
3025

3126
$barcodeAware->markBarcodeAsChecked($valid);
3227

33-
$this->eventDispatcher->dispatch(new PostBarcodeCheckEvent($barcodeAware, $valid, (string) $validator->getType()), PostBarcodeCheckEvent::NAME);
28+
$this->eventDispatcher->dispatch(new PostBarcodeCheckEvent($barcodeAware, $valid, $validator->getType()), PostBarcodeCheckEvent::NAME);
3429
}
3530
}

src/Command/CheckBarcodesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131
EntityManagerInterface $productVariantManager,
3232
MessageBusInterface $commandBus,
3333
BatcherFactoryInterface $batcherFactory,
34-
string $productVariantClass
34+
string $productVariantClass,
3535
) {
3636
parent::__construct();
3737

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function getConfigTreeBuilder(): TreeBuilder
1414
$treeBuilder = new TreeBuilder('loevgaard_sylius_barcode');
1515
$rootNode = $treeBuilder->getRootNode();
1616

17+
/** @psalm-suppress UndefinedInterfaceMethod,PossiblyNullReference */
1718
$rootNode
1819
->children()
1920
->arrayNode('form')
@@ -30,10 +31,6 @@ public function getConfigTreeBuilder(): TreeBuilder
3031
->booleanNode('require_unique')
3132
->defaultTrue()
3233
->info('If true the barcode unique constraint will be added to the field')
33-
->end()
34-
->end()
35-
->end()
36-
->end()
3734
;
3835

3936
return $treeBuilder;

src/DependencyInjection/LoevgaardSyliusBarcodeExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ final class LoevgaardSyliusBarcodeExtension extends Extension
1313
{
1414
public function load(array $configs, ContainerBuilder $container): void
1515
{
16+
/**
17+
* @psalm-suppress PossiblyNullArgument
18+
*
19+
* @var array{form: array{require: bool, require_valid: bool, require_unique: bool}} $config
20+
*/
1621
$config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
1722
$container->setParameter('loevgaard_sylius_barcode.form.require', $config['form']['require']);
1823
$container->setParameter('loevgaard_sylius_barcode.form.require_valid', $config['form']['require_valid']);

src/EventListener/AddBarcodeUniqueSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
final class AddBarcodeUniqueSubscriber implements EventSubscriber
1313
{
14-
/** @var bool */
15-
private $uniqueEnabled;
14+
private bool $uniqueEnabled;
1615

1716
public function __construct(bool $uniqueEnabled)
1817
{
@@ -38,6 +37,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void
3837
return;
3938
}
4039

40+
/** @psalm-suppress InvalidPropertyAssignmentValue */
4141
$metadata->fieldMappings['barcode']['unique'] = true;
4242
}
4343
}

src/EventListener/AddIndicesSubscriber.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void
2222
{
2323
$metadata = $event->getClassMetadata();
2424

25-
if (!is_subclass_of($metadata->name, BarcodeAwareInterface::class, true)) {
25+
if (!is_subclass_of($metadata->name, BarcodeAwareInterface::class)) {
2626
return;
2727
}
2828

@@ -41,6 +41,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void
4141
];
4242
}
4343

44+
/** @psalm-suppress PropertyTypeCoercion */
4445
$metadata->table = array_merge_recursive($tableConfig, $metadata->table);
4546
}
4647
}

src/Form/Extension/ProductVariantTypeExtension.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44

55
namespace Loevgaard\SyliusBarcodePlugin\Form\Extension;
66

7+
use Loevgaard\SyliusBarcodePlugin\Model\ProductVariantInterface;
78
use Loevgaard\SyliusBarcodePlugin\Validator\Constraint\Barcode;
89
use Sylius\Bundle\ProductBundle\Form\Type\ProductVariantType;
910
use Symfony\Component\Form\AbstractTypeExtension;
1011
use Symfony\Component\Form\Extension\Core\Type\TextType;
1112
use Symfony\Component\Form\FormBuilderInterface;
1213
use Symfony\Component\Validator\Constraints\NotBlank;
1314

15+
/**
16+
* @extends AbstractTypeExtension<ProductVariantInterface>
17+
*/
1418
class ProductVariantTypeExtension extends AbstractTypeExtension
1519
{
16-
/** @var bool */
17-
private $requireBarcode;
20+
private bool $requireBarcode;
1821

19-
/** @var bool */
20-
private $requireValidBarcode;
22+
private bool $requireValidBarcode;
2123

22-
/** @var array */
23-
private $validationGroups;
24+
private array $validationGroups;
2425

2526
public function __construct(bool $requireBarcode, bool $requireValidBarcode, array $validationGroups = [])
2627
{

0 commit comments

Comments
 (0)