Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "PHPStan analysis"

on:
pull_request:
push:
branches:
- "master"

jobs:
phpstan:
name: "PHPStan analysis"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2

- name: "Install dependencies"
run: "composer update --no-interaction --no-progress"

- name: "Run PHPStan"
run: "vendor/bin/phpstan"
7 changes: 1 addition & 6 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ jobs:
dependencies:
- "highest"
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

include:
- php-version: '7.2'
- php-version: '8.2'
dependencies: "lowest"

steps:
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
help: ## Show this help.
@printf "\033[33mUsage:\033[0m\n make [target] [arg=\"val\"...]\n\n\033[33mTargets:\033[0m\n"
@grep -E '^[-a-zA-Z0-9_\.\/]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-30s\033[0m %s\n", $$1, $$2}'

static-analysis:
@vendor/bin/phpstan analyse
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
> [!CAUTION]
> This is an experimental fork to propose a possible new major version.
>
> It will not be compatible with any existing gateway. Do not try to create a gateway for this version, please
> share your [ideas](https://github.com/devnix-labs/omnipay-common/discussions/categories/ideas) so we can elaborate
> a clear roadmap to define the shape of a new Omnipay version.

# Omnipay Common

**Core components for the Omnipay PHP payment processing library**
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
{
"name": "Del"
},
{
"name": "Pablo Largo Mohedano",
"email": "devnix.code@gmail.com"
},
{
"name": "Omnipay Contributors",
"homepage": "https://github.com/thephpleague/omnipay-common/contributors"
Expand All @@ -42,7 +46,7 @@
"classmap": ["tests/OmnipayTest.php"]
},
"require": {
"php": "^7.2|^8",
"php": "^8.2",
"php-http/client-implementation": "^1",
"php-http/message": "^1.5",
"php-http/message-factory": "^1.1",
Expand All @@ -55,7 +59,10 @@
"php-http/mock-client": "^1.6",
"php-http/guzzle7-adapter": "^1",
"squizlabs/php_codesniffer": "^3.8.1",
"http-interop/http-factory-guzzle": "^1.1"
"http-interop/http-factory-guzzle": "^1.1",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-phpunit": "^1.4",
"phpunit/phpunit": "^9.6"
},
"extra": {
"branch-alias": {
Expand Down
8 changes: 8 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
level: 0
paths:
- src
6 changes: 3 additions & 3 deletions src/Common/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,16 @@ public function getNumberMasked($mask = 'X')
* Credit Card Brand
*
* Iterates through known/supported card brands to determine the brand of this card
*
* @return string
*/
public function getBrand()
public function getBrand(): string|null
{
foreach ($this->getSupportedBrands() as $brand => $val) {
if (preg_match($val, $this->getNumber())) {
return $brand;
}
}

return null;
}

/**
Expand Down
12 changes: 8 additions & 4 deletions src/Common/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ private function getMoney($amount = null)
* Validates and returns the formatted amount.
*
* @throws InvalidRequestException on any validation failure.
* @return string The amount formatted to the correct number of decimal places for the selected currency.
* @return string|null The amount formatted to the correct number of decimal places for the selected currency.
*/
public function getAmount()
public function getAmount(): string|null
{
$money = $this->getMoney();

Expand All @@ -319,6 +319,8 @@ public function getAmount()

return $moneyFormatter->format($money);
}

return null;
}

/**
Expand All @@ -335,15 +337,17 @@ public function setAmount($value)
/**
* Get the payment amount as an integer.
*
* @return integer
* @return int|null
*/
public function getAmountInteger()
public function getAmountInteger(): int|null
{
$money = $this->getMoney();

if ($money !== null) {
return (int) $money->getAmount();
}

return null;
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/Common/AbstractGatewayTest/MockAbstractGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Omnipay\Common\AbstractGatewayTest;

final class MockAbstractGateway
{
public function __construct()
{
}
}