require php 8.0

This commit is contained in:
azjezz 2021-05-14 14:15:55 +01:00 committed by Saif Eddin Gmati
parent 336653fabb
commit bff689c862
23 changed files with 33 additions and 46 deletions

View File

@ -1,6 +1,6 @@
name: "coding standards" name: "coding standards"
on: on:
pull_request: ~ pull_request: ~
push: ~ push: ~
@ -15,7 +15,7 @@ jobs:
- name: "installing PHP" - name: "installing PHP"
uses: "shivammathur/setup-php@v2" uses: "shivammathur/setup-php@v2"
with: with:
php-version: "7.4" php-version: "8.0"
ini-values: memory_limit=-1 ini-values: memory_limit=-1
tools: composer:v2, cs2pr tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json extensions: bcmath, mbstring, intl, sodium, json

View File

@ -1,6 +1,6 @@
name: "documentation check" name: "documentation check"
on: on:
pull_request: ~ pull_request: ~
push: ~ push: ~
@ -15,7 +15,7 @@ jobs:
- name: "installing PHP" - name: "installing PHP"
uses: "shivammathur/setup-php@v2" uses: "shivammathur/setup-php@v2"
with: with:
php-version: "7.4" php-version: "8.0"
ini-values: memory_limit=-1 ini-values: memory_limit=-1
tools: composer:v2, cs2pr tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json extensions: bcmath, mbstring, intl, sodium, json

View File

@ -15,7 +15,7 @@ jobs:
- name: "installing PHP" - name: "installing PHP"
uses: "shivammathur/setup-php@v2" uses: "shivammathur/setup-php@v2"
with: with:
php-version: "7.4" php-version: "8.0"
ini-values: memory_limit=-1 ini-values: memory_limit=-1
tools: composer:v2, cs2pr tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json extensions: bcmath, mbstring, intl, sodium, json

View File

@ -17,7 +17,7 @@ jobs:
- name: "installing PHP" - name: "installing PHP"
uses: "shivammathur/setup-php@v2" uses: "shivammathur/setup-php@v2"
with: with:
php-version: "7.4" php-version: "8.0"
ini-values: memory_limit=-1 ini-values: memory_limit=-1
tools: composer:v2, cs2pr tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json extensions: bcmath, mbstring, intl, sodium, json

View File

@ -1,6 +1,6 @@
name: "unit tests" name: "unit tests"
on: on:
pull_request: ~ pull_request: ~
push: ~ push: ~
@ -13,7 +13,6 @@ jobs:
strategy: strategy:
matrix: matrix:
php-version: php-version:
- "7.4"
- "8.0" - "8.0"
operating-system: operating-system:
- "macos-latest" - "macos-latest"

1
.gitignore vendored
View File

@ -17,6 +17,7 @@
# php-cs-fixer cache # php-cs-fixer cache
/.php_cs.cache /.php_cs.cache
/.php-cs-fixer.cache
# phpunit cache # phpunit cache
/tools/phpunit/.phpunit.result.cache /tools/phpunit/.phpunit.result.cache

View File

@ -14,11 +14,11 @@ install-unit-tests-dependencies:
install: install-root-dependencies install-coding-standard-dependencies install-static-analysis-dependencies install-unit-tests-dependencies install: install-root-dependencies install-coding-standard-dependencies install-static-analysis-dependencies install-unit-tests-dependencies
coding-standard-fix: coding-standard-fix:
php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php_cs.dist php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php_cs.dist.php
php tools/php-codesniffer/vendor/bin/phpcbf --basepath=. --standard=tools/php-codesniffer/.phpcs.xml php tools/php-codesniffer/vendor/bin/phpcbf --basepath=. --standard=tools/php-codesniffer/.phpcs.xml
coding-standard-check: coding-standard-check:
php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php_cs.dist --dry-run php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php_cs.dist.php --dry-run
php tools/php-codesniffer/vendor/bin/phpcs --basepath=. --standard=tools/php-codesniffer/.phpcs.xml php tools/php-codesniffer/vendor/bin/phpcs --basepath=. --standard=tools/php-codesniffer/.phpcs.xml
static-analysis: static-analysis:

View File

@ -10,7 +10,7 @@
} }
], ],
"require": { "require": {
"php": "^7.4 || ^8.0", "php": "^8.0",
"ext-bcmath": "*", "ext-bcmath": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",

View File

@ -24,7 +24,7 @@ namespace Psl\Iter;
* @param iterable<T> $iterable * @param iterable<T> $iterable
* @param T $value * @param T $value
*/ */
function contains(iterable $iterable, $value): bool function contains(iterable $iterable, mixed $value): bool
{ {
foreach ($iterable as $v) { foreach ($iterable as $v) {
if ($value === $v) { if ($value === $v) {

View File

@ -10,10 +10,10 @@ namespace Psl\Iter;
* @template Tk * @template Tk
* @template Tv * @template Tv
* *
* @param iterable<Tk, Tv> $iterable, * @param iterable<Tk, Tv> $iterable
* @param Tk $key * @param Tk $key
*/ */
function contains_key(iterable $iterable, $key): bool function contains_key(iterable $iterable, mixed $key): bool
{ {
foreach ($iterable as $k => $_v) { foreach ($iterable as $k => $_v) {
if ($key === $k) { if ($key === $k) {

View File

@ -17,11 +17,9 @@ use const JSON_THROW_ON_ERROR;
* *
* @throws Exception\DecodeException If an error occurred. * @throws Exception\DecodeException If an error occurred.
* *
* @return mixed
*
* @pure * @pure
*/ */
function decode(string $json, bool $assoc = true) function decode(string $json, bool $assoc = true): mixed
{ {
try { try {
/** @var mixed $value */ /** @var mixed $value */

View File

@ -18,13 +18,11 @@ use const JSON_UNESCAPED_UNICODE;
/** /**
* Returns a string containing the JSON representation of the supplied value. * Returns a string containing the JSON representation of the supplied value.
* *
* @param mixed $value
*
* @pure * @pure
* *
* @throws Exception\EncodeException If an error occurred. * @throws Exception\EncodeException If an error occurred.
*/ */
function encode($value, bool $pretty = false, int $flags = 0): string function encode(mixed $value, bool $pretty = false, int $flags = 0): string
{ {
$flags |= JSON_UNESCAPED_UNICODE $flags |= JSON_UNESCAPED_UNICODE
| JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_SLASHES

View File

@ -17,7 +17,7 @@ use Psl\Type;
* *
* @return T * @return T
*/ */
function typed(string $json, Type\TypeInterface $type) function typed(string $json, Type\TypeInterface $type): mixed
{ {
try { try {
return $type->coerce(decode($json)); return $type->coerce(decode($json));

View File

@ -49,7 +49,6 @@ function base_convert(string $value, int $from_base, int $to_base): string
Psl\invariant($to_base >= 2 && $to_base <= 36, 'Expected $to_base to be between 2 and 36, got %d', $to_base); Psl\invariant($to_base >= 2 && $to_base <= 36, 'Expected $to_base to be between 2 and 36, got %d', $to_base);
$from_alphabet = Byte\slice(Str\ALPHABET_ALPHANUMERIC, 0, $from_base); $from_alphabet = Byte\slice(Str\ALPHABET_ALPHANUMERIC, 0, $from_base);
/** @var numeric-string $result_decimal */
$result_decimal = '0'; $result_decimal = '0';
$place_value = bcpow((string)$from_base, (string)(Byte\length($value) - 1)); $place_value = bcpow((string)$from_base, (string)(Byte\length($value) - 1));
foreach (Byte\chunk($value) as $digit) { foreach (Byte\chunk($value) as $digit) {
@ -69,7 +68,6 @@ function base_convert(string $value, int $from_base, int $to_base): string
$result = ''; $result = '';
do { do {
$result = $to_alphabet[(int)bcmod($result_decimal, (string)$to_base)] . $result; $result = $to_alphabet[(int)bcmod($result_decimal, (string)$to_base)] . $result;
/** @var numeric-string $result_decimal */
$result_decimal = bcdiv($result_decimal, (string)$to_base); $result_decimal = bcdiv($result_decimal, (string)$to_base);
} while (bccomp($result_decimal, '0') > 0); } while (bccomp($result_decimal, '0') > 0);

View File

@ -21,12 +21,12 @@ final class Success implements ResultInterface
* *
* @readonly * @readonly
*/ */
private $value; private mixed $value;
/** /**
* @param T $value * @param T $value
*/ */
public function __construct($value) public function __construct(mixed $value)
{ {
$this->value = $value; $this->value = $value;
} }
@ -38,7 +38,7 @@ final class Success implements ResultInterface
* *
* @psalm-mutation-free * @psalm-mutation-free
*/ */
public function getResult() public function getResult(): mixed
{ {
return $this->value; return $this->value;
} }

View File

@ -21,9 +21,9 @@ use function stream_get_contents;
* *
* @param string $command The command to execute. * @param string $command The command to execute.
* @param list<string> $arguments The command arguments listed as separate entries. * @param list<string> $arguments The command arguments listed as separate entries.
* @param string $working_directory The initial working directory for the command. * @param null|string $working_directory The initial working directory for the command.
* This must be an absolute directory path, or null if you want to * This must be an absolute directory path, or null if you want to
* use the default value ( the current directory ) * use the default value ( the current directory )
* @param array<string, string> $environment A dict with the environment variables for the command that * @param array<string, string> $environment A dict with the environment variables for the command that
* will be run. * will be run.
* @param bool $escape_arguments If set to true ( default ), all $arguments will be escaped using `escape_argument`. * @param bool $escape_arguments If set to true ( default ), all $arguments will be escaped using `escape_argument`.

View File

@ -23,9 +23,6 @@ function slice(string $string, int $offset, ?int $length = null): string
{ {
Psl\invariant(null === $length || $length >= 0, 'Expected a non-negative length.'); Psl\invariant(null === $length || $length >= 0, 'Expected a non-negative length.');
$offset = Psl\Internal\validate_offset($offset, length($string)); $offset = Psl\Internal\validate_offset($offset, length($string));
$result = null === $length
? substr($string, $offset)
: substr($string, $offset, $length);
return false === $result ? '' : $result; return null === $length ? substr($string, $offset) : substr($string, $offset, $length);
} }

View File

@ -1,7 +1,7 @@
{ {
"type": "project", "type": "project",
"require": { "require": {
"php": "^7.4 || ^8.0", "php": "^8.0",
"ext-bcmath": "*", "ext-bcmath": "*",
"ext-intl": "*", "ext-intl": "*",
"ext-json": "*", "ext-json": "*",

View File

@ -1,6 +1,6 @@
<?php <?php
return PhpCsFixer\Config::create() return (new PhpCsFixer\Config())
->setFinder( ->setFinder(
\Symfony\Component\Finder\Finder::create() \Symfony\Component\Finder\Finder::create()
->in([ ->in([
@ -25,14 +25,10 @@ return PhpCsFixer\Config::create()
'list_syntax' => [ 'list_syntax' => [
'syntax' => 'short', 'syntax' => 'short',
], ],
'lowercase_constants' => true,
'multiline_comment_opening_closing' => true, 'multiline_comment_opening_closing' => true,
'native_function_casing' => true, 'native_function_casing' => true,
'no_empty_phpdoc' => true, 'no_empty_phpdoc' => true,
'no_leading_import_slash' => true, 'no_leading_import_slash' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_unused_imports' => true, 'no_unused_imports' => true,
'no_useless_else' => true, 'no_useless_else' => true,
'no_useless_return' => true, 'no_useless_return' => true,

View File

@ -1,12 +1,12 @@
{ {
"type": "project", "type": "project",
"require": { "require": {
"php": "^7.4 || ^8.0", "php": "^8.0",
"ext-bcmath": "*", "ext-bcmath": "*",
"ext-intl": "*", "ext-intl": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-sodium": "*", "ext-sodium": "*",
"friendsofphp/php-cs-fixer": "^2.18" "friendsofphp/php-cs-fixer": "^3.0"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"type": "project", "type": "project",
"require": { "require": {
"php": "^7.4 || ^8.0", "php": "^8.0",
"ext-bcmath": "*", "ext-bcmath": "*",
"ext-intl": "*", "ext-intl": "*",
"ext-json": "*", "ext-json": "*",
@ -9,4 +9,4 @@
"ext-sodium": "*", "ext-sodium": "*",
"phpunit/phpunit": "^9.5" "phpunit/phpunit": "^9.5"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"type": "project", "type": "project",
"require": { "require": {
"php": "^7.4 || ^8.0", "php": "^8.0",
"ext-bcmath": "*", "ext-bcmath": "*",
"ext-intl": "*", "ext-intl": "*",
"ext-json": "*", "ext-json": "*",

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<psalm totallyTyped="true" forbidEcho="true" strictBinaryOperands="true" phpVersion="7.4" allowPhpStormGenerics="true" allowStringToStandInForClass="true" rememberPropertyAssignmentsAfterCall="false" checkForThrowsDocblock="true" checkForThrowsInGlobalScope="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="baseline.xml"> <psalm totallyTyped="true" forbidEcho="true" strictBinaryOperands="true" phpVersion="8.0" allowStringToStandInForClass="true" rememberPropertyAssignmentsAfterCall="false" checkForThrowsDocblock="true" checkForThrowsInGlobalScope="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="baseline.xml">
<projectFiles> <projectFiles>
<directory name="../../src" /> <directory name="../../src" />
<directory name="../../integration" /> <directory name="../../integration" />