Skip to content

Commit

Permalink
Use null type instead of ?
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse committed Mar 7, 2024
1 parent 466bc11 commit 24bae2c
Show file tree
Hide file tree
Showing 51 changed files with 178 additions and 177 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'return_assignment' => true,
'fopen_flags' => false,
'strict_param' => true,
'phpdoc_separation' => ['groups' => [['ORM\\*'], ['Assert\\*']]],
'phpdoc_separation' => ['groups' => [['ORM\\*'], ['Assert\\*', 'Assert'], ['SymfonySerializer\\*']]],
'nullable_type_declaration' => ['syntax' => 'union'],
'header_comment' => ['header' => $header],
))
;
4 changes: 2 additions & 2 deletions Player/Adapter/BlackfireSdkAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function createRequest(string|Configuration|null $config = null): Request
}
}

public function updateProfile(string $uuid, string $title, ?array $metadata = null): bool
public function updateProfile(string $uuid, string $title, array|null $metadata = null): bool
{
try {
return $this->blackfireClient->updateProfile($uuid, $title, $metadata);
Expand All @@ -63,7 +63,7 @@ public function getProfile(string $uuid): Profile
}
}

public function startBuild(?string $env = null, array $options = []): Build
public function startBuild(string|null $env = null, array $options = []): Build
{
try {
$sdkBuild = $this->blackfireClient->startBuild($env, $options);
Expand Down
4 changes: 2 additions & 2 deletions Player/Adapter/BlackfireSdkAdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public function getConfiguration(): ClientConfiguration;

public function createRequest(string|Configuration|null $config = null): Request;

public function updateProfile(string $uuid, string $title, ?array $metadata = null): bool;
public function updateProfile(string $uuid, string $title, array|null $metadata = null): bool;

public function getProfile(string $uuid): Profile;

public function startBuild(?string $env = null, array $options = []): Build;
public function startBuild(string|null $env = null, array $options = []): Build;
}
2 changes: 1 addition & 1 deletion Player/Build/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
public function __construct(
public string $uuid,
public ?string $url = null,
public string|null $url = null,
) {
}
}
2 changes: 1 addition & 1 deletion Player/BuildApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getOrCreate(string $env, ScenarioSet $scenarioSet): Build
return $build;
}

public function createBuild(?string $buildName, string $env): Build
public function createBuild(string|null $buildName, string $env): Build
{
$options = [
'trigger_name' => 'Blackfire Player',
Expand Down
2 changes: 1 addition & 1 deletion Player/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
final class Application extends BaseApplication
{
public function __construct(?BlackfireSdkAdapterInterface $blackfireSdk, ?HttpClientInterface $blackfireHttpClient, string $transactionId)
public function __construct(BlackfireSdkAdapterInterface|null $blackfireSdk, HttpClientInterface|null $blackfireHttpClient, string $transactionId)
{
parent::__construct('Blackfire Player', Player::version());

Expand Down
8 changes: 4 additions & 4 deletions Player/Console/PlayerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ final class PlayerCommand extends Command
public const EXIT_CODE_SCENARIO_ERROR_NON_FATAL = 66;
public const EXIT_CODE_BLACKFIRE_NETWORK_ERROR = 67;

private ?HttpClientInterface $blackfireHttpClient;
private ?BlackfireSdkAdapterInterface $blackfireSdkAdapter;
private HttpClientInterface|null $blackfireHttpClient;
private BlackfireSdkAdapterInterface|null $blackfireSdkAdapter;
private string $transactionId;

public function __construct(
?HttpClientInterface $blackfireHttpClient, ?BlackfireSdkAdapterInterface $blackfireSdkAdapter, string $transactionId)
HttpClientInterface|null $blackfireHttpClient, BlackfireSdkAdapterInterface|null $blackfireSdkAdapter, string $transactionId)
{
$this->blackfireHttpClient = $blackfireHttpClient;
$this->blackfireSdkAdapter = $blackfireSdkAdapter;
Expand Down Expand Up @@ -347,7 +347,7 @@ private function createReport(ScenarioSetResult $results): array
return $report;
}

private function getEnvOrDefault(string $envVar, ?string $default = null): ?string
private function getEnvOrDefault(string $envVar, string|null $default = null): string|null
{
$env = getenv($envVar);
if (!$env) {
Expand Down
2 changes: 1 addition & 1 deletion Player/Exception/ExpectationFailureException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ExpectationFailureException extends LogicException
{
private array $results;

public function __construct(?string $message = null, array $results = [], int $code = 0, ?\Exception $previous = null)
public function __construct(string|null $message = null, array $results = [], int $code = 0, \Exception|null $previous = null)
{
parent::__construct($message, $code, $previous);

Expand Down
6 changes: 3 additions & 3 deletions Player/ExpressionLanguage/ExpressionLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/
class ExpressionLanguage extends SymfonyExpressionLanguage
{
private ?ExtractResultsVisitor $resultsVisitor = null;
private ?ValidatorParser $parser = null;
private ?Lexer $lexer = null;
private ExtractResultsVisitor|null $resultsVisitor = null;
private ValidatorParser|null $parser = null;
private Lexer|null $lexer = null;

public function extractResults(ParsedExpression $expression, array $variables): array
{
Expand Down
2 changes: 1 addition & 1 deletion Player/ExpressionLanguage/ExtractResultsVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function extractResults(ParsedExpression $expression, array $variables):
return array_unique($results, \SORT_REGULAR);
}

private function visit(Node\Node $node, array $variables, ?Node\Node $parentNode = null): array
private function visit(Node\Node $node, array $variables, Node\Node|null $parentNode = null): array
{
$subExpressions = [];

Expand Down
8 changes: 4 additions & 4 deletions Player/ExpressionLanguage/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Provider implements ExpressionFunctionProviderInterface
private readonly FakerGenerator $faker;

public function __construct(
?FakerGenerator $faker = null,
FakerGenerator|null $faker = null,
private readonly bool $sandbox = false,
) {
$this->faker = null !== $faker ? $faker : FakerFactory::create();
Expand Down Expand Up @@ -69,7 +69,7 @@ public function getFunctions(): array
return $arguments['_crawler']->selectButton($selector);
}),

new ExpressionFunction('file', $compiler, function (array $arguments, string $filename, ?string $name = null) {
new ExpressionFunction('file', $compiler, function (array $arguments, string $filename, string|null $name = null) {
if ($this->sandbox) {
if (UploadFile::isAbsolutePath($filename)) {
$extra = $arguments['_extra'];
Expand Down Expand Up @@ -186,7 +186,7 @@ public function getFunctions(): array
return array_merge($arr1, $arr2);
}),

new ExpressionFunction('fake', $compiler, function (array $arguments, ?string $provider = null/* , $othersArgs ... */) {
new ExpressionFunction('fake', $compiler, function (array $arguments, string|null $provider = null/* , $othersArgs ... */) {
$arguments = \func_get_args();

if (!$provider) {
Expand Down Expand Up @@ -222,7 +222,7 @@ public function getFunctions(): array
return $ret;
}),

new ExpressionFunction('regex', $compiler, function (array $arguments, string $regex, ?string $str = null) {
new ExpressionFunction('regex', $compiler, function (array $arguments, string $regex, string|null $str = null) {
if (null === $str) {
if ($arguments['_response'] instanceof Response) {
$str = $arguments['_response']->body;
Expand Down
4 changes: 2 additions & 2 deletions Player/ExpressionLanguage/ValidatorParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/
class ValidatorParser extends SymfonyParser
{
private ?TokenStream $stream = null;
private ?array $names = null;
private TokenStream|null $stream = null;
private array|null $names = null;
private array $missingNames = [];

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion Player/Extension/BlackfireEnvResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
private const DEPRECATION_ENV_RESOLVING = 'Resolving an environment at the scenario level using the "blackfire" property is deprecated. Please use `--blackfire-env` instead.';

public function __construct(
private ?string $defaultEnv,
private string|null $defaultEnv,
private ExpressionLanguage $language,
) {
}
Expand Down
2 changes: 1 addition & 1 deletion Player/Extension/BlackfireExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public function afterScenarioSet(ScenarioSet $scenarios, int $concurrency, Scena
}
}

private function findEnvBuildFromExtraBag(string $env, ScenarioSet $scenarios): ?Build
private function findEnvBuildFromExtraBag(string $env, ScenarioSet $scenarios): Build|null
{
$bag = $scenarios->getExtraBag();

Expand Down
6 changes: 3 additions & 3 deletions Player/Http/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class Cookie
private function __construct(
private readonly string $name,
private readonly string $value,
private readonly ?string $expires,
private readonly string|null $expires,
private readonly string $path,
private readonly string $domain,
private readonly bool $secure,
Expand Down Expand Up @@ -74,7 +74,7 @@ public function __toString(): string
*
* @throws \InvalidArgumentException
*/
public static function fromString(string $cookie, ?string $url = null): static
public static function fromString(string $cookie, string|null $url = null): static
{
$parts = explode(';', $cookie);

Expand Down Expand Up @@ -135,7 +135,7 @@ public static function fromString(string $cookie, ?string $url = null): static
);
}

private static function parseDate(string $dateValue): ?string
private static function parseDate(string $dateValue): string|null
{
// trim single quotes around date if present
if (($length = \strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) {
Expand Down
4 changes: 2 additions & 2 deletions Player/Http/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function clear(): void
$this->cookieJar = [];
}

public function updateFromSetCookie(array $setCookies, ?string $uri = null): void
public function updateFromSetCookie(array $setCookies, string|null $uri = null): void
{
$cookies = [];

Expand All @@ -56,7 +56,7 @@ public function updateFromSetCookie(array $setCookies, ?string $uri = null): voi
}
}

public function updateFromResponse(ResponseInterface $response, ?string $uri = null): void
public function updateFromResponse(ResponseInterface $response, string|null $uri = null): void
{
$headers = $response->getHeaders(false);
$this->updateFromSetCookie($headers['set-cookie'] ?? [], $uri);
Expand Down
2 changes: 1 addition & 1 deletion Player/Http/CrawlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class CrawlerFactory
{
public static function create(Response $response, ?string $uri): ?Crawler
public static function create(Response $response, string|null $uri): Crawler|null
{
$contentType = $response->headers['content-type'][0] ?? null;
if (!$contentType) {
Expand Down
4 changes: 2 additions & 2 deletions Player/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Input

public function __construct(
string $input,
private readonly ?string $file = null,
private readonly string|null $file = null,
) {
$this->lines = $this->splitInput($input);

Expand Down Expand Up @@ -70,7 +70,7 @@ public function getIndent(): int
return $this->computeIndent($this->lineno);
}

public function getFile(): ?string
public function getFile(): string|null
{
return $this->file;
}
Expand Down
4 changes: 2 additions & 2 deletions Player/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Parser
/** @var string[] */
private array $missingVariables = [];
private array $groups;
private ?string $name = null;
private string|null $name = null;

public function __construct(
private readonly ExpressionLanguage $expressionLanguage,
Expand Down Expand Up @@ -106,7 +106,7 @@ protected function doLoad(mixed $file): ScenarioSet
return $this->parse($input, $file);
}

public function parse(string $input, ?string $file = null): ScenarioSet
public function parse(string $input, string|null $file = null): ScenarioSet
{
$input = new Input($input, $file);

Expand Down
4 changes: 2 additions & 2 deletions Player/PlayerNext.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class PlayerNext
{
/** @var (StepExtensionInterface|ScenarioExtensionInterface|ScenarioSetExtensionInterface|NextStepExtensionInterface|ExceptionExtensionInterface)[][] */
private array $extensions = [];
private ?array $extensionsSorted = null;
private ?AbstractStep $currentStep = null;
private array|null $extensionsSorted = null;
private AbstractStep|null $currentStep = null;

public function __construct(
private readonly StepContextFactory $stepContextFactory,
Expand Down
6 changes: 3 additions & 3 deletions Player/Scenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
class Scenario extends GroupStep
{
#[Ignore]
protected ?string $blackfireBuildUuid = null;
protected string|null $blackfireBuildUuid = null;

public function getType(): ?string
public function getType(): string|null
{
return null;
}

public function getBlackfireBuildUuid(): ?string
public function getBlackfireBuildUuid(): string|null
{
return $this->blackfireBuildUuid;
}
Expand Down
12 changes: 6 additions & 6 deletions Player/ScenarioContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
*/
class ScenarioContext
{
private ?Response $lastResponse = null;
private ?Crawler $crawler = null;
private Response|null $lastResponse = null;
private Crawler|null $crawler = null;
private ValueBag $valueBag;
private ValueBag $extraBag;

public function __construct(
private readonly ?string $name,
private ?ScenarioSet $scenarioSet,
private readonly string|null $name,
private ScenarioSet|null $scenarioSet,
) {
$this->valueBag = new ValueBag();
$this->extraBag = new ValueBag();
Expand Down Expand Up @@ -97,12 +97,12 @@ public function removeExtraValue(string $name): void
$this->extraBag->remove($name);
}

public function getName(): ?string
public function getName(): string|null
{
return $this->name;
}

public function getScenarioSet(): ?ScenarioSet
public function getScenarioSet(): ScenarioSet|null
{
return $this->scenarioSet;
}
Expand Down
6 changes: 3 additions & 3 deletions Player/ScenarioResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ScenarioResult
{
public function __construct(
private readonly ScenarioContext $scenarioContext,
private ?\Throwable $error,
private \Throwable|null $error,
) {
}

Expand All @@ -48,12 +48,12 @@ public function isErrored(): bool
return null !== $this->error;
}

public function getError(): ?\Throwable
public function getError(): \Throwable|null
{
return $this->error;
}

public function getScenarioName(): ?string
public function getScenarioName(): string|null
{
return $this->scenarioContext->getName();
}
Expand Down
Loading

0 comments on commit 24bae2c

Please sign in to comment.