Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: paragonie/random_compat
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.20
Choose a base ref
...
head repository: paragonie/random_compat
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jun 19, 2021

  1. Update .gitattributes

    williamdes committed Jun 19, 2021
    Copy the full SHA
    9a08bcd View commit details

Commits on Aug 8, 2021

  1. Copy the full SHA
    76d27d0 View commit details
  2. GH Actions: explicitly set code coverage to none

    As no code coverage is being recorded for these builds, it is good practice to explicitly set `coverage: none` in `setup-php`.
    This fixes a warning on PHP 5.3 stating that Xdebug is on.
    jrfnl committed Aug 8, 2021
    Copy the full SHA
    e386675 View commit details
  3. GH Actions: enable Composer caching

    ... by using the `ramsey/composer-install` action.
    
    This means that the Composer downloads directory for dependencies will be cached and restored on each build. This conserves resources and should also make builds faster.
    
    Ref: https://github.com/marketplace/actions/install-composer-dependencies
    jrfnl committed Aug 8, 2021
    Copy the full SHA
    6ab88bd View commit details
  4. GH Actions: split off Psalm to separate workflow

    Psalm does not need to be run against multiple PHP versions. Running it once should be enough.
    
    With that in mind, this commit:
    * Introduces a separate, dedicated workflow which only installs and runs Psalm.
    * Removes the Psalm related steps from the `CI` workflow.
    * Removes Psalm from the `tools` setting for `setup-php`.
    jrfnl committed Aug 8, 2021
    Copy the full SHA
    64256a0 View commit details
  5. GH Actions: clean up running of the tests

    In contrast to Sodium Compat, the tests for this package _were_ running on the low PHP versions.
    
    However, the point remains that PHPUnit was being installed 3 (!) times, once via the `setup-php` action, once via the `composer install` and once via the `php-actions/phpunit` action.
    
    This simplifies the script and ensures that the tests are always run against the most appropriate PHPUnit version for the PHP version against which the tests are being run, by:
    * Remove the installing of PHPUnit via `setup-php`.
    * Remove the use of the `php-actions/phpunit` action.
    * Defer to the Composer installed PHPUnit version in all cases.
    
    I'm also removing the explicit ini settings for the jobs.
    These look like they were copied over from example code, but these values don't have any effect on the test runs in these workflows, so may as well be removed.
    jrfnl committed Aug 8, 2021
    Copy the full SHA
    d0bbad2 View commit details
  6. GH Actions: merge "moderate" and "modern" jobs

    As there is now effectively no difference anymore between the `moderate` and `modern` jobs, these jobs can now be merged into one.
    jrfnl committed Aug 8, 2021
    Copy the full SHA
    71c5eb7 View commit details
  7. GH Actions: set error reporting to E_ALL

    The default setting for `error_reporting` used by the SetupPHP action is `error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT` and `display_errors` is set to `Off`.
    
    For the purposes of CI, I'd recommend running with `E_ALL` and `display_errors=On` to ensure **all** PHP notices are shown.
    
    Ref: shivammathur/setup-php#469
    jrfnl committed Aug 8, 2021
    Copy the full SHA
    c84f7b7 View commit details
  8. GH Actions: enable testing against PHP 8.1

    For now, this build is still allowed to fail.
    jrfnl committed Aug 8, 2021
    Copy the full SHA
    8100036 View commit details
  9. Merge pull request #172 from jrfnl/feature/ghactions-fix-it

    GH Actions: run tests against PHP 8.1 and other tweaks
    paragonie-security authored Aug 8, 2021
    Copy the full SHA
    73f1f02 View commit details
  10. Merge pull request #171 from williamdes/master

    Update .gitattributes
    paragonie-security authored Aug 8, 2021
    Copy the full SHA
    32e99a1 View commit details

Commits on Sep 25, 2021

  1. PHPUnit: update configuration

    PHPUnit just released version 9.5.10 and 8.5.21.
    
    This contains a particular (IMO breaking) change:
    
    > * PHPUnit no longer converts PHP deprecations to exceptions by default (configure `convertDeprecationsToExceptions="true"` to enable this)
    
    Let's unpack this:
    
    Previously (PHPUnit < 9.5.10/8.5.21), if PHPUnit would encounter a PHP native deprecation notice, it would:
    1. Show a test which causes a deprecation notice to be thrown as **"errored"**,
    2. Show the **first** deprecation notice it encountered and
    3. PHPUnit would exit with a **non-0 exit code** (2), which will fail a CI build.
    
    As of PHPUnit 9.5.10/8.5.21, if PHPUnit encounters a PHP native deprecation notice, it will no longer do so. Instead PHPUnit will:
    1. Show a test which causes a PHP deprecation notice to be thrown as **"risky"**,
    2. Show the **all** deprecation notices it encountered and
    3. PHPUnit will exit with a **0 exit code**, which will show a CI build as passing.
    
    This commit reverts PHPUnit to the previous behaviour by adding `convertDeprecationsToExceptions="true"` to the PHPUnit configuration.
    
    Refs:
    * https://github.com/sebastianbergmann/phpunit/blob/9.5/ChangeLog-8.5.md
    * https://github.com/sebastianbergmann/phpunit/blob/9.5/ChangeLog-9.5.md
    jrfnl committed Sep 25, 2021
    Copy the full SHA
    0c1394f View commit details

Commits on Oct 4, 2021

  1. Merge pull request #173 from jrfnl/feature/phpunit-update-config

    PHPUnit: update configuration
    paragonie-security authored Oct 4, 2021
    Copy the full SHA
    cba4096 View commit details

Commits on Dec 25, 2021

  1. GH Actions: version update for ramsey/composer-install

    The action used to install Composer packages and handle the caching has released a new major (and some follow-up patch releases), which means, the action reference needs to be updated to benefit from it.
    
    Refs:
    * https://github.com/ramsey/composer-install/releases/tag/2.0.0
    * https://github.com/ramsey/composer-install/releases/tag/2.0.1
    * https://github.com/ramsey/composer-install/releases/tag/2.0.2
    jrfnl committed Dec 25, 2021
    Copy the full SHA
    4cd8bc7 View commit details

Commits on Jan 17, 2022

  1. Merge pull request #174 from jrfnl/feature/ghactions-update-composer-…

    …action
    
    GH Actions: version update for `ramsey/composer-install`
    paragonie-security authored Jan 17, 2022
    Copy the full SHA
    9174875 View commit details

Commits on Feb 16, 2022

  1. Copy the full SHA
    76dbb53 View commit details
  2. Fix issue #175

    paragonie-security committed Feb 16, 2022
    Copy the full SHA
    4958521 View commit details
  3. Copy the full SHA
    96c132c View commit details

Commits on Mar 5, 2022

  1. GH Actions: version update for various predefined actions

    A number of predefined actions have had major release, which warrant an update to the workflow(s).
    
    These updates don't actually contain any changed functionality, they are mostly just a change of the Node version used by the action itself (from Node 14 to Node 16).
    
    Refs:
    * https://github.com/actions/checkout/releases
    jrfnl committed Mar 5, 2022
    Copy the full SHA
    a0ef17f View commit details

Commits on Mar 22, 2022

  1. Merge pull request #177 from jrfnl/feature/ghactions-update-various-a…

    …ctions
    
    GH Actions: version update for various predefined actions
    paragonie-security authored Mar 22, 2022
    Copy the full SHA
    23ba782 View commit details

Commits on Jun 19, 2022

  1. GH Actions: run tests against PHP 8.2

    The first alpha of PHP 8.2 was released nearly two weeks ago, so let's start testing against PHP 8.2
    
    Notes:
    * Test runs again PHP 8.1 were still marked as "allowed to fail".
        This has been changed to allow PHP 8.2 to fail, but no longer allow failures for PHP 8.1.
    jrfnl committed Jun 19, 2022
    Copy the full SHA
    e5f04a4 View commit details
  2. Copy the full SHA
    990580f View commit details
  3. Merge pull request #180 from jrfnl/feature/ghactions-run-tests-agains…

    …t-php-8.2
    
    GH Actions: run tests against PHP 8.2
    paragonie-security authored Jun 19, 2022
    Copy the full SHA
    4957160 View commit details
  4. Copy the full SHA
    64f3265 View commit details

Commits on Sep 9, 2024

  1. GH Actions: update PHP versions in workflows

    PHP 8.2 and 8.3 have been released quite a while ago and PHP 8.4 is expected towards end of November, so adding PHP 8.3 and 8.4 to the matrix and no longer allowing PHP 8.2 or 8.3 to fail the build.
    
    Builds against PHP 8.4 are still allowed to fail for now.
    jrfnl committed Sep 9, 2024
    Copy the full SHA
    5c150cb View commit details
  2. GH Actions: update the actions/checkout action runner

    The v3 version still uses Node 16, while GHA will stop supporting that soonish. Using v4 fixes that.
    jrfnl committed Sep 9, 2024
    Copy the full SHA
    5112281 View commit details
  3. GH Actions: update the ramsey/composer-install action runner

    The v2 version still uses Node 16, while GHA will stop supporting that soonish. Using v3 fixes that.
    jrfnl committed Sep 9, 2024
    Copy the full SHA
    0d047e6 View commit details

Commits on Sep 10, 2024

  1. Merge pull request #185 from jrfnl/feature/ghactions-tweak-php-versions

    GH Actions: update PHP versions in workflows
    paragonie-security authored Sep 10, 2024
    Copy the full SHA
    bf95de2 View commit details
Showing with 71 additions and 67 deletions.
  1. +1 −1 .gitattributes
  2. +27 −59 .github/workflows/ci.yml
  3. +30 −0 .github/workflows/psalm.yml
  4. +1 −1 composer.json
  5. +1 −1 lib/random.php
  6. +1 −1 phpunit.xml.dist
  7. +1 −1 psalm.xml
  8. +3 −1 tests/unit/RandomBytesTest.php
  9. +6 −2 tests/unit/RandomIntTest.php
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/.github export-ignore
/build-phar.sh export-ignore
/CHANGELOG.md export-ignore
/RATIONALE.md export-ignore
86 changes: 27 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -8,95 +8,63 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-16.04']
operating-system: ['ubuntu-18.04']
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0']
phpunit-versions: ['7.5.20']
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
ini-values: post_max_size=256M, max_execution_time=180
tools: psalm, phpunit:${{ matrix.phpunit-versions }}
ini-values: error_reporting=-1, display_errors=On
coverage: none

- name: Install dependencies
run: composer self-update --1; composer install
- name: Use Composer 1.x
run: composer self-update --1

- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"

- name: PHPUnit tests
uses: php-actions/phpunit@v2
with:
memory_limit: 256M
run: vendor/bin/phpunit

moderate:
moderate-modern:
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.1', '7.2', '7.3']
phpunit-versions: ['latest']
steps:
- name: Checkout
uses: actions/checkout@v2
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, sodium
ini-values: post_max_size=256M, max_execution_time=180
tools: psalm, phpunit:${{ matrix.phpunit-versions }}

- name: Install dependencies
run: composer install
continue-on-error: ${{ matrix.php-versions == '8.4' }}

- name: Modernize dependencies
run: composer require --dev "phpunit/phpunit:>=4"

- name: PHPUnit tests
uses: php-actions/phpunit@v2
timeout-minutes: 30
with:
memory_limit: 256M

modern:
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.4', '8.0']
phpunit-versions: ['latest']
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, sodium
ini-values: post_max_size=256M, max_execution_time=180
tools: psalm, phpunit:${{ matrix.phpunit-versions }}

- name: Install dependencies
run: composer install
ini-values: error_reporting=-1, display_errors=On
coverage: none

- name: Modernize dependencies
run: composer require --dev "phpunit/phpunit:>=4"
run: composer require --dev --no-update "phpunit/phpunit:>=4"

- name: PHPUnit tests
uses: php-actions/phpunit@v2
timeout-minutes: 30
with:
memory_limit: 256M
- name: Install Composer dependencies (PHP < 8.4)
if: ${{ matrix.php-versions != '8.4' }}
uses: "ramsey/composer-install@v3"

- name: Install Psalm
run: rm composer.lock && composer require --dev vimeo/psalm:^4
- name: Install Composer dependencies - ignore-platform-reqs (PHP 8.4)
if: ${{ matrix.php-versions == '8.4' }}
uses: "ramsey/composer-install@v3"
with:
composer-options: --ignore-platform-reqs

- name: Static Analysis
run: vendor/bin/psalm
- name: PHPUnit tests
run: vendor/bin/phpunit
30 changes: 30 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Psalm

on: [push]

jobs:
psalm:
name: Psalm on PHP ${{ matrix.php-versions }}
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.4']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: psalm:4
coverage: none

- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"
with:
composer-options: --no-dev

- name: Static Analysis
run: psalm
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
"php": ">=5.2.0"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*"
"phpunit/phpunit": "*"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
2 changes: 1 addition & 1 deletion lib/random.php
Original file line number Diff line number Diff line change
@@ -183,7 +183,7 @@ class_exists('COM')
try {
$RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
/** @psalm-suppress TypeDoesNotContainType */
if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
if (is_callable(array($RandomCompatCOMtest, 'GetRandom'))) {
// See random_bytes_com_dotnet.php
require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php';
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" backupStaticAttributes="false" bootstrap="phpunit-autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" backupStaticAttributes="false" bootstrap="phpunit-autoload.php" colors="true" convertDeprecationsToExceptions="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./lib</directory>
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<psalm
autoloader="psalm-autoload.php"
errorLevel="1"
useDocblockTypes="true"
totallyTyped="true"
>
<projectFiles>
<directory name="lib" />
4 changes: 3 additions & 1 deletion tests/unit/RandomBytesTest.php
Original file line number Diff line number Diff line change
@@ -40,7 +40,9 @@ public function testOutput()
random_bytes(12),
random_bytes(64),
random_bytes(64),
random_bytes(1.5)
PHP_VERSION_ID < 80100
? random_bytes(1.5)
: random_bytes(1)
);

$this->assertTrue(
8 changes: 6 additions & 2 deletions tests/unit/RandomIntTest.php
Original file line number Diff line number Diff line change
@@ -16,10 +16,14 @@ public function testOutput()
random_int(-1000, 1000),
random_int(~PHP_INT_MAX, PHP_INT_MAX),
random_int("0", "1"),
random_int(0.11111, 0.99999),
PHP_VERSION_ID < 80100
? random_int(0.11111, 0.99999)
: 0,
random_int($half_neg_max, PHP_INT_MAX),
random_int(0.0, 255.0),
random_int(-4.5, -4.5),
PHP_VERSION_ID < 80100
? random_int(-4.5, -4.5)
: -4,
random_int("1337e3","1337e3")
);