Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pipeline (phpstan & phpcsfixer) #407

Merged
merged 2 commits into from
Feb 23, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ parameters:
count: 5
path: tests/Unit/CassetteTest.php

-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertCount\\(\\) with arguments 22, array\\{url\\: string, content_type\\: string\\|null, http_code\\: int, header_size\\: int, request_size\\: int, filetime\\: int, ssl_verify_result\\: int, redirect_count\\: int, \\.\\.\\.\\} and 'curl_getinfo\\(\\)…' will always evaluate to false\\.$#"
count: 1
path: tests/Unit/LibraryHooks/CurlHookTest.php

-
message: "#^Parameter \\#2 \\$requestMatchers of method VCR\\\\Request\\:\\:matches\\(\\) expects array\\<callable\\(\\)\\: mixed\\>, array\\{array\\{'some', 'method'\\}\\} given\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Configuration
*
* A value of null means all hooks are enabled.
*
* @see \VCR\LibraryHooks\LibraryHook
* @see LibraryHooks\LibraryHook
*
* @var string[]|null list of enabled LibraryHook names
*/
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/LibraryHooks/CurlHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function __callStatic($method, array $args)
/**
* @see http://www.php.net/manual/en/function.curl-init.php
*/
public static function curlInit(string $url = null): \CurlHandle|false
public static function curlInit(?string $url = null): \CurlHandle|false
{
$curlHandle = curl_init($url);
if (false !== $curlHandle) {
Expand Down
4 changes: 2 additions & 2 deletions src/VCR/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Response
* @param array<string,string> $headers
* @param array<string,mixed> $curlInfo
*/
final public function __construct($status, array $headers = [], string $body = null, array $curlInfo = [])
final public function __construct($status, array $headers = [], ?string $body = null, array $curlInfo = [])
{
$this->setStatus($status);
$this->headers = $headers;
Expand Down Expand Up @@ -110,7 +110,7 @@ public function getBody(): string
/**
* @return array<string,mixed>|mixed|null
*/
public function getCurlInfo(string $option = null): mixed
public function getCurlInfo(?string $option = null): mixed
{
if (empty($option)) {
return $this->curlInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/Storage/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Yaml extends AbstractStorage

protected Dumper $yamlDumper;

public function __construct(string $cassettePath, string $cassetteName, Parser $parser = null, Dumper $dumper = null)
public function __construct(string $cassettePath, string $cassetteName, ?Parser $parser = null, ?Dumper $dumper = null)
{
parent::__construct($cassettePath, $cassetteName, '');

Expand Down
4 changes: 2 additions & 2 deletions src/VCR/Util/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Assertion extends BaseAssertion
* @param string $message exception message to show if value is not a callable
* @param null $propertyPath
*
* @throws \VCR\VCRException if specified value is not a callable
* @throws VCRException if specified value is not a callable
*/
public static function isCallable($value, $message = null, string $propertyPath = null): bool
public static function isCallable($value, $message = null, ?string $propertyPath = null): bool
{
if (!\is_callable($value)) {
throw new VCRException($message, self::INVALID_CALLABLE, $propertyPath);
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/Util/CurlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va
* Makes sure we've properly handled the POST body, such as ensuring that
* CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set.
*/
public static function validateCurlPOSTBody(Request $request, \CurlHandle $curlHandle = null): void
public static function validateCurlPOSTBody(Request $request, ?\CurlHandle $curlHandle = null): void
{
$readFunction = $request->getCurlOption(\CURLOPT_READFUNCTION);
if (null === $readFunction) {
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/Util/StreamHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class StreamHelper
*
* @param resource $context stream context resource
*/
public static function createRequestFromStreamContext($context, string $path, Request $existing = null): Request
public static function createRequestFromStreamContext($context, string $path, ?Request $existing = null): Request
{
$http = self::getHttpOptionsFromContext($context);
$request = $existing;
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/Util/StreamProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class StreamProcessor

protected bool $isIntercepting = false;

public function __construct(Configuration $configuration = null)
public function __construct(?Configuration $configuration = null)
{
if ($configuration) {
static::$configuration = $configuration;
Expand Down
8 changes: 4 additions & 4 deletions src/VCR/VCRFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class VCRFactory

protected static ?self $instance = null;

protected function __construct(Configuration $config = null)
protected function __construct(?Configuration $config = null)
{
$this->config = $config ?: $this->getOrCreate('VCR\Configuration');
}
Expand Down Expand Up @@ -59,21 +59,21 @@ protected function createStorage(string $cassetteName): Storage

protected function createVCRLibraryHooksSoapHook(): SoapHook
{
return new LibraryHooks\SoapHook(
return new SoapHook(
$this->getOrCreate('VCR\CodeTransform\SoapCodeTransform'),
$this->getOrCreate('VCR\Util\StreamProcessor')
);
}

protected function createVCRLibraryHooksCurlHook(): CurlHook
{
return new LibraryHooks\CurlHook(
return new CurlHook(
$this->getOrCreate('VCR\CodeTransform\CurlCodeTransform'),
$this->getOrCreate('VCR\Util\StreamProcessor')
);
}

public static function getInstance(Configuration $config = null): self
public static function getInstance(?Configuration $config = null): self
{
if (!self::$instance) {
self::$instance = new self($config);
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/Videorecorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getEventDispatcher(): EventDispatcherInterface
return $this->eventDispatcher;
}

private function dispatch(Event $event, string $eventName = null): Event
private function dispatch(Event $event, ?string $eventName = null): Event
{
$res = $this->getEventDispatcher()->dispatch($event, $eventName);

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testEnableRequestMatchersFailsWithNoExistingName(): void

public function testAddRequestMatcherFailsWithNoName(): void
{
$this->expectException(\VCR\VCRException::class);
$this->expectException(VCRException::class);
$this->expectExceptionMessage("A request matchers name must be at least one character long. Found ''");
$expected = fn ($first, $second) => true;
$this->config->addRequestMatcher('', $expected);
Expand Down Expand Up @@ -123,7 +123,7 @@ public function availableStorageProvider(): array

public function testSetStorageInvalidName(): void
{
$this->expectException(\VCR\VCRException::class);
$this->expectException(VCRException::class);
$this->expectExceptionMessage("Storage 'Does not exist' not available.");
$this->config->setStorage('Does not exist');
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public function testBlacklist(): void

public function testSetModeInvalidName(): void
{
$this->expectException(\VCR\VCRException::class);
$this->expectException(VCRException::class);
$this->expectExceptionMessage("Mode 'invalid' does not exist.");
$this->config->setMode('invalid');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Util/StreamProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testFlockWithFilePutContents(): void
/**
* @dataProvider streamOpenAppendFilterProvider
*/
public function testStreamOpenShouldAppendFilters(bool $expected, int $option, bool $shouldProcess = null): void
public function testStreamOpenShouldAppendFilters(bool $expected, int $option, ?bool $shouldProcess = null): void
{
$mock = $this->getMockBuilder('VCR\Util\StreamProcessor')
->disableOriginalConstructor()
Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

require_once __DIR__.'/../vendor/autoload.php';

\VCR\VCR::turnOn();
\VCR\VCR::turnOff();
VCR\VCR::turnOn();
VCR\VCR::turnOff();