8000 Add parameter type declarations to contracts. · symfony/symfony@f0e7df8 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0e7df8

Browse files
committed
Add parameter type declarations to contracts.
1 parent bfdf79e commit f0e7df8

27 files changed

+85
-146
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"twig/twig": "^2.10|^3",
2424
"psr/cache": "~1.0",
2525
"psr/container": "^1.0",
26+
"psr/event-dispatcher": "^1.0",
2627
"psr/link": "^1.0",
2728
"psr/log": "~1.0",
2829
"symfony/contracts": "^1.1.3",

src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class StubTranslator implements TranslatorInterface
1717
{
18-
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
18+
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
1919
{
2020
return '[trans]'.strtr($id, $parameters).'[/trans]';
2121
}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^7.2.9",
20-
"symfony/translation-contracts": "^1.1",
20+
"symfony/translation-contracts": "^1.2",
2121
"twig/twig": "^2.10|^3"
2222
},
2323
"require-dev": {

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames()
108108

109109
class TranslatorWithTranslatorBag implements TranslatorInterface
110110
{
111-
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
111+
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
112112
{
113113
}
114114
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"symfony/serializer": "^4.4|^5.0",
5252
"symfony/stopwatch": "^4.4|^5.0",
5353
"symfony/translation": "^5.0",
54+
"symfony/translation-contracts": "^1.2",
5455
"symfony/twig-bundle": "^4.4|^5.0",
5556
"symfony/validator": "^4.4|^5.0",
5657
"symfony/var-dumper": "^4.4|^5.0",

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function hasListeners(string $eventName = null)
129129
/**
130130
* {@inheritdoc}
131131
*/
132-
public function dispatch($event, string $eventName = null): object
132+
public function dispatch(object $event, string $eventName = null): object
133133
{
134134
if (!\is_object($event)) {
135135
throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an object, %s given.', EventDispatcherInterface::class, \gettype($event)));
@@ -143,7 +143,7 @@ public function dispatch($event, string $eventName = null): object
143143

144144
$currentRequestHash = $this->currentRequestHash = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_hash($request) : '';
145145

146-
if (null !== $this->logger && ($event instanceof Event || $event instanceof StoppableEventInterface) && $event->isPropagationStopped()) {
146+
if (null !== $this->logger && $event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
147147
$this->logger->debug(sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName));
148148
}
149149

src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function __invoke(object $event, string $eventName, EventDispatcherInterf
121121
$e->stop();
122122
}
123123

124-
if (($event instanceof Event || $event instanceof StoppableEventInterface) && $event->isPropagationStopped()) {
124+
if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
125125
$this->stoppedPropagation = true;
126126
}
127127
}

src/Symfony/Component/EventDispatcher/EventDispatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct()
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function dispatch($event, string $eventName = null): object
49+
public function dispatch(object $event, string $eventName = null): object
5050
{
5151
if (!\is_object($event)) {
5252
throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an object, %s given.', EventDispatcherInterface::class, \gettype($event)));
@@ -222,7 +222,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber)
222222
*/
223223
protected function callListeners(iterable $listeners, string $eventName, object $event)
224224
{
225-
$stoppable = $event instanceof Event || $event instanceof StoppableEventInterface;
225+
$stoppable = $event instanceof StoppableEventInterface;
226226

227227
foreach ($listeners as $listener) {
228228
if ($stoppable && $event->isPropagationStopped()) {

src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface EventDispatcherInterface extends ContractsEventDispatcherInterface
2525
/**
2626
* {@inheritdoc}
2727
*/
28-
public function dispatch($event, string $eventName = null): object;
28+
public function dispatch(object $event, string $eventName = null): object;
2929

3030
/**
3131
* Adds an event listener that listens on the specified events.

src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(EventDispatcherInterface $dispatcher)
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
public function dispatch($event, string $eventName = null): object
31+
public function dispatch(object $event, string $eventName = null): object
3232
{
3333
return $this->dispatcher->dispatch($event, $eventName);
3434
}

0 commit comments

Comments
 (0)
0