Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Cache/DataHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function hasItem($key): bool
* @return mixed|array|null Return last history item or null on failure
* @throws CacheException
*/
public function getLastItem($key, string $field = null)
public function getLastItem($key, ?string $field = null)
{
$history = $this->getAll($key);
$item = array_pop($history);
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/GraphQLException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GraphQLException extends HttpException
* @param ?string $lastQuery
* @param \Exception|null $previous
*/
public function __construct(string $message, string $uri, string $method, array $options, ResponseInterface $response, array $errorData = [], array $responseData = [], \Exception $previous = null, ?string $lastQuery = null)
public function __construct(string $message, string $uri, string $method, array $options, ResponseInterface $response, array $errorData = [], array $responseData = [], ?\Exception $previous = null, ?string $lastQuery = null)
{
if (null !== $lastQuery) {
$this->setLastQuery($lastQuery);
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class HttpException extends \Exception
* @param array $responseData
* @param \Exception|null $previous
*/
public function __construct(string $message, private string $requestUri, private string $requestMethod, private array $requestOptions, private ResponseInterface $response, private array $responseErrorData = [], private array $responseData = [], \Exception $previous = null)
public function __construct(string $message, private string $requestUri, private string $requestMethod, private array $requestOptions, private ResponseInterface $response, private array $responseErrorData = [], private array $responseData = [], ?\Exception $previous = null)
{
// Append error data if set
$message .= $this->getMessageFromErrorData($this->responseErrorData);
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ public function throwExceptionOnFailedRequest(ResponseInterface $response): void
*
* Hash generated from: URI + GET params
*
* @param $method
* @param $uri
* @param array $context
* @return string Unique identifier for this request
Expand Down Expand Up @@ -720,7 +719,7 @@ public function get(string $uri, array $queryParams = [], array $options = []):
* @throws HttpException
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
*/
public function post(string $uri, string|array $postData = null, array $options = []): CacheableResponse
public function post(string $uri, string|array|null $postData = null, array $options = []): CacheableResponse
{
if (is_array($postData)) {
if (isset($options['body']) && is_array($options['body'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/CheckPermissionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait CheckPermissionsTrait
* Set permissions for accessing the API, defaults to read-only
* @param Permissions $permissions
*/
public function setPermissions(Permissions $permissions = null)
public function setPermissions(?Permissions $permissions = null)
{
if ($permissions instanceof Permissions) {
$this->permissions = $permissions;
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/FlagsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait FlagsTrait
{
protected $flags;

public function __construct(int $options = null)
public function __construct(?int $options = null)
{
if ($options !== null) {
$this->setFlags($options);
Expand Down
5 changes: 2 additions & 3 deletions tests/Decode/DecoderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Strata\Data\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Strata\Data\Decode\DecoderFactory;
use Symfony\Component\HttpClient\MockHttpClient;
Expand All @@ -25,9 +26,7 @@ public function testFilenameFactory()
$this->assertNull(DecoderFactory::fromFilename('https://example.com/feed'));
}

/**
* @dataProvider responseDataProvider
*/
#[DataProvider('responseDataProvider')]
public function testResponseFactory($contentType, $expectedClass)
{
$mockResponse = new MockResponse('', ['response_headers' => ['Content-type' => $contentType]]);
Expand Down
9 changes: 3 additions & 6 deletions tests/Validate/Rule/EmailRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

namespace Strata\Data\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Strata\Data\Validate\Rule\EmailRule;

class EmailRuleTest extends TestCase
{
/**
* @dataProvider validDataProvider
*/
#[DataProvider('validDataProvider')]
public function testValid(string $email)
{
$validator = new EmailRule('[email]');
Expand All @@ -20,9 +19,7 @@ public function testValid(string $email)
$this->assertTrue($validator->validate($data));
}

/**
* @dataProvider invalidDataProvider
*/
#[DataProvider('invalidDataProvider')]
public function testInvalid(string $email)
{
$validator = new EmailRule('[email]');
Expand Down
9 changes: 3 additions & 6 deletions tests/Validate/Rule/NumberRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

namespace Strata\Data\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Strata\Data\Validate\Rule\NumberRule;

class NumberRuleTest extends TestCase
{
/**
* @dataProvider validDataProvider
*/
#[DataProvider('validDataProvider')]
public function testValid($number)
{
$validator = new NumberRule('[data]');
Expand All @@ -20,9 +19,7 @@ public function testValid($number)
$this->assertTrue($validator->validate($data));
}

/**
* @dataProvider invalidDataProvider
*/
#[DataProvider('invalidDataProvider')]
public function testInvalid($number)
{
$validator = new NumberRule('[data]');
Expand Down
9 changes: 3 additions & 6 deletions tests/Validate/Rule/RequiredRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

namespace Strata\Data\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Strata\Data\Validate\Rule\RequiredRule;

class RequiredRuleTest extends TestCase
{
/**
* @dataProvider validDataProvider
*/
#[DataProvider('validDataProvider')]
public function testValid(string $propertyPath)
{
$data = ['email' => 'hello@studio24.net', 'title' => '', 'number' => 0, 'things' => [], 'null' => null];
Expand All @@ -20,9 +19,7 @@ public function testValid(string $propertyPath)
$this->assertTrue($validator->validate($data));
}

/**
* @dataProvider invalidDataProvider
*/
#[DataProvider('invalidDataProvider')]
public function testInvalid(string $propertyPath)
{
$data = ['email' => 'hello@studio24.net', 'title' => '', 'number' => 0, 'things' => [], 'null' => null];
Expand Down