diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..49f4ac6 --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,22 @@ +on: [ pull_request ] +name: Static analysis + +jobs: + psalm: + name: Psalm + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + coverage: none + + - name: Download dependencies + uses: ramsey/composer-install@v2 + + - name: Psalm + run: vendor/bin/psalm --no-progress --output-format=github diff --git a/composer.json b/composer.json index 599e093..5c183e2 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ }, "require-dev": { "phpunit/phpunit": "^12.5", - "symfony/validator": "^8.0" + "symfony/validator": "^8.0", + "vimeo/psalm": "^6.16" } } diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..57b5e7b --- /dev/null +++ b/psalm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Validator/Constraints/IdentityNumberValidator.php b/src/Validator/Constraints/IdentityNumberValidator.php index 23356d1..e6a6f45 100644 --- a/src/Validator/Constraints/IdentityNumberValidator.php +++ b/src/Validator/Constraints/IdentityNumberValidator.php @@ -43,12 +43,12 @@ public function validate(mixed $value, Constraint $constraint): void $this->coordinationIdFactory->createId($value); return; - } catch (Exception $e) {} + } catch (\Exception $e) {} } try { $this->personalIdFactory->createId($value); - } catch (Exception $e) { + } catch (\Exception $e) { $this->context->addViolation($message); } } diff --git a/src/Validator/Constraints/OrganizationNumberValidator.php b/src/Validator/Constraints/OrganizationNumberValidator.php index 17b16f2..8eca46f 100644 --- a/src/Validator/Constraints/OrganizationNumberValidator.php +++ b/src/Validator/Constraints/OrganizationNumberValidator.php @@ -44,7 +44,7 @@ public function validate($value, Constraint $constraint): void $this->personalIdFactory->createId($value); return; - } catch (Exception $e) {} + } catch (\Exception $e) {} } if ($constraint->allowCoordinationNumber) { @@ -55,12 +55,12 @@ public function validate($value, Constraint $constraint): void $this->coordinationIdFactory->createId($value); return; - } catch (Exception $e) {} + } catch (\Exception $e) {} } try { $this->organizationIdFactory->createId($value); - } catch (Exception $e) { + } catch (\Exception $e) { $this->context->addViolation($constraint->message); } }