Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Php 8.1 (#48)
Browse files Browse the repository at this point in the history
* Update php version
* Update githubAction
* Update README
* Refactor AresExtension
  • Loading branch information
trejjam committed Jan 15, 2023
1 parent 6c298ab commit e87456c
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 108 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

strategy:
matrix:
php-version: ["7.4"]
php-version: ["8.1"]
operating-system: ["ubuntu-latest"]
fail-fast: false

Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:

strategy:
matrix:
php-version: ["7.4"]
php-version: ["8.1"]
operating-system: ["ubuntu-latest"]
fail-fast: false

Expand Down Expand Up @@ -138,19 +138,19 @@ jobs:

strategy:
matrix:
php-version: ["7.4", "8.0"]
php-version: ["8.1", "8.2"]
operating-system: ["ubuntu-latest"]
composer-args: [ "" ]
include:
- php-version: "7.4"
- php-version: "8.1"
operating-system: "ubuntu-latest"
composer-args: "--prefer-lowest"
- php-version: "8.1"
- php-version: "8.2"
operating-system: "ubuntu-latest"
composer-args: "--ignore-platform-reqs"
composer-args: "--prefer-lowest"
fail-fast: false

continue-on-error: "${{ matrix.php-version == '8.1' }}"
continue-on-error: "${{ matrix.php-version == '8.2' }}"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:

strategy:
matrix:
php-version: ["7.4"]
php-version: ["8.1"]
operating-system: ["ubuntu-latest"]
fail-fast: false

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p align=center> <a href="https://github.com/trejjam/ares/actions"><img src="https://badgen.net/github/checks/trejjam/ares/master?cache=300"></a> <a href="https://coveralls.io/r/trejjam/ares"><img src="https://badgen.net/coveralls/c/github/trejjam/ares?cache=300"></a> <a href="https://packagist.org/packages/trejjam/ares"><img src="https://badgen.net/packagist/dm/trejjam/ares"></a> <a href="https://packagist.org/packages/trejjam/ares"><img src="https://badgen.net/packagist/v/trejjam/ares"></a></p><p align=center> <a href="https://packagist.org/packages/trejjam/ares"><img src="https://badgen.net/packagist/php/trejjam/ares"></a> <a href="https://github.com/trejjam/ares"><img src="https://badgen.net/github/license/trejjam/ares"></a> <a href="https://contributte.org/partners.html"><img src="https://badgen.net/badge/sponsor/donations/F96854"></a></p>## UsageTo install the latest version of `trejjam/ares` use [Composer](https://getcomposer.com).```composer require trejjam/ares```## Versions| State | Version | Branch | PHP | Nette ||-------------|---------|----------|----------|-------|| dev | `^0.6` | `master` | `>= 7.3` | ^3.0 || stable | `^0.5` | `master` | `>= 7.3` | ^3.0 || stable | `^0.4` | `master` | `>= 7.2` | ^3.0 || stable | `^0.3` | `master` | `>= 7.2` | ^3.0 || stable | `^0.2` | `master` | `>= 7.1` | ^2.4 |## DocumentationFor details on how to use this package, check out our [documentation](.docs).## Maintainers<table> <tbody> <tr> <td align="center"> <a href="https://github.com/trejjam"> <img width="150" height="150" src="https://avatars2.githubusercontent.com/u/3594540?s=150&v=4"> </a> </br> <a href="https://github.com/trejjam">Jan Trejbal</a> </td> </tr> </body></table>-----Thank you for testing, reporting and contributing.
<p align=center> <a href="https://github.com/trejjam/ares/actions"><img src="https://badgen.net/github/checks/trejjam/ares/master?cache=300"></a> <a href="https://coveralls.io/r/trejjam/ares"><img src="https://badgen.net/coveralls/c/github/trejjam/ares?cache=300"></a> <a href="https://packagist.org/packages/trejjam/ares"><img src="https://badgen.net/packagist/dm/trejjam/ares"></a> <a href="https://packagist.org/packages/trejjam/ares"><img src="https://badgen.net/packagist/v/trejjam/ares"></a></p><p align=center> <a href="https://packagist.org/packages/trejjam/ares"><img src="https://badgen.net/packagist/php/trejjam/ares"></a> <a href="https://github.com/trejjam/ares"><img src="https://badgen.net/github/license/trejjam/ares"></a> <a href="https://contributte.org/partners.html"><img src="https://badgen.net/badge/sponsor/donations/F96854"></a></p>## UsageTo install the latest version of `trejjam/ares` use [Composer](https://getcomposer.com).```composer require trejjam/ares```## Versions| State | Version | Branch | PHP | Nette ||--------|---------|----------|----------|-------|| dev | `^0.7` | `master` | `>= 8.1` | ^3.0 || stable | `^0.6` | `master` | `>= 8.1` | ^3.0 || stable | `^0.5` | `master` | `>= 7.3` | ^3.0 || stable | `^0.4` | `master` | `>= 7.2` | ^3.0 || stable | `^0.3` | `master` | `>= 7.2` | ^3.0 || stable | `^0.2` | `master` | `>= 7.1` | ^2.4 |## DocumentationFor details on how to use this package, check out our [documentation](.docs).## Maintainers<table> <tbody> <tr> <td align="center"> <a href="https://github.com/trejjam"> <img width="150" height="150" src="https://avatars2.githubusercontent.com/u/3594540?s=150&v=4"> </a> </br> <a href="https://github.com/trejjam">Jan Trejbal</a> </td> </tr> </body></table>-----Thank you for testing, reporting and contributing.
Expand Down
4 changes: 4 additions & 0 deletions bin/easy-coding-standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForEachLoopDeclarationSniff;
use PhpCsFixer\Fixer\Basic\BracesFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
use PhpCsFixer\Fixer\ControlStructure\ControlStructureContinuationPositionFixer;
use PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\NewWithBracesFixer;
Expand Down Expand Up @@ -48,4 +49,7 @@
$ecsConfig->ruleWithConfiguration(ReturnTypeDeclarationFixer::class, [
'space_before' => 'one',
]);
$ecsConfig->ruleWithConfiguration(ControlStructureContinuationPositionFixer::class, [
'position' => ControlStructureContinuationPositionFixer::NEXT_LINE,
]);
};
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@
}
],
"require": {
"php": "^7.3 | ^8.0",
"php": "~8.1.0",

"ext-simplexml": "^7.1 | ^8.0",
"ext-simplexml": "~8.1.0 | ~8.2.0",

"nette/di": "^3.0",
"nette/http": "^3.0",
"nette/utils": "^3.0",
"guzzlehttp/guzzle": "^7.0",
"thecodingmachine/safe": "^1.3 || ^2.0"
"thecodingmachine/safe": "^2.4"
},
"require-dev": {
"nette/tester": "^2.4",

"composer/ca-bundle": "^1.1",
"paragonie/certainty": "^2.6",
"composer/ca-bundle": "^1.3",
"paragonie/certainty": "^2.8",

"phpstan/phpstan": "^1.7",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^1.3",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-strict-rules": "^1.4",
"thecodingmachine/phpstan-safe-rule": "^1.2",
"roave/no-floaters": "^1.5",
"roave/no-floaters": "^1.9",

"symplify/easy-coding-standard": "^11.0",
"symplify/easy-coding-standard": "^11.2",

"roave/security-advisories": "dev-master"
},
Expand All @@ -62,7 +62,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "v0.6.x-dev"
"dev-master": "v0.7.x-dev"
}
}
}
70 changes: 32 additions & 38 deletions src/DI/AresExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,41 @@

use Composer;
use GuzzleHttp;
use Nette;
use Nette\DI\CompilerExtension;
use Nette\DI\Definitions\ServiceDefinition;
use Nette\DI\Definitions\Statement;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use Nette\Utils\Strings;
use stdClass;
use Trejjam\Ares;
use Trejjam\Ares\Mapper;

/**
* @property ExtensionConfiguration $config
* @method ExtensionConfiguration getConfig()
* @property-read stdClass $config
*/
class AresExtension extends CompilerExtension
{
public function __construct()
public function getConfigSchema() : Nette\Schema\Schema
{
$this->config = new ExtensionConfiguration();
}

public function getConfigSchema() : Schema
{
return Expect::from($this->config);
return Expect::structure([
'http' => Expect::structure([
'clientFactory' => Expect::anyOf(Expect::string(), Expect::array(), Expect::type(Statement::class))->nullable(),
'caChain' => Expect::anyOf(Expect::string(), Expect::type(Statement::class))->nullable(),
'client' => Expect::array()->default([]),
]),
'mapper' => Expect::anyOf(Expect::string(), Expect::array(), Expect::type(Statement::class))->default(Mapper::class),
]);
}

public function loadConfiguration() : void
{
if ($this->config->http->caChain === null && method_exists(
$http = $this->config->http;
if ($http->caChain === null && method_exists(
'Composer\CaBundle\CaBundle',
'getSystemCaRootBundlePath'
)) {
$this->config->http->caChain = Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
$http->caChain = Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
}
}

Expand All @@ -45,56 +49,46 @@ public function beforeCompile() : void

$builder = $this->getContainerBuilder();

$this->registerFactory('mapper', Ares\IMapper::class, $this->config->mapper);
$mapper = $this->config->mapper;
$http = $this->config->http;

$this->registerFactory('mapper', Ares\IMapper::class, $mapper);

if ($this->config->http->clientFactory !== null) {
if ($http->clientFactory !== null) {
$httpClient = $this->registerFactory(
'http.client',
GuzzleHttp\Client::class,
$this->config->http->clientFactory
$http->clientFactory
);
} else {
}
else {
$httpClient = $builder->addDefinition($this->prefix('http.client'))->setType(GuzzleHttp\Client::class);
}

if ($this->config->http->caChain !== null && !array_key_exists('verify', $this->config->http->client)) {
$this->config->http->client['verify'] = $this->config->http->caChain;
if ($http->caChain !== null && !array_key_exists('verify', $http->client)) {
$http->client['verify'] = $http->caChain;
}

$httpClient
->setArguments(
[
'config' => $this->config->http->client,
]
)
->setArguments(['config' => $http->client])
->setAutowired(false);

$builder
->addDefinition($this->prefix('request'))
->setFactory(Ares\Request::class)->setArguments(
[
'httpClient' => $httpClient,
]
);
->setFactory(Ares\Request::class)->setArguments(['httpClient' => $httpClient]);
}

/**
* @param string|array|Statement $factory
*/
private function registerFactory(string $name, string $type, $factory) : ServiceDefinition
private function registerFactory(string $name, string $type, string|array|Statement $factory) : ServiceDefinition
{
$builder = $this->getContainerBuilder();

if (is_string($factory) && Strings::startsWith($factory, '@')) {
$factoryDefinition = $builder->addDefinition($this->prefix($name));

$factoryDefinition->setFactory($factory);
} else {
$this->loadDefinitionsFromConfig(
[
$name => $factory,
]
);
}
else {
$this->loadDefinitionsFromConfig([$name => $factory]);

$factoryDefinition = $builder->getDefinition($this->prefix($name));
}
Expand Down
25 changes: 0 additions & 25 deletions src/DI/ExtensionConfiguration.php

This file was deleted.

24 changes: 0 additions & 24 deletions src/DI/HttpClientConfiguration.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function fetch(string $ico) : SimpleXMLElement
try {
$xml = simplexml_load_string($contents);
}
catch (SimplexmlException $e) {
catch (SimplexmlException) {
throw (new IcoNotFoundException($ico))->setResponse($response);
}

Expand Down

0 comments on commit e87456c

Please sign in to comment.