Skip to content

Commit

Permalink
Merge pull request #69 from JanPalen/feature/OP-476-update-builds
Browse files Browse the repository at this point in the history
Feature/op 476 update builds
  • Loading branch information
senghe authored Sep 5, 2024
2 parents 09f8bbd + d45c84c commit 226c20f
Show file tree
Hide file tree
Showing 26 changed files with 202 additions and 87 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
sylius: ["~1.12.0", "~1.13.0"]
node: ["^18.0", "^20.0"]
mysql: ["8.0"]

exclude:
- sylius: "~1.13.0"
php: "8.0"
- symfony: "^6.4"
- sylius: "~1.12.0"
php: "8.0"
symfony: "^6.4"

env:
APP_ENV: test
Expand Down Expand Up @@ -168,10 +168,6 @@ jobs:
name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)

-
name: Run ECS
run: vendor/bin/ecs check src

-
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/coding_standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Coding standard

on:
push:
branches-ignore:
- 'dependabot/**'
pull_request: ~
release:
types: [ created ]
workflow_dispatch: ~

jobs:
tests:
runs-on: ubuntu-latest

name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"

strategy:
fail-fast: false
matrix:
php: [ "8.0", "8.1", "8.2", "8.3" ]
symfony: [ "^5.4", "^6.4" ]
sylius: [ "^1.12", "^1.13" ]
node: [ "18.x", "20.x" ]

exclude:
- sylius: ^1.13
php: 8.0
- sylius: ^1.12
php: 8.0
symfony: ^6.4

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
extensions: intl
tools: symfony
coverage: none

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-
- name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"
- name: Restrict Sylius version
if: matrix.sylius != ''
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

- name: Install PHP dependencies
run: composer install --no-interaction
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

- name: Run PHPStan
run: vendor/bin/phpstan analyse -c phpstan.neon -l 8 src

- name: Run ECS
run: vendor/bin/ecs check src

- name: Failed build Slack notification
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
env:
SLACK_CHANNEL: ${{ secrets.FAILED_BUILD_SLACK_CHANNEL }}
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_MESSAGE: ':x:'
SLACK_TITLE: Failed build on ${{ github.event.repository.name }} repository
SLACK_USERNAME: ${{ secrets.FAILED_BUILD_SLACK_USERNAME }}
SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }}
14 changes: 14 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
parameters:
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

excludes_analyse:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'
- 'src/Repository'
- 'src/Processor/AutomaticBlacklistingRulesProcessor.php'
- 'src/Factory/FraudSuspicionFactory.php'

# Test dependencies
- 'tests/Application/app/**.php'
- 'tests/Application/src/**.php'

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


Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CompanyBlacklistingRuleChecker implements BlacklistingRuleCheckerInterface

public function checkIfCustomerIsBlacklisted(QueryBuilder $builder, FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): void
{
if (!empty($fraudSuspicionCommonModel->getCompany())) {
if (null !== $fraudSuspicionCommonModel->getCompany() && '' !== $fraudSuspicionCommonModel->getCompany()) {
$builder
->andWhere('o.company = :company')
->setParameter('company', $fraudSuspicionCommonModel->getCompany())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class PhoneNumberBlacklistingRuleChecker implements BlacklistingRuleCheckerInter

public function checkIfCustomerIsBlacklisted(QueryBuilder $builder, FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): void
{
if (!empty($fraudSuspicionCommonModel->getPhoneNumber())) {
if (null !== $fraudSuspicionCommonModel->getPhoneNumber() &&
'' !== $fraudSuspicionCommonModel->getPhoneNumber()) {
$builder
->andWhere('o.phoneNumber = :phoneNumber')
->setParameter('phoneNumber', $fraudSuspicionCommonModel->getPhoneNumber())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ProvinceBlacklistingRuleChecker implements BlacklistingRuleCheckerInterfac

public function checkIfCustomerIsBlacklisted(QueryBuilder $builder, FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): void
{
if (!empty($fraudSuspicionCommonModel->getProvince())) {
if (null !== $fraudSuspicionCommonModel->getProvince() && '' !== $fraudSuspicionCommonModel->getProvince()) {
$builder
->andWhere('o.province = :province')
->setParameter('province', $fraudSuspicionCommonModel->getProvince())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

final class BlacklistingRuleEligibilityChecker implements BlacklistingRuleEligibilityCheckerInterface
{
public function isEligible(BlacklistingRuleInterface $blacklistingRule, CustomerInterface $customer): bool
public function isEligible(BlacklistingRuleInterface $blacklistingRule, ?CustomerInterface $customer): bool
{
if (null === $customer) {
return false;
}

if ($blacklistingRule->isOnlyForGuests() && null !== $customer->getUser()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

interface BlacklistingRuleEligibilityCheckerInterface
{
public function isEligible(BlacklistingRuleInterface $blacklistingRule, CustomerInterface $customer): bool;
public function isEligible(BlacklistingRuleInterface $blacklistingRule, ?CustomerInterface $customer): bool;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class CustomerIpBlacklistingRuleChecker implements BlacklistingRuleCheckerInterf

public function checkIfCustomerIsBlacklisted(QueryBuilder $builder, FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): void
{
if (!empty($fraudSuspicionCommonModel->getCustomerIp())) {
if (null !== $fraudSuspicionCommonModel->getCustomerIp() &&
'' !== $fraudSuspicionCommonModel->getCustomerIp()) {
$builder
->andWhere('o.customerIp = :customerIp')
->setParameter('customerIp', $fraudSuspicionCommonModel->getCustomerIp())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class SyliusBehatPolyfillCompilerPass implements CompilerPassInterface

private const TEST = 'test';

public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
/** @var string $environment */
$environment = $container->getParameter(self::KERNEL_ENVIRONMENT_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AutomaticBlacklistingConfiguration implements AutomaticBlacklistingConfigu
/** @var int|null */
protected $id;

/** @var string */
/** @var string|null */
protected $name;

/**
Expand All @@ -43,10 +43,10 @@ class AutomaticBlacklistingConfiguration implements AutomaticBlacklistingConfigu
/** @var bool */
protected $addFraudSuspicion = false;

/** @var int */
/** @var int|null */
protected $permittedFraudSuspicionsNumber;

/** @var string */
/** @var string|null */
protected $permittedFraudSuspicionsTime;

public function __construct()
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/FraudPrevention/BlacklistingRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class BlacklistingRule implements BlacklistingRuleInterface
/** @var int|null */
protected $id;

/** @var string */
/** @var string|null */
protected $name;

/** @var array */
protected $attributes = [];

/** @var int */
/** @var int|null */
protected $permittedStrikes;

/** @var bool */
Expand Down Expand Up @@ -86,7 +86,7 @@ public function addAttribute(string $attribute): void

public function removeAttribute(string $attribute): void
{
$index = array_search($attribute, $this->attributes);
$index = array_search($attribute, $this->attributes, true);

if (false !== $index) {
unset($this->attributes[$index]);
Expand Down
36 changes: 18 additions & 18 deletions src/Entity/FraudPrevention/FraudSuspicion.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ class FraudSuspicion implements FraudSuspicionInterface
/** @var string|null */
protected $company;

/** @var string */
/** @var string|null */
protected $firstName;

/** @var string */
/** @var string|null */
protected $lastName;

/** @var string */
/** @var string|null */
protected $email;

/** @var string */
/** @var string|null */
protected $phoneNumber;

/** @var string */
/** @var string|null */
protected $street;

/** @var string */
/** @var string|null */
protected $city;

/** @var string */
/** @var string|null */
protected $province;

/** @var string */
/** @var string|null */
protected $country;

/** @var string|null */
Expand Down Expand Up @@ -100,7 +100,7 @@ public function getCompany(): ?string
return $this->company;
}

public function setCompany(?string $company)
public function setCompany(?string $company): void
{
$this->company = $company;
}
Expand All @@ -110,7 +110,7 @@ public function getFirstName(): ?string
return $this->firstName;
}

public function setFirstName(?string $firstName)
public function setFirstName(?string $firstName): void
{
$this->firstName = $firstName;
}
Expand All @@ -120,7 +120,7 @@ public function getLastName(): ?string
return $this->lastName;
}

public function setLastName(?string $lastName)
public function setLastName(?string $lastName): void
{
$this->lastName = $lastName;
}
Expand All @@ -130,7 +130,7 @@ public function getEmail(): ?string
return $this->email;
}

public function setEmail(?string $email)
public function setEmail(?string $email): void
{
$this->email = $email;
}
Expand All @@ -140,7 +140,7 @@ public function getPhoneNumber(): ?string
return $this->phoneNumber;
}

public function setPhoneNumber(?string $phoneNumber)
public function setPhoneNumber(?string $phoneNumber): void
{
$this->phoneNumber = $phoneNumber;
}
Expand All @@ -150,7 +150,7 @@ public function getStreet(): ?string
return $this->street;
}

public function setStreet(?string $street)
public function setStreet(?string $street): void
{
$this->street = $street;
}
Expand All @@ -160,7 +160,7 @@ public function getCity(): ?string
return $this->city;
}

public function setCity(?string $city)
public function setCity(?string $city): void
{
$this->city = $city;
}
Expand All @@ -170,7 +170,7 @@ public function getProvince(): ?string
return $this->province;
}

public function setProvince(?string $province)
public function setProvince(?string $province): void
{
$this->province = $province;
}
Expand All @@ -180,7 +180,7 @@ public function getCountry(): ?string
return $this->country;
}

public function setCountry(?string $country)
public function setCountry(?string $country): void
{
$this->country = $country;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ public function getAddressType(): ?string
return $this->addressType;
}

public function setAddressType(string $addressType)
public function setAddressType(string $addressType): void
{
$this->addressType = $addressType;
}
Expand Down
Loading

0 comments on commit 226c20f

Please sign in to comment.