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

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
operating-system:
- "macos-latest"

1
.gitignore vendored
View File

@ -17,6 +17,7 @@
# php-cs-fixer cache
/.php_cs.cache
/.php-cs-fixer.cache
# phpunit 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
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
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
static-analysis:

View File

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

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@ use Psl\Type;
*
* @return T
*/
function typed(string $json, Type\TypeInterface $type)
function typed(string $json, Type\TypeInterface $type): mixed
{
try {
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);
$from_alphabet = Byte\slice(Str\ALPHABET_ALPHANUMERIC, 0, $from_base);
/** @var numeric-string $result_decimal */
$result_decimal = '0';
$place_value = bcpow((string)$from_base, (string)(Byte\length($value) - 1));
foreach (Byte\chunk($value) as $digit) {
@ -69,7 +68,6 @@ function base_convert(string $value, int $from_base, int $to_base): string
$result = '';
do {
$result = $to_alphabet[(int)bcmod($result_decimal, (string)$to_base)] . $result;
/** @var numeric-string $result_decimal */
$result_decimal = bcdiv($result_decimal, (string)$to_base);
} while (bccomp($result_decimal, '0') > 0);

View File

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

View File

@ -21,9 +21,9 @@ use function stream_get_contents;
*
* @param string $command The command to execute.
* @param list<string> $arguments The command arguments listed as separate entries.
* @param string $working_directory The initial working directory for the command.
* This must be an absolute directory path, or null if you want to
* use the default value ( the current directory )
* @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
* use the default value ( the current directory )
* @param array<string, string> $environment A dict with the environment variables for the command that
* will be run.
* @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.');
$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",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"ext-bcmath": "*",
"ext-intl": "*",
"ext-json": "*",

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
<?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>
<directory name="../../src" />
<directory name="../../integration" />