Skip to content

Commit

Permalink
Add/php 8 2 (#11)
Browse files Browse the repository at this point in the history
* add 8-2 test suite

* add composer.lock

* update composer

* remove composer.lock

* upgrade psalm

* fix typecheck

* fix composer

* fix composer

* fix composer

* use correct semver

* test psalm from composer

* psalm 5.6

* use whatever psalm is available

* use manual download
  • Loading branch information
ins0 authored Mar 30, 2023
1 parent 930b408 commit 0d9d78b
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 56 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['5.6', '7.4', '8.0']
php-versions: ['5.x', '7.x', '8.x']
name: Testing PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
Expand All @@ -26,15 +26,19 @@ jobs:
run: composer test
typecheck:
runs-on: ubuntu-latest
name: Typechecks against PSALM
name: TypeChecks against PSALM
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.x'
- name: Check PHP Version
run: php -v
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
- name: Downloading
run: wget https://github.com/vimeo/psalm/releases/download/3.12.1/psalm.phar
run: wget https://github.com/vimeo/psalm/releases/download/5.9.0/psalm.phar
- name: Typechecking
run: php psalm.phar
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/vendor/
/.idea/
/.phpunit.cache/
.phpunit.result.cache
composer.lock
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "library",
"license": "MIT",
"homepage": "https://www.mittwald.de/",
"description": "PHP library for Vault",
"description": "A PHP client library for 'Vault by HashiCorp'",
"require": {
"ext-json": "*",
"guzzlehttp/psr7": "^1.6",
Expand Down
24 changes: 12 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="./tests/bootstrap.php">
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="The project's test suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="The project's test suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
6 changes: 2 additions & 4 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
<psalm
totallyTyped="false"
allowPhpStormGenerics="true"
errorLevel="2"
resolveFromConfigFile="true"
allowStringToStandInForClass="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
Expand Down
9 changes: 6 additions & 3 deletions src/VaultPHP/Authentication/Provider/AppRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ class AppRole extends AbstractAuthenticationProvider
{
/** @var string */
private $roleId;

/** @var string */
private $secretId;

/** @var string */
private $endpoint = '/v1/auth/approle/login';
/** @var string */
private $endpoint = '/v1/auth/approle/login';

/**
* AppRole constructor.
* @param string $AppRole
* @param $roleId
* @param $secretId
*/
public function __construct($roleId, $secretId)
{
Expand Down
8 changes: 5 additions & 3 deletions src/VaultPHP/Response/BulkEndpointResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

/**
* Class BulkEndpointResponse
* @package VaultPHP\Response
*
* @template-implements Iterator<int>
* @template-implements ArrayAccess<int, mixed>
*/
class BulkEndpointResponse extends EndpointResponse implements Iterator, ArrayAccess, Countable
{
Expand Down Expand Up @@ -48,7 +50,7 @@ public function getBatchResults() {
}

/**
* @return mixed
* @return int|null
*/
public function current()
{
Expand All @@ -68,7 +70,7 @@ public function next()
*/
public function key()
{
return (int) $this->iteratorPosition;
return $this->iteratorPosition;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/VaultPHP/Response/EndpointResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EndpointResponse implements EndpointResponseInterface
* @param array|object $data
* @param array $meta
*/
public function __construct($data = [], $meta = [])
final public function __construct($data = [], $meta = [])
{
$this->metaData = new MetaData($meta);
$this->populateData($data);
Expand Down Expand Up @@ -106,6 +106,6 @@ public function getMetaData()
*/
public function hasErrors()
{
return (bool) $this->getMetaData()->hasErrors();
return $this->getMetaData()->hasErrors();
}
}
2 changes: 1 addition & 1 deletion src/VaultPHP/Response/MetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ public function containsError($error) {
public function hasErrors()
{
$errors = $this->getErrors();
return $errors !== NULL && is_array($errors) && count($errors) >= 1;
return is_array($errors) && count($errors) >= 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getCiphertext()

/**
* @param string $ciphertext
* @return $this
* @return self
*/
public function setCiphertext($ciphertext)
{
Expand All @@ -63,7 +63,7 @@ public function getNonce()

/**
* @param string|null $nonce
* @return $this
* @return self
*/
public function setNonce($nonce)
{
Expand All @@ -81,7 +81,7 @@ public function getContext()

/**
* @param string|null $context
* @return $this
* @return self
*/
public function setContext($context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getPlaintext()

/**
* @param string $plaintext
* @return $this
* @return self
*/
public function setPlaintext($plaintext)
{
Expand All @@ -63,7 +63,7 @@ public function getNonce()

/**
* @param string|null $nonce
* @return $this
* @return self
*/
public function setNonce($nonce)
{
Expand All @@ -81,7 +81,7 @@ public function getContext()

/**
* @param string|null $context
* @return $this
* @return self
*/
public function setContext($context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function setDeletionAllowed($allow)
*/
public function setMinDecryptionVersion($min_decryption_version)
{
$this->min_decryption_version = (int)$min_decryption_version;
$this->min_decryption_version = $min_decryption_version;
return $this;
}

Expand All @@ -66,7 +66,7 @@ public function setMinDecryptionVersion($min_decryption_version)
*/
public function setMinEncryptionVersion($min_encryption_version)
{
$this->min_encryption_version = (int)$min_encryption_version;
$this->min_encryption_version = $min_encryption_version;
return $this;
}

Expand All @@ -76,7 +76,7 @@ public function setMinEncryptionVersion($min_encryption_version)
*/
public function setExportable($exportable)
{
$this->exportable = (bool)$exportable;
$this->exportable = $exportable;
return $this;
}

Expand All @@ -86,7 +86,7 @@ public function setExportable($exportable)
*/
public function setAllowPlaintextBackup($allow_plaintext_backup)
{
$this->allow_plaintext_backup = (bool)$allow_plaintext_backup;
$this->allow_plaintext_backup = $allow_plaintext_backup;
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Class SecretEngineTest
* @package Test\VaultPHP\SecretEngines
*/
abstract class SecretEngineTest extends TestCase
abstract class AbstractSecretEngineTestCase extends TestCase
{
protected function createApiClient($expectedMethod, $expectedPath, $expectedData, $responseData, $responseStatus = 200)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Test\VaultPHP\SecretEngines\Engines\Transit;

use Test\VaultPHP\SecretEngines\SecretEngineTest;
use Test\VaultPHP\SecretEngines\AbstractSecretEngineTestCase;
use VaultPHP\SecretEngines\Engines\Transit\Request\CreateKeyRequest;
use VaultPHP\SecretEngines\Engines\Transit\Response\CreateKeyResponse;
use VaultPHP\SecretEngines\Engines\Transit\EncryptionType;
Expand All @@ -12,7 +12,7 @@
* Class CreateKeyTest
* @package Test\VaultPHP\SecretEngines\Transit
*/
final class CreateKeyTest extends SecretEngineTest
final class CreateKeyTest extends AbstractSecretEngineTestCase
{
public function testApiCall()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Test\VaultPHP\SecretEngines\Engines\Transit;

use Test\VaultPHP\SecretEngines\SecretEngineTest;
use Test\VaultPHP\SecretEngines\AbstractSecretEngineTestCase;
use VaultPHP\SecretEngines\Engines\Transit\Request\DecryptData\DecryptData;
use VaultPHP\SecretEngines\Engines\Transit\Request\DecryptData\DecryptDataBulkRequest;
use VaultPHP\SecretEngines\Engines\Transit\Response\DecryptDataResponse;
Expand All @@ -12,7 +12,7 @@
* Class DecryptDataBulkTest
* @package Test\VaultPHP\SecretEngines\Transit
*/
final class DecryptDataBulkTest extends SecretEngineTest
final class DecryptDataBulkTest extends AbstractSecretEngineTestCase
{
public function testApiCall()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Test\VaultPHP\SecretEngines\Engines\Transit;

use Test\VaultPHP\SecretEngines\SecretEngineTest;
use Test\VaultPHP\SecretEngines\AbstractSecretEngineTestCase;
use VaultPHP\SecretEngines\Engines\Transit\Request\DecryptData\DecryptDataRequest;
use VaultPHP\SecretEngines\Engines\Transit\Response\DecryptDataResponse;
use VaultPHP\SecretEngines\Engines\Transit\Transit;
Expand All @@ -11,7 +11,7 @@
* Class DecryptDataTest
* @package Test\VaultPHP\SecretEngines\Transit
*/
final class DecryptDataTest extends SecretEngineTest
final class DecryptDataTest extends AbstractSecretEngineTestCase
{
public function testApiCall()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Test\VaultPHP\SecretEngines\Engines\Transit;

use Test\VaultPHP\SecretEngines\SecretEngineTest;
use Test\VaultPHP\SecretEngines\AbstractSecretEngineTestCase;
use VaultPHP\SecretEngines\Engines\Transit\Response\DeleteKeyResponse;
use VaultPHP\SecretEngines\Engines\Transit\Transit;

/**
* Class DeleteKeyTest
* @package Test\VaultPHP\SecretEngines\Transit
*/
final class DeleteKeyTest extends SecretEngineTest
final class DeleteKeyTest extends AbstractSecretEngineTestCase
{
public function testApiCall()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Test\VaultPHP\SecretEngines\Engines\Transit;

use Test\VaultPHP\SecretEngines\SecretEngineTest;
use Test\VaultPHP\SecretEngines\AbstractSecretEngineTestCase;
use VaultPHP\SecretEngines\Engines\Transit\Request\EncryptData\EncryptData;
use VaultPHP\SecretEngines\Engines\Transit\Request\EncryptData\EncryptDataBulkRequest;
use VaultPHP\SecretEngines\Engines\Transit\Response\EncryptDataResponse;
Expand All @@ -12,7 +12,7 @@
* Class EncryptDataBulkTest
* @package Test\VaultPHP\SecretEngines\Transit
*/
final class EncryptDataBulkTest extends SecretEngineTest
final class EncryptDataBulkTest extends AbstractSecretEngineTestCase
{
public function testApiCall()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Test\VaultPHP\SecretEngines\Engines\Transit;

use Test\VaultPHP\SecretEngines\SecretEngineTest;
use Test\VaultPHP\SecretEngines\AbstractSecretEngineTestCase;
use VaultPHP\SecretEngines\Engines\Transit\EncryptionType;
use VaultPHP\SecretEngines\Engines\Transit\Request\EncryptData\EncryptDataRequest;
use VaultPHP\SecretEngines\Engines\Transit\Response\EncryptDataResponse;
Expand All @@ -12,7 +12,7 @@
* Class EncryptDataTest
* @package Test\VaultPHP\SecretEngines\Transit
*/
final class EncryptDataTest extends SecretEngineTest
final class EncryptDataTest extends AbstractSecretEngineTestCase
{
public function testApiCall()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/VaultPHP/SecretEngines/Engines/Transit/ListKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Test\VaultPHP\SecretEngines\Engines\Transit;

use Test\VaultPHP\SecretEngines\SecretEngineTest;
use Test\VaultPHP\SecretEngines\AbstractSecretEngineTestCase;
use VaultPHP\SecretEngines\Engines\Transit\Response\ListKeysResponse;
use VaultPHP\SecretEngines\Engines\Transit\Transit;

/**
* Class ListKeyTest
* @package Test\VaultPHP\SecretEngines\Transit
*/
final class ListKeyTest extends SecretEngineTest
final class ListKeyTest extends AbstractSecretEngineTestCase
{
public function testApiCall()
{
Expand Down
Loading

0 comments on commit 0d9d78b

Please sign in to comment.