Skip to content

Commit

Permalink
Add PHP 8.4, drop PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stephank committed Dec 13, 2024
1 parent 73ea0a1 commit 3e41c00
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/php-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.2', '8.3', '8.4']
name: PHP ${{ matrix.php-versions }} tests
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -20,10 +20,10 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.php-cs-fixer.cache
.phpunit.*
composer.lock
vendor
13 changes: 13 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$config = new PhpCsFixer\Config();

return $config
->setRules([
'@PSR12' => true,
'@PHP82Migration' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
);
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 6.0.0

### PHP support

- Dropped support for PHP `8.1` and lower.
- Added support for PHP `8.4`.

## 5.0.0

### PHP support
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object-oriented interface to a variety of hashing methods.

## Requirements

* PHP `8.1`, `8.2` or PHP `8.3` (recommended)
* PHP `8.2`, `8.3` or PHP `8.4` (recommended)

## Installation

Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@
]
},
"require": {
"php": "8.1.* || 8.2.* || 8.3.*"
"php": "8.2 - 8.4"
},
"require-dev": {
"phpstan/phpstan": "1.10.46",
"phpunit/phpunit": "10.4.2",
"squizlabs/php_codesniffer": "3.7.2"
"phpstan/phpstan": "2.0.3",
"phpunit/phpunit": "11.5.1",
"squizlabs/php_codesniffer": "3.11.2",
"friendsofphp/php-cs-fixer": "^3.65"
}
}
1 change: 1 addition & 0 deletions src/AngryBytes/Hash/HMAC.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function hmac(string $sharedSecret, ...$args): string
{
// Get the data concatenated
$data = '';
/** @var string $arg */
foreach ($args as $arg) {
$data .= $arg;
}
Expand Down
1 change: 1 addition & 0 deletions src/AngryBytes/Hash/Hasher/MD5.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class MD5 implements HasherInterface
public function hash(string $string, array $options = []): string
{
$salt = $options['salt'] ?? '';
assert(is_string($salt));

return md5($string . '-' . $salt);
}
Expand Down
22 changes: 11 additions & 11 deletions tests/AngryBytes/Hash/Test/BlowfishTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public function testSerialized(): void
$hasher = $this->createHasher();

// Complex data
$data = array(
new \stdClass,
array('foo', 'bar'),
12345
);
$data = [
new \stdClass(),
['foo', 'bar'],
12345,
];
$this->assertEquals(
'$2y$15$aa5c57dda7634fc90a92duDv2OoNSn8R.p3.GSoaEZd6/vdiiq9lG',
$hasher->hash($data)
Expand Down Expand Up @@ -80,11 +80,11 @@ public function testObjectVerify(): void
$hasher = $this->createHasher();

// Complex data
$data = array(
new \stdClass,
array('foo', 'bar'),
12345
);
$data = [
new \stdClass(),
['foo', 'bar'],
12345,
];

$this->assertTrue(
$hasher->verify($data, '$2y$15$aa5c57dda7634fc90a92duDv2OoNSn8R.p3.GSoaEZd6/vdiiq9lG')
Expand Down Expand Up @@ -188,7 +188,7 @@ public function testSalt(): void
private function createHasher(): Hash
{
return new Hash(
new BlowfishHasher,
new BlowfishHasher(),
'909b96914de6866224f70f52a13e9fa6'
);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/AngryBytes/Hash/Test/HashLibTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class HashLibTest extends \PHPUnit\Framework\TestCase
public function testValidSalt(): void
{
new Hash(
new \AngryBytes\Hash\Hasher\MD5
new \AngryBytes\Hash\Hasher\MD5()
);

new Hash(
new \AngryBytes\Hash\Hasher\MD5,
new \AngryBytes\Hash\Hasher\MD5(),
str_repeat('a', 20)
);
}
Expand All @@ -34,7 +34,7 @@ public function testSaltTooShort(): void
$this->expectException(\InvalidArgumentException::class);

new Hash(
new \AngryBytes\Hash\Hasher\MD5,
new \AngryBytes\Hash\Hasher\MD5(),
str_repeat('a', 19)
);
}
Expand All @@ -47,7 +47,7 @@ public function testSaltTooLong(): void
$this->expectException(\InvalidArgumentException::class);

new Hash(
new \AngryBytes\Hash\Hasher\MD5,
new \AngryBytes\Hash\Hasher\MD5(),
str_repeat('a', CRYPT_SALT_LENGTH + 1)
);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/AngryBytes/Hash/Test/MD5Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testHashObject(): void
{
$hasher = $this->createHasher();

$obj = new \stdClass;
$obj = new \stdClass();
$obj->foo = 'bar';

$this->assertEquals(
Expand Down Expand Up @@ -74,7 +74,7 @@ public function testVerifyHashObject(): void
{
$hasher = $this->createHasher();

$obj = new \stdClass;
$obj = new \stdClass();
$obj->foo = 'bar';

$this->assertTrue(
Expand All @@ -94,7 +94,7 @@ public function testVerifyHashObject(): void
private function createHasher(): Hash
{
return new Hash(
new MD5Hasher,
new MD5Hasher(),
'909b96914de6866224f70f52a13e9fa6'
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/AngryBytes/Hash/Test/PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function testCostTooHigh(): void
private function createHasher(): Hash
{
return new Hash(
new PasswordHasher
new PasswordHasher()
);
}
}

0 comments on commit 3e41c00

Please sign in to comment.