Skip to content

Commit 226c20f

Browse files
authored
Merge pull request #69 from JanPalen/feature/OP-476-update-builds
Feature/op 476 update builds
2 parents 09f8bbd + d45c84c commit 226c20f

26 files changed

+202
-87
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626
sylius: ["~1.12.0", "~1.13.0"]
2727
node: ["^18.0", "^20.0"]
2828
mysql: ["8.0"]
29-
3029
exclude:
3130
- sylius: "~1.13.0"
3231
php: "8.0"
33-
- symfony: "^6.4"
32+
- sylius: "~1.12.0"
3433
php: "8.0"
34+
symfony: "^6.4"
3535

3636
env:
3737
APP_ENV: test
@@ -168,10 +168,6 @@ jobs:
168168
name: Validate database schema
169169
run: (cd tests/Application && bin/console doctrine:schema:validate)
170170

171-
-
172-
name: Run ECS
173-
run: vendor/bin/ecs check src
174-
175171
-
176172
name: Run PHPSpec
177173
run: vendor/bin/phpspec run --ansi -f progress --no-interaction
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Coding standard
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'dependabot/**'
7+
pull_request: ~
8+
release:
9+
types: [ created ]
10+
workflow_dispatch: ~
11+
12+
jobs:
13+
tests:
14+
runs-on: ubuntu-latest
15+
16+
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
php: [ "8.0", "8.1", "8.2", "8.3" ]
22+
symfony: [ "^5.4", "^6.4" ]
23+
sylius: [ "^1.12", "^1.13" ]
24+
node: [ "18.x", "20.x" ]
25+
26+
exclude:
27+
- sylius: ^1.13
28+
php: 8.0
29+
- sylius: ^1.12
30+
php: 8.0
31+
symfony: ^6.4
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
36+
- name: Setup PHP
37+
uses: shivammathur/setup-php@v2
38+
with:
39+
php-version: "${{ matrix.php }}"
40+
extensions: intl
41+
tools: symfony
42+
coverage: none
43+
44+
- name: Get Composer cache directory
45+
id: composer-cache
46+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
47+
48+
- name: Cache Composer
49+
uses: actions/cache@v4
50+
with:
51+
path: ${{ steps.composer-cache.outputs.dir }}
52+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
53+
restore-keys: |
54+
${{ runner.os }}-php-${{ matrix.php }}-composer-
55+
56+
- name: Restrict Symfony version
57+
if: matrix.symfony != ''
58+
run: |
59+
composer global config --no-plugins allow-plugins.symfony/flex true
60+
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
61+
composer config extra.symfony.require "${{ matrix.symfony }}"
62+
63+
- name: Restrict Sylius version
64+
if: matrix.sylius != ''
65+
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction
66+
67+
- name: Install PHP dependencies
68+
run: composer install --no-interaction
69+
env:
70+
SYMFONY_REQUIRE: ${{ matrix.symfony }}
71+
72+
- name: Run PHPStan
73+
run: vendor/bin/phpstan analyse -c phpstan.neon -l 8 src
74+
75+
- name: Run ECS
76+
run: vendor/bin/ecs check src
77+
78+
- name: Failed build Slack notification
79+
uses: rtCamp/action-slack-notify@v2
80+
if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
81+
env:
82+
SLACK_CHANNEL: ${{ secrets.FAILED_BUILD_SLACK_CHANNEL }}
83+
SLACK_COLOR: ${{ job.status }}
84+
SLACK_ICON: https://github.com/rtCamp.png?size=48
85+
SLACK_MESSAGE: ':x:'
86+
SLACK_TITLE: Failed build on ${{ github.event.repository.name }} repository
87+
SLACK_USERNAME: ${{ secrets.FAILED_BUILD_SLACK_USERNAME }}
88+
SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }}

phpstan.neon

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
parameters:
22
reportUnmatchedIgnoredErrors: false
33
checkMissingIterableValueType: false
4+
checkGenericClassInNonGenericObjectType: false
45

56
excludes_analyse:
67
# Makes PHPStan crash
78
- 'src/DependencyInjection/Configuration.php'
9+
- 'src/Repository'
10+
- 'src/Processor/AutomaticBlacklistingRulesProcessor.php'
11+
- 'src/Factory/FraudSuspicionFactory.php'
812

913
# Test dependencies
1014
- 'tests/Application/app/**.php'
1115
- 'tests/Application/src/**.php'
1216

1317
ignoreErrors:
1418
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'
19+
- '/Parameter #1 \$customer of method BitBag\\SyliusBlacklistPlugin\\Model\\FraudSuspicionCommonModelInterface::setCustomer\(\) expects Sylius\\Component\\Customer\\Model\\CustomerInterface, Sylius\\Component\\Customer\\Model\\CustomerInterface\|null given\./'
20+
- '/Parameter #1 \$customer of method BitBag\\SyliusBlacklistPlugin\\StateResolver\\CustomerStateResolverInterface::changeStateOnBlacklisted\(\) expects Sylius\\Component\\Customer\\Model\\CustomerInterface, Sylius\\Component\\Customer\\Model\\CustomerInterface\|null given\./'
21+
- '#Access to an undefined property Symfony\\Component\\Validator\\Constraint::\$.+#'
22+
- '#Call to an undefined method .+::[a-zA-Z]+\(\).#'
23+
- '#Argument of an invalid type array\|null supplied for foreach, only iterables are supported.#'
24+
- '#Cannot call method [a-zA-Z]+\(.*\) on .+\\?null#'
25+
- '#Property .+::\$[a-zA-Z]+ is never read, only written.#'
26+
- '#Call to an undefined method .+::[a-zA-Z]+\(\).#'
27+
28+

src/Checker/BlacklistingRule/Address/CompanyBlacklistingRuleChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CompanyBlacklistingRuleChecker implements BlacklistingRuleCheckerInterface
2222

2323
public function checkIfCustomerIsBlacklisted(QueryBuilder $builder, FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): void
2424
{
25-
if (!empty($fraudSuspicionCommonModel->getCompany())) {
25+
if (null !== $fraudSuspicionCommonModel->getCompany() && '' !== $fraudSuspicionCommonModel->getCompany()) {
2626
$builder
2727
->andWhere('o.company = :company')
2828
->setParameter('company', $fraudSuspicionCommonModel->getCompany())

src/Checker/BlacklistingRule/Address/PhoneNumberBlacklistingRuleChecker.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class PhoneNumberBlacklistingRuleChecker implements BlacklistingRuleCheckerInter
2222

2323
public function checkIfCustomerIsBlacklisted(QueryBuilder $builder, FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): void
2424
{
25-
if (!empty($fraudSuspicionCommonModel->getPhoneNumber())) {
25+
if (null !== $fraudSuspicionCommonModel->getPhoneNumber() &&
26+
'' !== $fraudSuspicionCommonModel->getPhoneNumber()) {
2627
$builder
2728
->andWhere('o.phoneNumber = :phoneNumber')
2829
->setParameter('phoneNumber', $fraudSuspicionCommonModel->getPhoneNumber())

src/Checker/BlacklistingRule/Address/ProvinceBlacklistingRuleChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ProvinceBlacklistingRuleChecker implements BlacklistingRuleCheckerInterfac
2222

2323
public function checkIfCustomerIsBlacklisted(QueryBuilder $builder, FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): void
2424
{
25-
if (!empty($fraudSuspicionCommonModel->getProvince())) {
25+
if (null !== $fraudSuspicionCommonModel->getProvince() && '' !== $fraudSuspicionCommonModel->getProvince()) {
2626
$builder
2727
->andWhere('o.province = :province')
2828
->setParameter('province', $fraudSuspicionCommonModel->getProvince())

src/Checker/BlacklistingRule/BlacklistingRuleEligibilityChecker.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616

1717
final class BlacklistingRuleEligibilityChecker implements BlacklistingRuleEligibilityCheckerInterface
1818
{
19-
public function isEligible(BlacklistingRuleInterface $blacklistingRule, CustomerInterface $customer): bool
19+
public function isEligible(BlacklistingRuleInterface $blacklistingRule, ?CustomerInterface $customer): bool
2020
{
21+
if (null === $customer) {
22+
return false;
23+
}
24+
2125
if ($blacklistingRule->isOnlyForGuests() && null !== $customer->getUser()) {
2226
return false;
2327
}

src/Checker/BlacklistingRule/BlacklistingRuleEligibilityCheckerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
interface BlacklistingRuleEligibilityCheckerInterface
1818
{
19-
public function isEligible(BlacklistingRuleInterface $blacklistingRule, CustomerInterface $customer): bool;
19+
public function isEligible(BlacklistingRuleInterface $blacklistingRule, ?CustomerInterface $customer): bool;
2020
}

src/Checker/BlacklistingRule/Customer/CustomerIpBlacklistingRuleChecker.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class CustomerIpBlacklistingRuleChecker implements BlacklistingRuleCheckerInterf
2222

2323
public function checkIfCustomerIsBlacklisted(QueryBuilder $builder, FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): void
2424
{
25-
if (!empty($fraudSuspicionCommonModel->getCustomerIp())) {
25+
if (null !== $fraudSuspicionCommonModel->getCustomerIp() &&
26+
'' !== $fraudSuspicionCommonModel->getCustomerIp()) {
2627
$builder
2728
->andWhere('o.customerIp = :customerIp')
2829
->setParameter('customerIp', $fraudSuspicionCommonModel->getCustomerIp())

src/DependencyInjection/Compiler/SyliusBehatPolyfillCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class SyliusBehatPolyfillCompilerPass implements CompilerPassInterface
2424

2525
private const TEST = 'test';
2626

27-
public function process(ContainerBuilder $container)
27+
public function process(ContainerBuilder $container): void
2828
{
2929
/** @var string $environment */
3030
$environment = $container->getParameter(self::KERNEL_ENVIRONMENT_KEY);

0 commit comments

Comments
 (0)