Skip to content
Merged
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
5 changes: 0 additions & 5 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ jobs:
strategy:
matrix:
php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
/composer.lock

### Tests
/.phpunit.result.cache
/.phpunit.cache/
/phpunit.xml
2 changes: 1 addition & 1 deletion .runConfigurations/All tests.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<env name="FUNC_ENABLED" value="1" />
</envs>
</CommandLine>
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml" scope="XML" options="--verbose" />
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml" scope="XML" />
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion .runConfigurations/All unit tests.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All unit tests" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml" directory="$PROJECT_DIR$/tests" scope="XML" options="--verbose" />
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml" directory="$PROJECT_DIR$/tests" scope="XML" />
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion .runConfigurations/Functional tests.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<env name="FUNC_ENABLED" value="1" />
</envs>
</CommandLine>
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml" scope="XML" options="--verbose --group=functional" />
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml" scope="XML" options="--group=functional" />
<method v="2" />
</configuration>
</component>
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Add PHP 8 type declarations.
### Removed
- **BC break**: Removed support for PHP versions <= v8.0 as they are no longer
[actively supported](https://php.net/supported-versions.php) by the PHP project.

## [5.1.1] - 2021-08-10
### Fixed
Expand Down
20 changes: 12 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "maxemail/api-php",
"description": "Maxemail API Client",
"license" : "LGPL-3.0",
"license": "LGPL-3.0",
"authors": [
{
"name": "Maxemail Team & Contributors",
Expand All @@ -16,17 +16,17 @@
},

"require": {
"php" : "^7.1|^8",
"php": "^8.1",
"ext-fileinfo": "*",
"ext-json" : "*",
"ext-json": "*",
"ext-zip": "*",

"psr/log" : "^1 || ^2 || ^3",
"psr/log": "^2 || ^3",
"guzzlehttp/guzzle": "^6 || ^7"
},

"suggest": {
"psr/log-implementation" : "A logger can be used to provide debug information"
"psr/log-implementation": "A logger can be used to provide debug information"
},

"autoload-dev": {
Expand All @@ -36,8 +36,12 @@
},

"require-dev": {
"phpunit/phpunit" : "^7|^8|^9",
"php-mock/php-mock-phpunit": "^2.0",
"symplify/easy-coding-standard": "^9"
"phpunit/phpunit" : "^10",
"php-mock/php-mock-phpunit": "^2",
"symplify/easy-coding-standard": "^12.1"
},
"scripts": {
"check-cs": "vendor/bin/ecs check --ansi",
"fix-cs": "vendor/bin/ecs check --fix --ansi"
}
}
70 changes: 55 additions & 15 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,65 @@

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
return ECSConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);
])
->withRootFiles()

$services = $containerConfigurator->services();
->withSets([
SetList::COMMON,
SetList::PSR_12,
SetList::STRICT,
])

$containerConfigurator->import(SetList::COMMON);
// Remove sniff, from common/control-structures
$services->remove(\PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer::class);
// Remove sniff, from common/spaces
$services->remove(\PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer::class);
$services->remove(\PhpCsFixer\Fixer\CastNotation\CastSpacesFixer::class);
->withSkip([
// Remove sniff, from common/control-structures
\PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer::class,

$containerConfigurator->import(SetList::PSR_12);
};
// Remove sniff, from common/spaces
\PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer::class,
])

// Rule from common/spaces. No space after cast.
->withConfiguredRule(
\PhpCsFixer\Fixer\CastNotation\CastSpacesFixer::class,
[
'space' => 'none',
],
)

/*
* Rule missing from PSR12. PER Coding Style 3:
* "... each of the blocks [of import statements] MUST be separated by a single blank line ..."
*/
->withRules([
\PhpCsFixer\Fixer\Whitespace\BlankLineBetweenImportGroupsFixer::class,
])

// Rule from PSR12. PER Coding Style 7.1: "The `fn` keyword MUST NOT be succeeded by a space."
->withConfiguredRule(
\PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer::class,
[
'closure_fn_spacing' => 'none',
],
)

/*
* Rule from PER Coding Style 2.6:
* "If the list is split across multiple lines, then the last item MUST have a trailing comma."
*/
->withConfiguredRule(
\PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer::class,
[
'elements' => [
\PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer::ELEMENTS_ARGUMENTS,
\PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer::ELEMENTS_ARRAYS,
\PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer::ELEMENTS_PARAMETERS,
],
],
);
17 changes: 5 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
convertDeprecationsToExceptions="true"
cacheDirectory=".phpunit.cache"
colors="true"
>
<!-- convertDeprecationsToExceptions is required for MiddlewareTest::testWarningLoggerCreatesLog -->
Expand All @@ -17,20 +17,13 @@
</php>

<testsuites>
<testsuite name="Mxm">
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<!-- `filter` element is only used to support PHPUnit <=8 for PHP <=7.2 -->
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<!-- END -->
<coverage>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
66 changes: 23 additions & 43 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\HandlerStack;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -56,59 +57,38 @@
* @property mixed transactional https://docs.maxemail.xtremepush.com/mxm-dev/api/services/transactional
* @property mixed data_export_quick_transactional https://docs.maxemail.xtremepush.com/mxm-dev/api/services/data-export-quick-transactional
*/
class Client implements \Psr\Log\LoggerAwareInterface
class Client implements LoggerAwareInterface
{
public const VERSION = '5.1';

/**
* @var string
*/
private $uri = 'https://mxm.xtremepush.com/';
private string $uri = 'https://mxm.xtremepush.com/';

/**
* @var string
*/
private $username;
private readonly string $username;

/**
* @var string
*/
private $password;
private readonly string $password;

/**
* @var Service[]
*/
private $services = [];
private array $services = [];

/**
* @var Helper
*/
private $helper;
private Helper $helper;

/**
* @var LoggerInterface
*/
private $logger;
private LoggerInterface $logger;

/**
* @var GuzzleClient
*/
private $httpClient;
private GuzzleClient $httpClient;

/**
* @var bool
*/
private $debugLoggingEnabled = false;
private bool $debugLoggingEnabled = false;

/**
* @param array $config {
* @var string $username Required
* @var string $password Required
* @var string $uri Optional. Default https://mxm.xtremepush.com/
* @var string $user @deprecated See username
* @var string $pass @deprecated See password
* @var bool $debugLogging Optional. Enable logging of request/response. Default false
* }
* @param array{
* username: string, // Required
* password: string, // Required
* uri: string, // Optional. Default https://mxm.xtremepush.com/
* user: string, // @deprecated See username
* pass: string, // @deprecated See password
* debugLogging: bool, // Optional. Enable logging of request/response. Default false
* } $config
*/
public function __construct(array $config)
{
Expand Down Expand Up @@ -159,7 +139,7 @@ private function getInstance(string $serviceName): Service

private function getClient(): GuzzleClient
{
if ($this->httpClient === null) {
if (!isset($this->httpClient)) {
$stack = HandlerStack::create();
Middleware::addMaxemailErrorParser($stack);
Middleware::addWarningLogging($stack, $this->getLogger());
Expand Down Expand Up @@ -187,10 +167,10 @@ private function getClient(): GuzzleClient
/**
* Get API connection config
*
* @return array {
* @var string $uri
* @var string $username
* @var string $password
* @return array{
* uri: string,
* username: string,
* password: string,
* }
*/
public function getConfig(): array
Expand Down
Loading