Skip to content

Commit

Permalink
testing php 8.1 (#123)
Browse files Browse the repository at this point in the history
* testing php 8.1

* php 8 and 8.1 fixes

* narrowing php versions
  • Loading branch information
jaydiablo authored Dec 4, 2021
1 parent cbc340d commit 734f636
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 71 deletions.
34 changes: 10 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.2', '7.3', '7.4']
php-versions: ['7.4', '8.0', '8.1']
composer-args: ['', '--prefer-lowest']
include:
- operating-system: ubuntu-latest
php-versions: '8.0'
composer-args: '--ignore-platform-reqs --no-scripts'
- operating-system: ubuntu-latest
php-versions: '8.0'
composer-args: '--prefer-lowest --ignore-platform-reqs --no-scripts'
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v2.4.0
- name: Setup PHP
uses: shivammathur/setup-php@2.10.0
uses: shivammathur/setup-php@2.16.0
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring
Expand All @@ -39,7 +32,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/[email protected].4
uses: actions/[email protected].7
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: php${{ matrix.php-versions }}-composer-${{ matrix.composer-args }}-${{ hashFiles('**/composer.json') }}
Expand All @@ -50,21 +43,14 @@ jobs:
- name: PHPStan
run: composer phpstan
- name: Code Style Check
env:
PHP_CS_FIXER_IGNORE_ENV: true
run: composer style-check -- --format=checkstyle | cs2pr
- name: Test
run: composer test-with-coverage
- name: Upload Coverage
run: bash <(curl -s https://codecov.io/bash) -f ./clover.xml
merge-me:
name: Merge me!
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Merge me!
uses: ridedott/merge-me-action@master
uses: codecov/codecov-action@v2
with:
# This must be used as GitHub Actions token does not support
# pushing to protected branches.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_LOGIN: 'dependabot[bot]'
files: ./clover.xml
fail_ci_if_error: true
verbose: true
32 changes: 32 additions & 0 deletions .github/workflows/merge-me.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Merge me!

on:
workflow_run:
types:
- completed
workflows:
- 'Build'

jobs:
merge-me:
name: Merge me!
runs-on: ubuntu-latest
steps:
- # It is often a desired behavior to merge only when a workflow execution
# succeeds. This can be changed as needed.
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Merge me!
uses: ridedott/merge-me-action@v2
with:
# Depending on branch protection rules, a manually populated
# `GITHUB_TOKEN_WORKAROUND` secret with permissions to push to
# a protected branch must be used. This secret can have an arbitrary
# name, as an example, this repository uses `DOTTBOTT_TOKEN`.
#
# When using a custom token, it is recommended to leave the following
# comment for other developers to be aware of the reasoning behind it:
#
# This must be used as GitHub Actions token does not support pushing
# to protected branches.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ENABLE_GITHUB_API_PREVIEW: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/clover.xml
.php_cs.cache
.phpunit.result.cache
.php-cs-fixer.cache
9 changes: 4 additions & 5 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
$config = new PhpCsFixer\Config();
return $config->setRiskyAllowed(true)
->setRules(array(
'@PSR2' => true,
'@PHPUnit60Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'binary_operator_spaces' => array('align_double_arrow' => true, 'align_equals' => true),
'binary_operator_spaces' => array('operators' => array('=' => 'align', '=>' => 'align')),
'single_quote' => true,
'array_syntax' => array('syntax' => 'long'),
'concat_space' => array('spacing' => 'one'),
'psr0' => false
'psr_autoloading' => array('dir' => 'src'),
))
->setUsingCache(true)
->setFinder($finder);
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "BSD-3-Clause",
"prefer-stable": true,
"require": {
"php": "^7.0 || ^8.0",
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"diablomedia/zendframework1-exception": "^1.0.0"
},
"autoload": {
Expand All @@ -27,11 +27,11 @@
}
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"phpstan/phpstan": "0.12.82",
"friendsofphp/php-cs-fixer": "2.18.4",
"maglnet/composer-require-checker": "^1.1.0 || ^2.0.0",
"phpro/grumphp-shim": "^0.22.0 || ^1.1"
"phpunit/phpunit": "^9.5.10",
"phpstan/phpstan": "1.2.0",
"friendsofphp/php-cs-fixer": "3.3.2",
"maglnet/composer-require-checker": "^3.0.0",
"phpro/grumphp-shim": "^1.5.0"
},
"archive": {
"exclude": [
Expand Down
2 changes: 1 addition & 1 deletion grumphp.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ grumphp:
config_file: require-checker-config.json
phpcsfixer2:
allow_risky: true
config: .php_cs
config: .php-cs-fixer.php
phpstan:
configuration: phpstan.neon
phpunit:
Expand Down
2 changes: 1 addition & 1 deletion phpstan-php7.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'count' => 1,
),
array(
'message' => '#Parameter \#1 \$gmpnumber of function gmp_strval expects GMP\|int\|string, resource given\.#',
'message' => '#Parameter \#1 \$gmpnumber of function gmp_strval expects GMP\|int\|string, GMP\|resource\|string given\.#',
'path' => __DIR__ . '/src/Zend/Crypt/Math/BigInteger/Gmp.php',
'count' => 1,
),
Expand Down
5 changes: 5 additions & 0 deletions phpstan-php8.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
'path' => __DIR__ . '/src/Zend/Crypt/Math/BigInteger/Gmp.php',
'count' => 1,
),
array(
'message' => '#Parameter \#1 \$num of function gmp_strval expects GMP\|int\|string, GMP\|resource\|string given\.#',
'path' => __DIR__ . '/src/Zend/Crypt/Math/BigInteger/Gmp.php',
'count' => 1,
),
)
)
);
Expand Down
16 changes: 6 additions & 10 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parameters:
level: 8
paths:
- ./
excludes_analyse:
excludePaths:
- %rootDir%/../../../tests/*
- %rootDir%/../../../vendor/*
bootstrapFiles:
Expand All @@ -25,17 +25,14 @@ parameters:
# Isset calls probably aren't necessary here, Zend_Crypt_Hmac:89|110
- '#Variable \$key in isset\(\) always exists and is not nullable\.#'
- '#Variable \$hash in isset\(\) always exists and is not nullable\.#'
-
message: '#Trying to invoke string but it might not be a callable.#'
path: %currentWorkingDirectory%/src/Zend/Crypt.php
-
message: '#Parameter \#1 \$key of function openssl_pkey_get_details expects (resource|OpenSSLAsymmetricKey), (resource|OpenSSLAsymmetricKey)\|false given\.#'
path: %currentWorkingDirectory%/src/Zend/Crypt/DiffieHellman.php
-
message: '#Parameter \#2 \$(dh_key|private_key) of function openssl_dh_compute_key expects (resource|OpenSSLAsymmetricKey), string given\.#'
path: %currentWorkingDirectory%/src/Zend/Crypt/DiffieHellman.php
-
message: '#Property Zend_Crypt_DiffieHellman::\$_secretKey \(string\) does not accept string\|false\.#'
message: '#Property Zend_Crypt_DiffieHellman::\$_secretKey \(string\|null\) does not accept string\|false\.#'
path: %currentWorkingDirectory%/src/Zend/Crypt/DiffieHellman.php
-
message: '#Property Zend_Crypt_Rsa_Key::\$_details \(array\) does not accept array\|false\.#'
Expand All @@ -62,7 +59,7 @@ parameters:
message: '#Parameter \#1 \$(data|string) of function bin2hex expects string, string\|false given\.#'
path: %currentWorkingDirectory%/src/Zend/Crypt/Math.php
-
message: '#Parameter \#1 \$(function|callback) of function call_user_func_array expects callable\(\): mixed, array\(Zend_Crypt_Math_BigInteger_Interface, string\) given\.#'
message: '#Parameter \#1 \$(function|callback) of function call_user_func_array expects callable\(\): mixed, array{Zend_Crypt_Math_BigInteger_Interface, string} given\.#'
path: %currentWorkingDirectory%/src/Zend/Crypt/Math/BigInteger.php
-
message: '#Parameter \#2 \$(right_operand|num2) of function bcadd expects string, int given\.#'
Expand Down Expand Up @@ -130,9 +127,6 @@ parameters:
-
message: '#Parameter \#1 \$(a|num) of function gmp_sqrt expects GMP\|int\|string, GMP\|resource\|string given\.#'
path: %currentWorkingDirectory%/src/Zend/Crypt/Math/BigInteger/Gmp.php
-
message: '#Parameter \#1 \$(gmpnumber|num) of function gmp_strval expects GMP\|int\|string, GMP\|resource\|string given\.#'
path: %currentWorkingDirectory%/src/Zend/Crypt/Math/BigInteger/Gmp.php
-
message: '#Parameter \#1 \$string of function strlen expects string, float\|int given\.#'
path: %currentWorkingDirectory%/src/Zend/Crypt/Math/BigInteger/Gmp.php
Expand All @@ -151,4 +145,6 @@ parameters:
-
message: '#Parameter \#1 \$value of method Zend_Crypt_Rsa::setCertificateString\(\) expects string, string\|false given\.#'
path: './src/Zend/Crypt/Rsa.php'

-
message: '#Method Zend_Crypt_DiffieHellman::getPrivateKey\(\) should return string but returns string\|null\.#'
path: './src/Zend/Crypt/DiffieHellman.php'
30 changes: 12 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
<phpunit
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
beStrictAboutTestsThatDoNotTestAnything="true"
backupGlobals="true"
stderr="true"
colors="true">
<testsuites>
<testsuite name="default">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" beStrictAboutTestsThatDoNotTestAnything="true" backupGlobals="true" stderr="true" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
10 changes: 5 additions & 5 deletions src/Zend/Crypt/DiffieHellman.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ class Zend_Crypt_DiffieHellman
/**
* Default large prime number; required by the algorithm.
*
* @var string
* @var string|null
*/
private $_prime = null;

/**
* The default generator number. This number must be greater than 0 but
* less than the prime number set.
*
* @var string
* @var string|null
*/
private $_generator = null;

/**
* A private number set by the local user. It's optional and will
* be generated if not set.
*
* @var string
* @var string|null
*/
private $_privateKey = null;

Expand All @@ -74,15 +74,15 @@ class Zend_Crypt_DiffieHellman
/**
* The public key generated by this instance after calling generateKeys().
*
* @var string
* @var string|null
*/
private $_publicKey = null;

/**
* The shared secret key resulting from a completed Diffie Hellman
* exchange
*
* @var string
* @var string|null
*/
private $_secretKey = null;

Expand Down
2 changes: 1 addition & 1 deletion src/Zend/Crypt/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function rand($minimum, $maximum)
if (file_exists('/dev/urandom')) {
$frandom = fopen('/dev/urandom', 'r');
if ($frandom !== false) {
return fread($frandom, strlen($maximum) - 1);
return fread($frandom, strlen($maximum) !== 0 ? strlen($maximum) - 1 : strlen($maximum));
}
}
// This is the only case where this method actually returns a number between minimum
Expand Down
1 change: 1 addition & 0 deletions src/Zend/Crypt/Rsa/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function __toString()
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function count()
{
return $this->_details['bits'];
Expand Down

0 comments on commit 734f636

Please sign in to comment.