Skip to content

Commit d896411

Browse files
committed
[CS] Fix more nullable types
Follows #19786
1 parent d6d2363 commit d896411

18 files changed

+29
-29
lines changed

components/expression_language.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ or by using the second argument of the constructor::
359359

360360
class ExpressionLanguage extends BaseExpressionLanguage
361361
{
362-
public function __construct(CacheItemPoolInterface $cache = null, array $providers = [])
362+
public function __construct(?CacheItemPoolInterface $cache = null, array $providers = [])
363363
{
364364
// prepends the default provider to let users override it
365365
array_unshift($providers, new StringExpressionLanguageProvider());

components/serializer.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ exists in your project::
118118
$this->sportsperson = $sportsperson;
119119
}
120120

121-
public function setCreatedAt(\DateTime $createdAt = null): void
121+
public function setCreatedAt(?\DateTime $createdAt = null): void
122122
{
123123
$this->createdAt = $createdAt;
124124
}
@@ -798,7 +798,7 @@ When serializing, you can set a callback to format a specific object property::
798798
$encoder = new JsonEncoder();
799799

800800
// all callback parameters are optional (you can omit the ones you don't use)
801-
$dateCallback = function ($innerObject, $outerObject, string $attributeName, string $format = null, array $context = []) {
801+
$dateCallback = function ($innerObject, $outerObject, string $attributeName, ?string $format = null, array $context = []) {
802802
return $innerObject instanceof \DateTime ? $innerObject->format(\DateTime::ISO8601) : '';
803803
};
804804

@@ -1605,7 +1605,7 @@ having unique identifiers::
16051605
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
16061606

16071607
// all callback parameters are optional (you can omit the ones you don't use)
1608-
$maxDepthHandler = function ($innerObject, $outerObject, string $attributeName, string $format = null, array $context = []) {
1608+
$maxDepthHandler = function ($innerObject, $outerObject, string $attributeName, ?string $format = null, array $context = []) {
16091609
return '/foos/'.$innerObject->id;
16101610
};
16111611

controller/error_pages.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ contents, create a new Normalizer that supports the ``FlattenException`` input::
216216

217217
class MyCustomProblemNormalizer implements NormalizerInterface
218218
{
219-
public function normalize($exception, string $format = null, array $context = [])
219+
public function normalize($exception, ?string $format = null, array $context = [])
220220
{
221221
return [
222222
'content' => 'This is my custom problem normalizer.',
@@ -227,7 +227,7 @@ contents, create a new Normalizer that supports the ``FlattenException`` input::
227227
];
228228
}
229229

230-
public function supportsNormalization($data, string $format = null)
230+
public function supportsNormalization($data, ?string $format = null)
231231
{
232232
return $data instanceof FlattenException;
233233
}

form/dynamic_form_modification.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ The type would now look like::
459459
])
460460
;
461461

462-
$formModifier = function (FormInterface $form, Sport $sport = null) {
462+
$formModifier = function (FormInterface $form, ?Sport $sport = null) {
463463
$positions = null === $sport ? [] : $sport->getAvailablePositions();
464464

465465
$form->add('position', EntityType::class, [

frontend/custom_version_strategy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ version string::
6868
* @param string $manifestPath
6969
* @param string|null $format
7070
*/
71-
public function __construct(string $manifestPath, string $format = null)
71+
public function __construct(string $manifestPath, ?string $format = null)
7272
{
7373
$this->manifestPath = $manifestPath;
7474
$this->format = $format ?: '%s?%s';

http_client.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ If you want to extend the behavior of a base HTTP client, you can use
16511651
{
16521652
private $decoratedClient;
16531653

1654-
public function __construct(HttpClientInterface $decoratedClient = null)
1654+
public function __construct(?HttpClientInterface $decoratedClient = null)
16551655
{
16561656
$this->decoratedClient = $decoratedClient ?? HttpClient::create();
16571657
}
@@ -1667,7 +1667,7 @@ If you want to extend the behavior of a base HTTP client, you can use
16671667
return $response;
16681668
}
16691669

1670-
public function stream($responses, float $timeout = null): ResponseStreamInterface
1670+
public function stream($responses, ?float $timeout = null): ResponseStreamInterface
16711671
{
16721672
return $this->decoratedClient->stream($responses, $timeout);
16731673
}

messenger.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2220,7 +2220,7 @@ provided in order to ease the declaration of these special handlers::
22202220
{
22212221
use BatchHandlerTrait;
22222222

2223-
public function __invoke(MyMessage $message, Acknowledger $ack = null)
2223+
public function __invoke(MyMessage $message, ?Acknowledger $ack = null)
22242224
{
22252225
return $this->handle($message, $ack);
22262226
}

messenger/custom-transport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Here is a simplified example of a database transport::
5050
/**
5151
* @param FakeDatabase $db is used for demo purposes. It is not a real class.
5252
*/
53-
public function __construct(FakeDatabase $db, SerializerInterface $serializer = null)
53+
public function __construct(FakeDatabase $db, ?SerializerInterface $serializer = null)
5454
{
5555
$this->db = $db;
5656
$this->serializer = $serializer ?? new PhpSerializer();

notifier.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ and its ``asChatMessage()`` method::
778778
$this->price = $price;
779779
}
780780

781-
public function asChatMessage(RecipientInterface $recipient, string $transport = null): ?ChatMessage
781+
public function asChatMessage(RecipientInterface $recipient, ?string $transport = null): ?ChatMessage
782782
{
783783
// Add a custom subject and emoji if the message is sent to Slack
784784
if ('slack' === $transport) {

profiler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ request::
255255

256256
class RequestCollector extends AbstractDataCollector
257257
{
258-
public function collect(Request $request, Response $response, \Throwable $exception = null)
258+
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
259259
{
260260
$this->data = [
261261
'method' => $request->getMethod(),

0 commit comments

Comments
 (0)