8000 Merge branch '3.2' · Deamon/symfony@e58be70 · GitHub
[go: up one dir, main page]

Skip to content

Commit e58be70

Browse files
committed
Merge branch '3.2'
* 3.2: Revamped the README file Fix missing namespace in AddConstraintValidatorPassTest [SecurityBundle] simplified code [ExpressionLanguage] Registering functions after calling evaluate(), compile() or parse() is not supported
2 parents 518d02d + 346eacd commit e58be70

File tree

6 files changed

+147
-64
lines changed

6 files changed

+147
-64
lines changed

README.md

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,74 @@
1-
README
2-
======
1+
<p align="center"><a href="https://symfony.com" target="_blank">
2+
<img src="https://symfony.com/logos/symfony_black_02.svg">
3+
</a></p>
34

4-
What is Symfony?
5-
-----------------
6-
7-
Symfony is a PHP full-stack web framework. It is written with speed and
8-
flexibility in mind. It allows developers to build better and easy to maintain
9-
websites with PHP.
10-
11-
Symfony can be used to develop all kind of websites, from your personal blog
12-
to high traffic ones like Dailymotion or Yahoo! Answers.
5+
[Symfony][1] is a **PHP framework** for web applications and a set of reusable
6+
**PHP components**. Symfony is used by thousands of web applications (including
7+
BlaBlaCar.com and Spotify.com) and most of the [popular PHP projects][2] (including
8+
Drupal and Magento).
139

1410
Installation
1511
------------
1612

17-
The best way to install Symfony is to use the [official Symfony Installer][7].
18-
It allows you to start a new project based on the version you want.
13+
* [Install Symfony][4] with Composer or with our own installer (see
14+
[requirements details][3]).
15+
* Symfony follows the [semantic versioning][5] strictly, publishes "Long Term
16+
Support" (LTS) versions and has a [release process][6] that is predictable and
17+
business-friendly.
1918

2019
Documentation
2120
-------------
2221

23-
The "[Quick Tour][1]" tutorial gives you a first feeling of the framework. If,
24-
like us, you think that Symfony can help speed up your development and take
25-
the quality of your work to the next level, read the official
26-
[Symfony documentation][2].
22+
* Read the [Getting Started guide][7] if you are new to Symfony.
23+
* Try the [Symfony Demo application][23] to learn Symfony in practice.
24+
* Master Symfony with the [Guides and Tutorials][8], the [Components docs][9]
25+
and the [Best Practices][10] reference.
26+
27+
Community
28+
---------
29+
30+
* [Join the Symfony Community][11] and meet other members at the [Symfony events][12].
31+
* [Get Symfony support][13] on StackOverflow, Slack, IRC, etc.
32+
* Follow us on [GitHub][14], [Twitter][15] and [Facebook][16].
2733

2834
Contributing
2935
------------
3036

31-
Symfony is an open source, community-driven project. If you'd like to contribute,
32-
please read the [Contributing Code][3] part of the documentation. If you're submitting
33-
a pull request, please follow the guidelines in the [Submitting a Patch][4] section
34-
and use [Pull Request Template][5].
35-
36-
Community Reviews
37-
-----------------
38-
39-
If you don't feel ready to contribute code or patches, reviewing issues and pull
40-
requests can be a great start to get involved and give back. In fact, people who
41-
"triage" issues are the backbone to Symfony's success!
42-
More information can be found in the [Community Reviews][8] guide.
43-
44-
Running Symfony Tests
45-
----------------------
46-
47-
Information on how to run the Symfony test suite can be found in the
48-
[Running Symfony Tests][6] section.
49-
50-
[1]: https://symfony.com/doc/current/quick_tour/index.html
51-
[2]: https://symfony.com/doc/current/
52-
[3]: https://symfony.com/doc/current/contributing/code/index.html
53-
[4]: https://symfony.com/doc/current/contributing/code/patches.html#check-list
54-
[5]: https://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request
55-
[6]: https://symfony.com/doc/master/contributing/code/tests.html
56-
[7]: https://symfony.com/doc/current/book/installation.html#installing-the-symfony-installer
57-
[8]: https://symfony.com/doc/current/contributing/community/reviews.html
37+
Symfony is an Open Source, community-driven project with thousands of
38+
[contributors][19]. Join them [contributing code][17] or [contributing documentation][18].
39+
40+
Security Issues
41+
---------------
42+
43+
If you discover a security vulnerability within Symfony, please follow our
44+
[disclosure procedure][20].
45+
46+
About Us
47+
--------
48+
49+
Symfony development is sponsored by [SensioLabs][21], lead by the
50+
[Symfony Core Team][22] and supported by [Symfony contributors][19].
51+
52+
[1]: https://symfony.com
53+
[2]: https://symfony.com/projects
54+
[3]: https://symfony.com/doc/current/reference/requirements.html
55+
[4]: https://symfony.com/doc/current/setup.html
56+
[5]: http://semver.org
57+
[6]: https://symfony.com/doc/current/contributing/community/releases.html
58+
[7]: https://symfony.com/doc/current/page_creation.html
59+
[8]: https://symfony.com/doc/current/index.html
60+
[9]: https://symfony.com/doc/current/components/index.html
61+
[10]: https://symfony.com/doc/current/best_practices/index.html
62+
[11]: https://symfony.com/community
63+
[12]: https://symfony.com/events/
64+
[13]: https://symfony.com/support
65+
[14]: https://github.com/symfony
66+
[15]: https://twitter.com/symfony
67+
[16]: https://www.facebook.com/SymfonyFramework/
68+
[17]: https://symfony.com/doc/current/contributing/code/index.html
69+
[18]: https://symfony.com/doc/current/contributing/documentation/index.html
70+
[19]: https://symfony.com/contributors
71+
[20]: https://symfony.com/security
72+
[21]: https://sensiolabs.com
73+
[22]: https://symfony.com/doc/current/contributing/code/core_team.html
74+
[23]: https://github.com/symfony/symfony-demo

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
13+
1214
use PHPUnit\Framework\TestCase;
1315
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass;
1416

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSecurityVotersPass.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\DependencyInjection\Reference;
1514
use Symfony\Component\DependencyInjection\ContainerBuilder;
1615
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
1717
use Symfony\Component\DependencyInjection\Exception\LogicException;
1818

1919
/**
@@ -23,6 +23,8 @@
2323
*/
2424
class AddSecurityVotersPass implements CompilerPassInterface
2525
{
26+
use PriorityTaggedServiceTrait;
27+
2628
/**
2729
* {@inheritdoc}
2830
*/
@@ -32,15 +34,7 @@ public function process(ContainerBuilder $container)
3234
return;
3335
}
3436

35-
$voters = array();
36-
foreach ($container->findTaggedServiceIds('security.voter') as $id => $attributes) {
37-
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
38-
$voters[$priority][] = new Reference($id);
39-
}
40-
41-
krsort($voters);
42-
$voters = call_user_func_array('array_merge', $voters);
43-
37+
$voters = $this->findAndSortTaggedServices('security.voter', $container);
4438
if (!$voters) {
4539
throw new LogicException('No security voters found. You need to tag at least one with "security.voter"');
4640
}

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818

1919
class AddSecurityVotersPassTest extends TestCase
2020
{
21+
/**
22+
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
23+
*/
24+
public function testNoVoters()
25+
{
26+
$container = new ContainerBuilder();
27+
$container
28+
->register('security.access.decision_manager', 'Symfony\Component\Security\Core\Authorization\AccessDecisionManager')
29+
->addArgument(array())
30+
;
31+
32+
$compilerPass = new AddSecurityVotersPass();
33+
$compilerPass->process($container);
34+
}
35+
2136
public function testThatSecurityVotersAreProcessedInPriorityOrder()
2237
{
2338
$container = new ContainerBuilder();
@@ -45,15 +60,9 @@ public function testThatSecurityVotersAreProcessedInPriorityOrder()
4560
$compilerPass->process($container);
4661

4762
$calls = $container->getDefinition('security.access.decision_manager')->getMethodCalls();
48-
49-
$this->assertEquals(
50-
array(
51-
new Reference('highest_prio_service'),
52-
new Reference('lowest_prio_service'),
53-
new Reference('no_prio_service'),
54-
new Reference('zero_prio_service'),
55-
),
56-
$calls[0][1][0]
57-
);
63+
$refs = $calls[0][1][0];
64+
$this->assertEquals(new Reference('highest_prio_service'), $refs[0]);
65+
$this->assertEquals(new Reference('lowest_prio_service'), $refs[1]);
66+
$this->assertCount(4, $refs);
5867
}
5968
}

src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,16 @@ public function parse($expression, $names)
122122
* @param callable $compiler A callable able to compile the function
123123
* @param callable $evaluator A callable able to evaluate the function
124124
*
125+
* @throws \LogicException when registering a function after calling evaluate(), compile() or parse()
126+
*
125127
* @see ExpressionFunction
126128
*/
127129
public function register($name, callable $compiler, callable $evaluator)
128130
{
131+
if (null !== $this->parser) {
132+
throw new \LogicException('Registering functions after calling evaluate(), compile() or parse() is not supported.');
133+
}
134+
129135
$this->functions[$name] = array('compiler' => $compiler, 'evaluator' => $evaluator);
130136
}
131137

src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\ExpressionLanguage\Tests;
1313

14+
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1617
use Symfony\Component\ExpressionLanguage\ParsedExpression;
@@ -218,4 +219,58 @@ public function testCachingWithDifferentNamesOrder()
218219
$expressionLanguage->compile($expression, array('a', 'B' => 'b'));
219220
$expressionLanguage->compile($expression, array('B' => 'b', 'a'));
220221
}
222+
223+
/**
224+
* @dataProvider getRegisterCallbacks
225+
* @expectedException \LogicException
226+
*/
227+
public function testRegisterAfterParse($registerCallback)
228+
{
229+
$el = new ExpressionLanguage();
230+
$el->parse('1 + 1', array());
231+
$registerCallback($el);
232+
}
233+
234+
/**
235+
* @dataProvider getRegisterCallbacks
236+
* @expectedException \LogicException
237+
*/
238+
public function testRegisterAfterEval($registerCallback)
239+
{
240+
$el = new ExpressionLanguage();
241+
$el->evaluate('1 + 1');
242+
$registerCallback($el);
243+
}
244+
245+
/**
246+
* @dataProvider getRegisterCallbacks
247+
* @expectedException \LogicException
248+
*/
249+
public function testRegisterAfterCompile($registerCallback)
250+
{
251+
$el = new ExpressionLanguage();
252+
$el->compile('1 + 1');
253+
$registerCallback($el);
254+
}
255+
256+
public function getRegisterCallbacks()
257+
{
258+
return array(
259+
array(
260+
function (ExpressionLanguage $el) {
261+
$el->register('fn', function () {}, function () {});
262+
},
263+
),
264+
array(
265+
function (ExpressionLanguage $el) {
266+
$el->addFunction(new ExpressionFunction('fn', function () {}, function () {}));
267+
},
268+
),
269+
array(
270+
function (ExpressionLanguage $el) {
271+
$el->registerProvider(new TestProvider());
272+
},
273+
),
274+
);
275+
}
221276
}

0 commit comments

Comments
 (0)
0