Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 48258fc

Browse filesBrowse files
Merge branch '3.4' into 4.2
* 3.4: minor: add some test in the ldap component [Bridge\ProxyManager] isProxyCandidate() does not take into account interfaces [Routing][AnnotationClassLoader] fix utf-8 encoding in default route name fixed a phpdoc [Debug] Wrap call to require_once in a try/catch [PropertyInfo] Add missing documentation link in Readme Use the current working dir as default first arg in 'link' binary Respect parent class contract in ContainerAwareDoctrineEventManager [Validator] Add the missing translations for the Danish ("da") locale [Serializer] Fix denormalization of object with variadic constructor typed argument Allow set 'None' on samesite cookie flag
2 parents ef7ff67 + 9e4d5ff commit 48258fc
Copy full SHA for 48258fc

File tree

17 files changed

+372
-74
lines changed
Filter options

17 files changed

+372
-74
lines changed

‎link

Copy file name to clipboardExpand all lines: link
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ use Symfony\Component\Filesystem\Filesystem;
2323
* @author Kévin Dunglas <dunglas@gmail.com>
2424
*/
2525

26-
if (2 !== $argc) {
27-
echo 'Link dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL;
28-
echo "Usage: $argv[0] /path/to/the/project".PHP_EOL;
29-
exit(1);
30-
}
26+
$pathToProject = $argv[1] ?? getcwd();
3127

32-
if (!is_dir("$argv[1]/vendor/symfony")) {
33-
echo "The directory \"$argv[1]\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL;
28+
if (!is_dir("$pathToProject/vendor/symfony")) {
29+
echo 'Link dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL;
30+
echo "Usage: $argv[0] /path/to/the/project".PHP_EOL.PHP_EOL;
31+
echo "The directory \"$pathToProject\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL;
3432
exit(1);
3533
}
3634

@@ -50,7 +48,7 @@ foreach ($directories as $dir) {
5048
}
5149
}
5250

53-
foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
51+
foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
5452
$package = 'symfony/'.basename($dir);
5553
if (is_link($dir)) {
5654
echo "\"$package\" is already a symlink, skipping.".PHP_EOL;
@@ -68,6 +66,6 @@ foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir)
6866
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
6967
}
7068

71-
foreach (glob("$argv[1]/var/cache/*") as $cacheDir) {
69+
foreach (glob("$pathToProject/var/cache/*") as $cacheDir) {
7270
$filesystem->remove($cacheDir);
7371
}

‎src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php
+46-43Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -37,72 +37,61 @@ public function __construct(ContainerInterface $container)
3737
}
3838

3939
/**
40-
* Dispatches an event to all registered listeners.
41-
*
42-
* @param string $eventName The name of the event to dispatch. The name of the event is
43-
* the name of the method that is invoked on listeners.
44-
* @param EventArgs $eventArgs The event arguments to pass to the event handlers/listeners.
45-
* If not supplied, the single empty EventArgs instance is used.
46-
*
47-
* @return bool
40+
* {@inheritdoc}
4841
*/
4942
public function dispatchEvent($eventName, EventArgs $eventArgs = null)
5043
{
51-
if (isset($this->listeners[$eventName])) {
52-
$eventArgs = null === $eventArgs ? EventArgs::getEmptyInstance() : $eventArgs;
44+
if (!isset($this->listeners[$eventName])) {
45+
return;
46+
}
5347

54-
$initialized = isset($this->initialized[$eventName]);
48+
$eventArgs = null === $eventArgs ? EventArgs::getEmptyInstance() : $eventArgs;
5549

56-
foreach ($this->listeners[$eventName] as $hash => $listener) {
57-
if (!$initialized && \is_string($listener)) {
58-
$this->listeners[$eventName][$hash] = $listener = $this->container->get($listener);
59-
}
50+
if (!isset($this->initialized[$eventName])) {
51+
$this->initializeListeners($eventName);
52+
}
6053

61-
$listener->$eventName($eventArgs);
62-
}
63-
$this->initialized[$eventName] = true;
54+
foreach ($this->listeners[$eventName] as $hash => $listener) {
55+
$listener->$eventName($eventArgs);
6456
}
6557
}
6658

6759
/**
68-
* Gets the listeners of a specific event or all listeners.
69-
*
70-
* @param string $event The name of the event
71-
*
72-
* @return array The event listeners for the specified event, or all event listeners
60+
* {@inheritdoc}
7361
*/
7462
public function getListeners($event = null)
7563
{
76-
return $event ? $this->listeners[$event] : $this->listeners;
64+
if (null !== $event) {
65+
if (!isset($this->initialized[$event])) {
66+
$this->initializeListeners($event);
67+
}
68+
69+
return $this->listeners[$event];
70+
}
71+
72+
foreach ($this->listeners as $event => $listeners) {
73+
if (!isset($this->initialized[$event])) {
74+
$this->initializeListeners($event);
75+
}
76+
}
77+
78+
return $this->listeners;
7779
}
7880

7981
/**
80-
* Checks whether an event has any registered listeners.
81-
*
82-
* @param string $event
83-
*
84-
* @return bool TRUE if the specified event has any listeners, FALSE otherwise
82+
* {@inheritdoc}
8583
*/
8684
public function hasListeners($event)
8785
{
8886
return isset($this->listeners[$event]) && $this->listeners[$event];
8987
}
9088

9189
/**
92-
* Adds an event listener that listens on the specified events.
93-
*
94-
* @param string|array $events The event(s) to listen on
95-
* @param object|string $listener The listener object
96-
*
97-
* @throws \RuntimeException
90+
* {@inheritdoc}
9891
*/
9992
public function addEventListener($events, $listener)
10093
{
10194
if (\is_string($listener)) {
102-
if ($this->initialized) {
103-
throw new \RuntimeException('Adding lazy-loading listeners after construction is not supported.');
104-
}
105-
10695
$hash = '_service_'.$listener;
10796
} else {
10897
// Picks the hash code related to that listener
@@ -113,14 +102,15 @@ public function addEventListener($events, $listener)
113102
// Overrides listener if a previous one was associated already
114103
// Prevents duplicate listeners on same event (same instance only)
115104
$this->listeners[$event][$hash] = $listener;
105+
106+
if (\is_string($listener)) {
107+
unset($this->initialized[$event]);
108+
}
116109
}
117110
}
118111

119112
/**
120-
* Removes an event listener from the specified events.
121-
*
122-
* @param string|array $events
123-
* @param object|string $listener
113+
* {@inheritdoc}
124114
*/
125115
public function removeEventListener($events, $listener)
126116
{
@@ -138,4 +128,17 @@ public function removeEventListener($events, $listener)
138128
}
139129
}
140130
}
131+
132+
/**
133+
* @param string $eventName
134+
*/
135+
private function initializeListeners($eventName)
136+
{
137+
foreach ($this->listeners[$eventName] as $hash => $listener) {
138+
if (\is_string($listener)) {
139+
$this->listeners[$eventName][$hash] = $this->container->get($listener);
140+
}
141+
}
142+
$this->initialized[$eventName] = true;
143+
}
141144
}

‎src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php
+60-10Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ protected function setUp()
2828

2929
public function testDispatchEvent()
3030
{
31-
$this->container->set('foobar', $listener1 = new MyListener());
32-
$this->evm->addEventListener('foo', 'foobar');
31+
$this->container->set('lazy', $listener1 = new MyListener());
32+
$this->evm->addEventListener('foo', 'lazy');
3333
$this->evm->addEventListener('foo', $listener2 = new MyListener());
3434

3535
$this->evm->dispatchEvent('foo');
@@ -38,19 +38,69 @@ public function testDispatchEvent()
3838
$this->assertTrue($listener2->called);
3939
}
4040

41+
public function testAddEventListenerAfterDispatchEvent()
42+
{
43+
$this->container->set('lazy1', $listener1 = new MyListener());
44+
$this->evm->addEventListener('foo', 'lazy1');
45+
$this->evm->addEventListener('foo', $listener2 = new MyListener());
46+
47+
$this->evm->dispatchEvent('foo');
48+
49+
$this->container->set('lazy2', $listener3 = new MyListener());
50+
$this->evm->addEventListener('foo', 'lazy2');
51+
$this->evm->addEventListener('foo', $listener4 = new MyListener());
52+
53+
$this->evm->dispatchEvent('foo');
54+
55+
$this->assertTrue($listener1->called);
56+
$this->assertTrue($listener2->called);
57+
$this->assertTrue($listener3->called);
58+
$this->assertTrue($listener4->called);
59+
}
60+
61+
public function testGetListenersForEvent()
62+
{
63+
$this->container->set('lazy', $listener1 = new MyListener());
64+
$this->evm->addEventListener('foo', 'lazy');
65+
$this->evm->addEventListener('foo', $listener2 = new MyListener());
66+
67+
$this->assertSame([$listener1, $listener2], array_values($this->evm->getListeners('foo')));
68+
}
69+
70+
public function testGetListeners()
71+
{
72+
$this->container->set('lazy', $listener1 = new MyListener());
73+
$this->evm->addEventListener('foo', 'lazy');
74+
$this->evm->addEventListener('foo', $listener2 = new MyListener());
75+
76+
$this->assertSame([$listener1, $listener2], array_values($this->evm->getListeners()['foo']));
77+
}
78+
4179
public function testRemoveEventListener()
4280
{
43-
$this->evm->addEventListener('foo', 'bar');
44-
$this->evm->addEventListener('foo', $listener = new MyListener());
81+
$this->container->set('lazy', $listener1 = new MyListener());
82+
$this->evm->addEventListener('foo', 'lazy');
83+
$this->evm->addEventListener('foo', $listener2 = new MyListener());
84+
85+
$this->evm->removeEventListener('foo', $listener2);
86+
$this->assertSame([$listener1], array_values($this->evm->getListeners('foo')));
4587

46-
$listeners = ['foo' => ['_service_bar' => 'bar', spl_object_hash($listener) => $listener]];
47-
$this->assertSame($listeners, $this->evm->getListeners());
48-
$this->assertSame($listeners['foo'], $this->evm->getListeners('foo'));
88+
$this->evm->removeEventListener('foo', 'lazy');
89+
$this->assertSame([], $this->evm->getListeners('foo'));
90+
}
91+
92+
public function testRemoveEventListenerAfterDispatchEvent()
93+
{
94+
$this->container->set('lazy', $listener1 = new MyListener());
95+
$this->evm->addEventListener('foo', 'lazy');
96+
$this->evm->addEventListener('foo', $listener2 = new MyListener());
97+
98+
$this->evm->dispatchEvent('foo');
4999

50-
$this->evm->removeEventListener('foo', $listener);
51-
$this->assertSame(['_service_bar' => 'bar'], $this->evm->getListeners('foo'));
100+
$this->evm->removeEventListener('foo', $listener2);
101+
$this->assertSame([$listener1], array_values($this->evm->getListeners('foo')));
52102

53-
$this->evm->removeEventListener('foo', 'bar');
103+
$this->evm->removeEventListener('foo', 'lazy');
54104
$this->assertSame([], $this->evm->getListeners('foo'));
55105
}
56106
}

‎src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
1616
use Symfony\Component\DependencyInjection\Definition;
17+
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
1718

1819
/**
1920
* Tests for {@see \Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper}.
@@ -182,6 +183,7 @@ public function getProxyCandidates()
182183
$definitions = [
183184
[new Definition(__CLASS__), true],
184185
[new Definition('stdClass'), true],
186+
[new Definition(DumperInterface::class), true],
185187
[new Definition(uniqid('foo', true)), false],
186188
[new Definition(), false],
187189
];

‎src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ private function convertFileToClass(string $path, string $file, string $prefix):
171171
}
172172
}
173173

174-
require_once $file;
174+
try {
175+
require_once $file;
176+
} catch (\Throwable $e) {
177+
return null;
178+
}
175179

176180
foreach ($candidates as $candidate) {
177181
if ($this->classExists($candidate)) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.