Merge branch '2.6' into 2.7

* 2.6: (36 commits)
  [Debug] fix error message on double exception
  [Validator] make DateTime objects represented as strings in the violation message.
  [RFC] [DebugBundle] [HttpKernel] Avoid using container as dependency for DumpListener
  Upgrade information for the Translation component regarding the new LoggingTranslator class.
  [WebProfilerBundle] Remove usage of app.request in search bar template
  Fix initialized() with aliased services
  fix data type in docblock
  Rename Symfony2 to Symfony
  bumped Symfony version to 2.6.0
  updated VERSION for 2.6.0-BETA2
  updated CHANGELOG for 2.6.0-BETA2
  [Debug] fix ENT_SUBSTITUTE usage
  compare version using PHP_VERSION_ID
  backport #12489
  remove an unneeded check
  Remove block submit_widget
  reformat code as suggested by @fabpot
  Fix typo
  Make `\Request::get` more performant.
  properly set request attributes in controller test
  ...
This commit is contained in:
Fabien Potencier 2014-11-28 11:00:56 +01:00
commit d277c16a27
68 changed files with 593 additions and 265 deletions

View File

@ -7,6 +7,21 @@ in 2.3 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1
* 2.3.22 (2014-11-20)
* bug #12525 [Bundle][FrameworkBundle] be smarter when guessing the document root (xabbuh)
* bug #12296 [SecurityBundle] Authentication entry point is only registered with firewall exception listener, not with authentication listeners (rjkip)
* bug #12393 [DependencyInjection] inlined factory not referenced (boekkooi)
* bug #12436 [Filesystem] Fixed case for empty folder (yosmanyga)
* bug #12370 [Yaml] improve error message for multiple documents (xabbuh)
* bug #12170 [Form] fix form handling with OPTIONS request method (Tobion)
* bug #12235 [Validator] Fixed Regex::getHtmlPattern() to work with complex and negated patterns (webmozart)
* bug #12326 [Session] remove invalid hack in session regenerate (Tobion)
* bug #12341 [Kernel] ensure session is saved before sending response (Tobion)
* bug #12329 [Routing] serialize the compiled route to speed things up (Tobion)
* bug #12316 Break infinite loop while resolving aliases (chx)
* bug #12313 [Security][listener] change priority of switchuser (aitboudad)
* 2.3.21 (2014-10-24)
* bug #11696 [Form] Fix #11694 - Enforce options value type check in some form types (kix)

View File

@ -7,6 +7,26 @@ in 2.5 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.5.0...v2.5.1
* 2.5.7 (2014-11-20)
* bug #12525 [Bundle][FrameworkBundle] be smarter when guessing the document root (xabbuh)
* bug #12296 [SecurityBundle] Authentication entry point is only registered with firewall exception listener, not with authentication listeners (rjkip)
* bug #12489 [FrameworkBundle] Fix server run in case the router script does not exist (romainneutron)
* bug #12443 [HttpKernel] Adding support for invokable controllers in the RequestDataCollector (jameshalsall)
* bug #12393 [DependencyInjection] inlined factory not referenced (boekkooi)
* bug #12436 [Filesystem] Fixed case for empty folder (yosmanyga)
* bug #12397 [Routing] fix BC (nicolas-grekas)
* bug #12382 [Routing] removed errors from git (HeinZawHtet)
* bug #12370 [Yaml] improve error message for multiple documents (xabbuh)
* bug #12170 [Form] fix form handling with OPTIONS request method (Tobion)
* bug #12235 [Validator] Fixed Regex::getHtmlPattern() to work with complex and negated patterns (webmozart)
* bug #12326 [Session] remove invalid hack in session regenerate (Tobion)
* bug #12341 [Kernel] ensure session is saved before sending response (Tobion)
* bug #12329 [Routing] serialize the compiled route to speed things up (Tobion)
* bug #12291 [Form] Fixed usage of "name" variable in form_start block (webmozart)
* bug #12316 Break infinite loop while resolving aliases (chx)
* bug #12313 [Security][listener] change priority of switchuser (aitboudad)
* 2.5.6 (2014-10-24)
* bug #11696 [Form] Fix #11694 - Enforce options value type check in some form types (kix)

View File

@ -7,6 +7,25 @@ in 2.6 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.6.0...v2.6.1
* 2.6.0-BETA2 (2014-11-23)
* bug #12555 [Debug] fix ENT_SUBSTITUTE usage (nicolas-grekas)
* feature #12538 [FrameworkBundle] be smarter when guessing the document root (xabbuh)
* bug #12539 [TwigBundle] properly set request attributes in controller test (xabbuh)
* bug #12267 [Form][WebProfiler] Empty form names fix (kix)
* bug #12137 [FrameworkBundle] cache:clear command fills *.php.meta files with wrong data (Strate)
* bug #12525 [Bundle][FrameworkBundle] be smarter when guessing the document root (xabbuh)
* bug #12296 [SecurityBundle] Authentication entry point is only registered with firewall exception listener, not with authentication listeners (rjkip)
* bug #12446 [Twig/DebugBundle] move dump extension registration (nicolas-grekas)
* bug #12489 [FrameworkBundle] Fix server run in case the router script does not exist (romainneutron)
* feature #12404 [Form] Remove timezone options from DateType and TimeType (jakzal)
* bug #12487 [DomCrawler] Added support for 'link' tags in the Link class (StephaneSeng)
* bug #12490 [FrameworkBundle] Fix server start in case the PHP binary is not found (romainneutron)
* bug #12443 [HttpKernel] Adding support for invokable controllers in the RequestDataCollector (jameshalsall)
* bug #12393 [DependencyInjection] inlined factory not referenced (boekkooi)
* bug #12411 [VarDumper] Use Unicode Control Pictures (nicolas-grekas)
* bug #12436 [Filesystem] Fixed case for empty folder (yosmanyga)
* 2.6.0-BETA1 (2014-11-03)
* first beta release

View File

@ -1,7 +1,7 @@
CONTRIBUTORS
============
Symfony2 is the result of the work of many people who made the code better
Symfony is the result of the work of many people who made the code better
(see http://symfony.com/contributors for more information):
- Fabien Potencier (fabpot)
@ -24,9 +24,9 @@ Symfony2 is the result of the work of many people who made the code better
- Benjamin Eberlei (beberlei)
- Igor Wiedler (igorw)
- Hugo Hamon (hhamon)
- Nicolas Grekas (nicolas-grekas)
- Martin Hasoň (hason)
- Eriksen Costa (eriksencosta)
- Nicolas Grekas (nicolas-grekas)
- Christian Flothmann (xabbuh)
- Jonathan Wage (jwage)
- Grégoire Pineau (lyrixx)
@ -40,8 +40,8 @@ Symfony2 is the result of the work of many people who made the code better
- Saša Stamenković (umpirsky)
- Miha Vrhovnik
- Henrik Bjørnskov (henrikbjorn)
- Konstantin Kudryashov (everzet)
- Wouter De Jong (wouterj)
- Konstantin Kudryashov (everzet)
- Bilal Amarni (bamarni)
- Florin Patan (florinpatan)
- Eric Clemmons (ericclemmons)
@ -65,8 +65,8 @@ Symfony2 is the result of the work of many people who made the code better
- Luis Cordova (cordoval)
- Arnaud Le Blanc (arnaud-lb)
- Kevin Bond (kbond)
- Tim Nagel (merk)
- Ait Boudad Abdellatif (aitboudad)
- Tim Nagel (merk)
- Brice BERNARD (brikou)
- marc.weistroff
- lenar
@ -120,6 +120,7 @@ Symfony2 is the result of the work of many people who made the code better
- Andreas Hucks (meandmymonkey)
- Andréia Bohner (andreia)
- Noel Guilbert (noel)
- Peter Rehm (rpet)
- Charles Sarrazin (csarrazi)
- bronze1man
- sun (sun)
@ -138,7 +139,6 @@ Symfony2 is the result of the work of many people who made the code better
- Sven Paulus (subsven)
- Lars Strojny (lstrojny)
- Joel Wurtz (brouznouf)
- Peter Rehm (rpet)
- Rui Marinho (ruimarinho)
- Matthias Pigulla (mpdude)
- Julien Brochet (mewt)
@ -173,6 +173,7 @@ Symfony2 is the result of the work of many people who made the code better
- jdhoek
- Nikita Konstantinov
- Wodor Wodorski
- Iltar van der Berg
- julien pauli (jpauli)
- Beau Simensen (simensen)
- Robert Kiss (kepten)
@ -185,6 +186,7 @@ Symfony2 is the result of the work of many people who made the code better
- Chris Smith (cs278)
- Florian Klein (docteurklein)
- Manuel Kiessling (manuelkiessling)
- Daniel Wehner
- Atsuhiro KUBO (iteman)
- Andrew Moore (finewolf)
- Bertrand Zuchuat (garfield-fr)
@ -207,7 +209,6 @@ Symfony2 is the result of the work of many people who made the code better
- janschoenherr
- Marco Pivetta (ocramius)
- Ricard Clau (ricardclau)
- Iltar van der Berg
- Erin Millard
- John Kary (johnkary)
- Matthew Lewinski (lewinski)
@ -246,6 +247,7 @@ Symfony2 is the result of the work of many people who made the code better
- Shein Alexey
- Joe Lencioni
- Kai
- Karoly Negyesi (chx)
- Xavier HAUSHERR
- Albert Jessurum (ajessu)
- Laszlo Korte
@ -301,7 +303,6 @@ Symfony2 is the result of the work of many people who made the code better
- Iker Ibarguren (ikerib)
- Ricardo Oliveira (ricardolotr)
- ondrowan
- Daniel Wehner
- Evan S Kaufman (evanskaufman)
- mcben
- Maks Slesarenko
@ -311,6 +312,7 @@ Symfony2 is the result of the work of many people who made the code better
- Ioan Negulescu
- Jakub Škvára (jskvara)
- Andrew Udvare (audvare)
- Sarah Khalil (saro0h)
- alexpods
- Erik Trapman (eriktrapman)
- De Cock Xavier (xdecock)
@ -334,8 +336,8 @@ Symfony2 is the result of the work of many people who made the code better
- Lenar Lõhmus
- Zach Badgett (zachbadgett)
- Aurélien Fredouelle
- Karoly Negyesi (chx)
- Pavel Campr (pcampr)
- Disquedur
- Geoffrey Tran (geoff)
- Jan Behrens
- Sebastian Krebs
@ -363,6 +365,7 @@ Symfony2 is the result of the work of many people who made the code better
- Maxime Douailin
- Javier López (loalf)
- Dustin Dobervich (dustin10)
- Warnar Boekkooi
- Alexander M. Turek (derrabus)
- Sebastian Marek (proofek)
- Erkhembayar Gantulga (erheme318)
@ -421,6 +424,7 @@ Symfony2 is the result of the work of many people who made the code better
- Venu
- Lars Vierbergen
- Mark Challoner
- Dennis Hotson
- Andrew Tchircoff (andrewtch)
- michaelwilliams
- 1emming
@ -431,6 +435,7 @@ Symfony2 is the result of the work of many people who made the code better
- John Bohn (jbohn)
- Andrew Hilobok (hilobok)
- Christian Soronellas (theunic)
- Yosmany Garcia (yosmanyga)
- Daniel Beyer
- Jérôme Vieilledent (lolautruche)
- Degory Valentine
@ -480,9 +485,9 @@ Symfony2 is the result of the work of many people who made the code better
- grizlik
- Derek ROTH
- Shin Ohno (ganchiku)
- Geert De Deckere (geertdd)
- Jan Kramer (jankramer)
- abdul malik ikhsan (samsonasik)
- Sarah Khalil (saro0h)
- Timothée Barray (tyx)
- Benjamin Laugueux (yzalis)
- Christian Morgan
@ -531,6 +536,7 @@ Symfony2 is the result of the work of many people who made the code better
- Radosław Benkel
- ttomor
- Mei Gwilym (meigwilym)
- Michael H. Arieli (excelwebzone)
- Luciano Mammino (loige)
- fabios
- Sander Coolen (scoolen)
@ -540,6 +546,7 @@ Symfony2 is the result of the work of many people who made the code better
- Anton Babenko (antonbabenko)
- Irmantas Šiupšinskas (irmantas)
- Danilo Silva
- Stepan Anchugov (kix)
- Zachary Tong (polyfractal)
- Hryhorii Hrebiniuk
- dantleech
@ -567,7 +574,6 @@ Symfony2 is the result of the work of many people who made the code better
- Boris Vujicic (boris.vujicic)
- Max Beutel
- Catalin Dan
- Warnar Boekkooi
- Piotr Antosik (antek88)
- Artem Lopata
- Marcos Quesada (marcos_quesada)
@ -592,6 +598,7 @@ Symfony2 is the result of the work of many people who made the code better
- Daniel Mecke (daniel_mecke)
- Matteo Giachino (matteosister)
- Alex Demchenko (pilot)
- Tadas Gliaubicas (tadcka)
- Benoit Garret
- Thomas Royer (cydonia7)
- DerManoMann
@ -708,6 +715,7 @@ Symfony2 is the result of the work of many people who made the code better
- Max Summe
- WedgeSama
- Felds Liscia
- James Halsall (jaitsu)
- Maxime Veber (nek-)
- Tadcka
- Beth Binkovitz
@ -734,7 +742,6 @@ Symfony2 is the result of the work of many people who made the code better
- r1pp3rj4ck
- Robert Queck
- mlively
- Dennis Hotson
- Fabian Steiner (fabstei)
- Klaus Silveira (klaussilveira)
- Thomas Chmielowiec (chmielot)
@ -780,6 +787,7 @@ Symfony2 is the result of the work of many people who made the code better
- Martin Eckhardt
- Denis Zunke
- Jonathan Poston
- Adrian Olek (adrianolek)
- Przemysław Piechota (kibao)
- Leonid Terentyev (li0n)
- Adam Prager (padam87)
@ -800,7 +808,6 @@ Symfony2 is the result of the work of many people who made the code better
- Paul Seiffert (seiffert)
- Vasily Khayrulin (sirian)
- Stefan Koopmanschap (skoop)
- Yosmany Garcia (yosmanyga)
- Ivan Kurnosov
- stloyd
- Chris Tickner
@ -891,6 +898,7 @@ Symfony2 is the result of the work of many people who made the code better
- Joel Marcey
- David Christmann
- root
- James Hudson
- Tom Maguire
- David Zuelke
- Pierre Rineau
@ -906,6 +914,7 @@ Symfony2 is the result of the work of many people who made the code better
- grifx
- Robert Campbell
- Matt Lehner
- Hein Zaw Htet™
- Ruben Kruiswijk
- Michael J
- Alex Pods
@ -944,7 +953,9 @@ Symfony2 is the result of the work of many people who made the code better
- Vincent Composieux (eko)
- Franz Liedke (franzliedke)
- gondo (gondo)
- Gusakov Nikita (hell0w0rd)
- Osman Üngür (import)
- Jelle Bekker (jbekker)
- Ian Jenkins (jenkoian)
- Jorge Martin (jorgemartind)
- Kevin Herrera (kherge)
@ -973,6 +984,7 @@ Symfony2 is the result of the work of many people who made the code better
- Daniele Cesarini (ijanki)
- Ismail Asci (ismailasci)
- Simon CONSTANS (kosssi)
- Kristof Van Cauwenbergh (kristofvc)
- Ramon Henrique Ornelas (ramonornela)
- Till Klampaeckel (till)
- Tobias Weinert (tweini)
@ -1003,6 +1015,7 @@ Symfony2 is the result of the work of many people who made the code better
- patrick-mcdougle
- Dariusz Czech
- Anonymous User
- Eric J. Duran
- cmfcmf
- Drew Butler
- Steve Müller
@ -1118,6 +1131,7 @@ Symfony2 is the result of the work of many people who made the code better
- Vincent (vincent1870)
- Eugene Babushkin (warl)
- Xavier Amado (xamado)
- Dawid Pakuła (zulusx)
- Florent Cailhol
- szymek
- craigmarvelley

View File

@ -1,10 +1,10 @@
README
======
What is Symfony2?
What is Symfony?
-----------------
Symfony2 is a PHP 5.3 full-stack web framework. It is written with speed and
Symfony is a PHP 5.3 full-stack web framework. It is written with speed and
flexibility in mind. It allows developers to build better and easy to maintain
websites with PHP.
@ -14,7 +14,7 @@ to high traffic ones like Dailymotion or Yahoo! Answers.
Requirements
------------
Symfony2 is only supported on PHP 5.3.3 and up.
Symfony is only supported on PHP 5.3.3 and up.
Be warned that PHP versions before 5.3.8 are known to be buggy and might not
work for you:
@ -28,35 +28,35 @@ work for you:
known PHP bug (see https://bugs.php.net/bug.php?id=55156).
* PHP 5.3.16 has a major bug in the Reflection subsystem and is not suitable to
run Symfony2 (https://bugs.php.net/bug.php?id=62715)
run Symfony (https://bugs.php.net/bug.php?id=62715)
Installation
------------
The best way to install Symfony2 is to download the Symfony Standard Edition
The best way to install Symfony is to download the Symfony Standard Edition
available at [http://symfony.com/download][1].
Documentation
-------------
The "[Quick Tour][2]" tutorial gives you a first feeling of the framework. If,
like us, you think that Symfony2 can help speed up your development and take
like us, you think that Symfony can help speed up your development and take
the quality of your work to the next level, read the official
[Symfony2 documentation][3].
[Symfony documentation][3].
Contributing
------------
Symfony2 is an open source, community-driven project. If you'd like to contribute,
Symfony is an open source, community-driven project. If you'd like to contribute,
please read the [Contributing Code][4] part of the documentation. If you're submitting
a pull request, please follow the guidelines in the [Submitting a Patch][5] section
and use [Pull Request Template][6].
Running Symfony2 Tests
Running Symfony Tests
----------------------
Information on how to run the Symfony2 test suite can be found in the
[Running Symfony2 Tests][7] section.
Information on how to run the Symfony test suite can be found in the
[Running Symfony Tests][7] section.
[1]: http://symfony.com/download
[2]: http://symfony.com/get_started

View File

@ -364,3 +364,43 @@ $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
Then enjoy dumping variables by calling `dump($var)` anywhere in your PHP
and `{% dump var %}` or `{{ dump(var) }}` in Twig. Dumps are displayed
**in the web debug toolbar**.
Translation
-----------
With `LoggingTranslator`, a new translator class is introduced with Symfony
2.6. By default, the `@translator` service is referring to this class in the
debug environment.
If you have own services that depend on the `@translator` service and expect
this service to be an instance of either
`Symfony\Component\Translation\Translator` or
`Symfony\Bundle\FrameworkBundle\Translation\Translator`, e.g. by type-hinting
for either of these classes, you will need to change that type hint. You can
use the `TranslatorInterface` to be on the safe side for future changes.
Before:
```php
use Symfony\Component\Translation\Translator;
class MyService {
public function __construct(Translator $translator)
{
...
}
}
```
After:
```php
use Symfony\Component\Translation\TranslatorInterface;
class MyService {
public function __construct(TranslatorInterface $translator)
{
...
}
}
```

View File

@ -2,7 +2,7 @@ Doctrine Bridge
===============
Provides integration for [Doctrine](http://www.doctrine-project.org/) with
various Symfony2 components.
various Symfony components.
Resources
---------

View File

@ -1,7 +1,7 @@
Monolog Bridge
==============
Provides integration for Monolog with various Symfony2 components.
Provides integration for Monolog with various Symfony components.
Resources
---------

View File

@ -1,7 +1,7 @@
Propel Bridge
=============
Provides integration for Propel with various Symfony2 components.
Provides integration for Propel with various Symfony components.
Resources
---------

View File

@ -1,7 +1,7 @@
ProxyManager Bridge
===================
Provides integration for [ProxyManager][1] with various Symfony2 components.
Provides integration for [ProxyManager][1] with various Symfony components.
Resources
---------

View File

@ -2,7 +2,7 @@ Twig Bridge
===========
Provides integration for [Twig](http://twig.sensiolabs.org/) with various
Symfony2 components.
Symfony components.
Resources
---------

View File

@ -14,11 +14,6 @@
{{- parent() -}}
{%- endblock textarea_widget %}
{% block submit_widget -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %}
{{- parent() -}}
{%- endblock %}
{% block button_widget -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %}
{{- parent() -}}

View File

@ -75,13 +75,13 @@ class TranslationExtensionTest extends \PHPUnit_Framework_TestCase
return array(
// trans tag
array('{% trans %}Hello{% endtrans %}', 'Hello'),
array('{% trans %}%name%{% endtrans %}', 'Symfony2', array('name' => 'Symfony2')),
array('{% trans %}%name%{% endtrans %}', 'Symfony', array('name' => 'Symfony')),
array('{% trans from elsewhere %}Hello{% endtrans %}', 'Hello'),
array('{% trans %}Hello %name%{% endtrans %}', 'Hello Symfony2', array('name' => 'Symfony2')),
array('{% trans with { \'%name%\': \'Symfony2\' } %}Hello %name%{% endtrans %}', 'Hello Symfony2'),
array('{% set vars = { \'%name%\': \'Symfony2\' } %}{% trans with vars %}Hello %name%{% endtrans %}', 'Hello Symfony2'),
array('{% trans %}Hello %name%{% endtrans %}', 'Hello Symfony', array('name' => 'Symfony')),
array('{% trans with { \'%name%\': \'Symfony\' } %}Hello %name%{% endtrans %}', 'Hello Symfony'),
array('{% set vars = { \'%name%\': \'Symfony\' } %}{% trans with vars %}Hello %name%{% endtrans %}', 'Hello Symfony'),
array('{% trans into "fr"%}Hello{% endtrans %}', 'Hello'),
@ -91,9 +91,9 @@ class TranslationExtensionTest extends \PHPUnit_Framework_TestCase
array('{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is 5 apples', array('count' => 5),),
array('{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
'There is 5 apples (Symfony2)', array('count' => 5, 'name' => 'Symfony2'),),
array('{% transchoice count with { \'%name%\': \'Symfony2\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
'There is 5 apples (Symfony2)', array('count' => 5),),
'There is 5 apples (Symfony)', array('count' => 5, 'name' => 'Symfony'),),
array('{% transchoice count with { \'%name%\': \'Symfony\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
'There is 5 apples (Symfony)', array('count' => 5),),
array('{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is no apples', array('count' => 0),),
array('{% transchoice 5 into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
@ -101,14 +101,14 @@ class TranslationExtensionTest extends \PHPUnit_Framework_TestCase
// trans filter
array('{{ "Hello"|trans }}', 'Hello'),
array('{{ name|trans }}', 'Symfony2', array('name' => 'Symfony2')),
array('{{ hello|trans({ \'%name%\': \'Symfony2\' }) }}', 'Hello Symfony2', array('hello' => 'Hello %name%')),
array('{% set vars = { \'%name%\': \'Symfony2\' } %}{{ hello|trans(vars) }}', 'Hello Symfony2', array('hello' => 'Hello %name%')),
array('{{ name|trans }}', 'Symfony', array('name' => 'Symfony')),
array('{{ hello|trans({ \'%name%\': \'Symfony\' }) }}', 'Hello Symfony', array('hello' => 'Hello %name%')),
array('{% set vars = { \'%name%\': \'Symfony\' } %}{{ hello|trans(vars) }}', 'Hello Symfony', array('hello' => 'Hello %name%')),
array('{{ "Hello"|trans({}, "messages", "fr") }}', 'Hello'),
// transchoice filter
array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count) }}', 'There is 5 apples', array('count' => 5)),
array('{{ text|transchoice(5, {\'%name%\': \'Symfony2\'}) }}', 'There is 5 apples (Symfony2)', array('text' => '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)')),
array('{{ text|transchoice(5, {\'%name%\': \'Symfony\'}) }}', 'There is 5 apples (Symfony)', array('text' => '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)')),
array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count, {}, "messages", "fr") }}', 'There is 5 apples', array('count' => 5)),
);
}

View File

@ -18,8 +18,8 @@
<service id="debug.dump_listener" class="Symfony\Component\HttpKernel\EventListener\DumpListener">
<tag name="kernel.event_subscriber" />
<argument type="service" id="service_container" />
<argument>data_collector.dump</argument>
<argument type="service" id="var_dumper.cloner" />
<argument type="service" id="data_collector.dump" />
</service>
<service id="var_dumper.cloner" class="Symfony\Component\VarDumper\Cloner\VarCloner" />

View File

@ -127,6 +127,9 @@ EOF
$tempKernel = $this->getTempKernel($realKernel, $namespace, $realKernelClass, $warmupDir);
$tempKernel->boot();
$tempKernelReflection = new \ReflectionObject($tempKernel);
$tempKernelFile = $tempKernelReflection->getFileName();
// warmup temporary dir
$warmer = $tempKernel->getContainer()->get('cache_warmer');
if ($enableOptionalWarmers) {
@ -162,6 +165,9 @@ EOF
file_put_contents(str_replace($search, $replace, $file), $content);
unlink($file);
}
// remove temp kernel file after cache warmed up
@unlink($tempKernelFile);
}
/**
@ -201,13 +207,30 @@ namespace $namespace
{
return '$rootDir';
}
protected function buildContainer()
{
\$container = parent::buildContainer();
// filter container's resources, removing reference to temp kernel file
\$resources = \$container->getResources();
\$filteredResources = array();
foreach (\$resources as \$resource) {
if ((string) \$resource !== __FILE__) {
\$filteredResources[] = \$resource;
}
}
\$container->setResources(\$filteredResources);
return \$container;
}
}
}
EOF;
$this->getContainer()->get('filesystem')->mkdir($warmupDir);
file_put_contents($file = $warmupDir.'/kernel.tmp', $code);
require_once $file;
@unlink($file);
$class = "$namespace\\$class";
return new $class($parent->getEnvironment(), $parent->isDebug());

View File

@ -19,7 +19,7 @@ use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\ProcessBuilder;
/**
* Runs Symfony2 application using PHP built-in web server.
* Runs Symfony application using PHP built-in web server.
*
* @author Michał Pipa <michal.pipa.xsolve@gmail.com>
*/
@ -83,12 +83,6 @@ EOF
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (defined('HHVM_VERSION')) {
$output->writeln('<error>This command is not supported on HHVM.</error>');
return 1;
}
$documentRoot = $input->getOption('docroot');
if (null === $documentRoot) {

View File

@ -33,7 +33,7 @@ class ServerStartCommand extends ServerCommand
$this
->setDefinition(array(
new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', 'web/'),
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null),
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
))
->setName('server:start')
@ -83,6 +83,18 @@ EOF
return 1;
}
$documentRoot = $input->getOption('docroot');
if (null === $documentRoot) {
$documentRoot = $this->getContainer()->getParameter('kernel.root_dir').'/../web';
}
if (!is_dir($documentRoot)) {
$output->writeln(sprintf('<error>The given document root directory "%s" does not exist</error>', $documentRoot));
return 1;
}
$env = $this->getContainer()->getParameter('kernel.environment');
if ('prod' === $env) {
@ -111,7 +123,7 @@ EOF
return 1;
}
if (null === $process = $this->createServerProcess($output, $address, $input->getOption('docroot'), $input->getOption('router'), $env, null)) {
if (null === $process = $this->createServerProcess($output, $address, $documentRoot, $input->getOption('router'), $env, null)) {
return 1;
}

View File

@ -498,7 +498,7 @@ class Configuration implements ConfigurationInterface
// API version already during container configuration
// (to adjust service classes etc.)
// See https://github.com/symfony/symfony/issues/11580
$v['validation']['api'] = version_compare(PHP_VERSION, '5.3.9', '<')
$v['validation']['api'] = PHP_VERSION_ID < 50309
? '2.4'
: '2.5-bc';

View File

@ -0,0 +1,78 @@
<?php
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand\Fixture\TestAppKernel;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\ResourceInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
class CacheClearCommandTest extends TestCase
{
/** @var TestAppKernel */
private $kernel;
/** @var Filesystem */
private $fs;
private $rootDir;
protected function setUp()
{
$this->fs = new Filesystem();
$this->kernel = new TestAppKernel('test', true);
$this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_');
$this->kernel->setRootDir($this->rootDir);
$this->fs->mkdir($this->rootDir);
}
protected function tearDown()
{
$this->fs->remove($this->rootDir);
}
public function testCacheIsFreshAfterCacheClearedWithWarmup()
{
$input = new ArrayInput(array('cache:clear'));
$application = new Application($this->kernel);
$application->setCatchExceptions(false);
$application->doRun($input, new NullOutput());
// Ensure that all *.meta files are fresh
$finder = new Finder();
$metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
// simply check that cache is warmed up
$this->assertGreaterThanOrEqual(1, count($metaFiles));
foreach ($metaFiles as $file) {
$configCache = new ConfigCache(substr($file, 0, -5), true);
$this->assertTrue(
$configCache->isFresh(),
sprintf(
'Meta file "%s" is not fresh',
(string) $file
)
);
}
// check that app kernel file present in meta file of container's cache
$containerRef = new \ReflectionObject($this->kernel->getContainer());
$containerFile = $containerRef->getFileName();
$containerMetaFile = $containerFile.'.meta';
$kernelRef = new \ReflectionObject($this->kernel);
$kernelFile = $kernelRef->getFileName();
/** @var ResourceInterface[] $meta */
$meta = unserialize(file_get_contents($containerMetaFile));
$found = false;
foreach ($meta as $resource) {
if ((string) $resource === $kernelFile) {
$found = true;
break;
}
}
$this->assertTrue($found, 'Kernel file should present as resource');
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand\Fixture;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
class TestAppKernel extends Kernel
{
public function registerBundles()
{
return array(
new FrameworkBundle(),
);
}
public function setRootDir($rootDir)
{
$this->rootDir = $rootDir;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.DIRECTORY_SEPARATOR.'config.yml');
}
}

View File

@ -0,0 +1,2 @@
framework:
secret: test

View File

@ -17,7 +17,7 @@ class JsonDescriptorTest extends AbstractDescriptorTest
{
protected function setUp()
{
if (version_compare(phpversion(), '5.4.0', '<')) {
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('Test skipped on PHP 5.3 as JSON_PRETTY_PRINT does not exist.');
}
}

View File

@ -131,7 +131,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
'static_method' => array('loadValidatorMetadata'),
'translation_domain' => 'validators',
'strict_email' => false,
'api' => version_compare(PHP_VERSION, '5.3.9', '<') ? '2.4' : '2.5-bc',
'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc',
),
'annotations' => array(
'cache' => 'file',

View File

@ -295,7 +295,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
$this->assertSame('setApiVersion', $calls[6][0]);
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]);
} else {
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
@ -448,7 +448,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
} else {
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
@ -472,7 +472,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
} else {
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);

View File

@ -19,7 +19,8 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Templating\TemplateReferenceInterface;
/**
* ExceptionController.
* ExceptionController renders error or exception pages for a given
* FlattenException.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Matthias Pigulla <mp@webfactory.de>
@ -27,6 +28,10 @@ use Symfony\Component\Templating\TemplateReferenceInterface;
class ExceptionController
{
protected $twig;
/**
* @var bool Show error (false) or exception (true) pages by default.
*/
protected $debug;
public function __construct(\Twig_Environment $twig, $debug)
@ -38,6 +43,10 @@ class ExceptionController
/**
* Converts an Exception to a Response.
*
* A "showException" request parameter can be used to force display of an error page (when set to false) or
* the exception page (when true). If it is not present, the "debug" value passed into the constructor will
* be used.
*
* @param Request $request The request
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
@ -49,25 +58,20 @@ class ExceptionController
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
{
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
$showException = $request->attributes->get('showException', $this->debug); // As opposed to an additional parameter, this maintains BC
return $this->createResponse($request, $exception, $this->debug, $logger, $currentContent);
}
$code = $exception->getStatusCode();
/**
* Displays the error page for arbitrary status codes and formats.
*
* @param Request $request The request
* @param int $code The HTTP status code to show the error page for.
*
* @return Response
*
* @throws \InvalidArgumentException When the error template does not exist
*/
public function testErrorPageAction(Request $request, $code)
{
$exception = FlattenException::create(new \Exception("Something has intentionally gone wrong."), $code);
return $this->createResponse($request, $exception, false);
return new Response($this->twig->render(
$this->findTemplate($request, $request->getRequestFormat(), $code, $showException),
array(
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
'currentContent' => $currentContent,
)
));
}
/**
@ -90,19 +94,19 @@ class ExceptionController
* @param Request $request
* @param string $format
* @param int $code An HTTP response status code
* @param bool $debug
* @param bool $showException
*
* @return TemplateReferenceInterface
*/
protected function findTemplate(Request $request, $format, $code, $debug)
protected function findTemplate(Request $request, $format, $code, $showException)
{
$name = $debug ? 'exception' : 'error';
if ($debug && 'html' == $format) {
$name = $showException ? 'exception' : 'error';
if ($showException && 'html' == $format) {
$name = 'exception_full';
}
// when not in debug, try to find a template for the specific HTTP status code and format
if (!$debug) {
// For error pages, try to find a template for the specific HTTP status code and format
if (!$showException) {
$template = new TemplateReference('TwigBundle', 'Exception', $name.$code, $format, 'twig');
if ($this->templateExists($template)) {
return $template;
@ -118,7 +122,7 @@ class ExceptionController
// default to a generic HTML exception
$request->setRequestFormat('html');
return new TemplateReference('TwigBundle', 'Exception', $debug ? 'exception_full' : $name, 'html', 'twig');
return new TemplateReference('TwigBundle', 'Exception', $showException ? 'exception_full' : $name, 'html', 'twig');
}
// to be removed when the minimum required version of Twig is >= 2.0
@ -138,29 +142,4 @@ class ExceptionController
return false;
}
/**
* @param Request $request
* @param FlattenException $exception
* @param bool $debug
* @param DebugLoggerInterface $logger
* @param string $currentContent
*
* @return Response
*/
protected function createResponse(Request $request, FlattenException $exception, $debug, DebugLoggerInterface $logger = null, $currentContent = '')
{
$code = $exception->getStatusCode();
return new Response($this->twig->render(
(string) $this->findTemplate($request, $request->getRequestFormat(), $code, $debug),
array(
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
'currentContent' => $currentContent,
)
));
}
}

View File

@ -0,0 +1,56 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\TwigBundle\Controller;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* PreviewErrorController can be used to test error pages.
*
* It will create a test exception and forward it to another controller.
*
* @author Matthias Pigulla <mp@webfactory.de>
*/
class PreviewErrorController
{
protected $kernel;
protected $controller;
public function __construct(HttpKernelInterface $kernel, $controller)
{
$this->kernel = $kernel;
$this->controller = $controller;
}
public function previewErrorPageAction(Request $request, $code)
{
$exception = FlattenException::create(new \Exception("Something has intentionally gone wrong."), $code);
/*
* This Request mimics the parameters set by
* \Symfony\Component\HttpKernel\EventListener\ExceptionListener::duplicateRequest, with
* the additional "showException" flag.
*/
$subRequest = $request->duplicate(null, null, array(
'_controller' => $this->controller,
'exception' => $exception,
'logger' => null,
'format' => $request->getRequestFormat(),
'showException' => false,
));
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
}

View File

@ -17,7 +17,7 @@ use Symfony\Component\Templating\TemplateReferenceInterface;
/**
* FilesystemLoader extends the default Twig filesystem loader
* to work with the Symfony2 paths and template references.
* to work with the Symfony paths and template references.
*
* @author Fabien Potencier <fabien@symfony.com>
*/

View File

@ -5,7 +5,7 @@
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="_twig_error_test" path="/{code}.{_format}">
<default key="_controller">twig.controller.exception:testErrorPageAction</default>
<default key="_controller">twig.controller.preview_error:previewErrorPageAction</default>
<default key="_format">html</default>
<requirement key="code">\d+</requirement>
</route>

View File

@ -25,6 +25,7 @@
<parameter key="twig.translation.extractor.class">Symfony\Bridge\Twig\Translation\TwigExtractor</parameter>
<parameter key="twig.exception_listener.class">Symfony\Component\HttpKernel\EventListener\ExceptionListener</parameter>
<parameter key="twig.controller.exception.class">Symfony\Bundle\TwigBundle\Controller\ExceptionController</parameter>
<parameter key="twig.controller.preview_error.class">Symfony\Bundle\TwigBundle\Controller\PreviewErrorController</parameter>
</parameters>
<services>
@ -133,5 +134,10 @@
<argument type="service" id="twig" />
<argument>%kernel.debug%</argument>
</service>
<service id="twig.controller.preview_error" class="%twig.controller.preview_error.class%">
<argument type="service" id="http_kernel" />
<argument>%twig.exception_listener.controller%</argument>
</service>
</services>
</container>

View File

@ -13,6 +13,7 @@ namespace Symfony\Bundle\TwigBundle\Tests\Controller;
use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Request;
class ExceptionControllerTest extends TestCase
@ -42,27 +43,23 @@ class ExceptionControllerTest extends TestCase
$controller->showAction($request, $flatten);
}
public function testErrorPagesInDebugMode()
public function testShowActionCanBeForcedToShowErrorPage()
{
$twig = new \Twig_Environment(
new \Twig_Loader_Array(array(
'TwigBundle:Exception:error404.html.twig' => '
{%- if exception is defined and status_text is defined and status_code is defined -%}
OK
{%- else -%}
"exception" variable is missing
{%- endif -%}
',
'TwigBundle:Exception:error404.html.twig' => 'ok',
))
);
$request = Request::create('whatever');
$request = Request::create('whatever', 'GET');
$request->attributes->set('showException', false);
$exception = FlattenException::create(new \Exception(), 404);
$controller = new ExceptionController($twig, /* "showException" defaults to --> */ true);
$controller = new ExceptionController($twig, /* "debug" set to --> */ true);
$response = $controller->testErrorPageAction($request, 404);
$response = $controller->showAction($request, $exception, null);
$this->assertEquals(200, $response->getStatusCode()); // successful request
$this->assertEquals('OK', $response->getContent()); // content of the error404.html template
$this->assertEquals('ok', $response->getContent()); // content of the error404.html template
}
public function testFallbackToHtmlIfNoTemplateForRequestedFormat()
@ -75,9 +72,10 @@ class ExceptionControllerTest extends TestCase
$request = Request::create('whatever');
$request->setRequestFormat('txt');
$exception = FlattenException::create(new \Exception());
$controller = new ExceptionController($twig, false);
$response = $controller->testErrorPageAction($request, 42);
$response = $controller->showAction($request, $exception);
$this->assertEquals('html', $request->getRequestFormat());
}

View File

@ -0,0 +1,56 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\TwigBundle\Tests\Controller;
use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController;
use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
class PreviewErrorControllerTest extends TestCase
{
public function testForwardRequestToConfiguredController()
{
$self = $this;
$request = Request::create('whatever');
$response = new Response("");
$code = 123;
$logicalControllerName = 'foo:bar:baz';
$kernel = $this->getMock('\Symfony\Component\HttpKernel\HttpKernelInterface');
$kernel
->expects($this->once())
->method('handle')
->with(
$this->callback(function (Request $request) use ($self, $logicalControllerName, $code) {
$self->assertEquals($logicalControllerName, $request->attributes->get('_controller'));
$exception = $request->attributes->get('exception');
$self->assertInstanceOf('Symfony\Component\HttpKernel\Exception\FlattenException', $exception);
$self->assertEquals($code, $exception->getStatusCode());
$self->assertFalse($request->attributes->get('showException'));
return true;
}),
$this->equalTo(HttpKernelInterface::SUB_REQUEST)
)
->will($this->returnValue($response));
$controller = new PreviewErrorController($kernel, $logicalControllerName);
$this->assertSame($response, $controller->previewErrorPageAction($request, $code));
}
}

View File

@ -249,6 +249,7 @@ class ProfilerController
'start' => $start,
'end' => $end,
'limit' => $limit,
'request' => $request,
)), 200, array('Content-Type' => 'text/html'));
}

View File

@ -420,7 +420,7 @@
{% else %}
<div class="toggle-icon empty"></div>
{% endif %}
{{ name }}
{{ name|default('(no name)') }} {% if data.type is not empty %}[<abbr title="{{ data.type_class }}">{{ data.type }}</abbr>]{% endif %}
{% if data.errors is defined and data.errors|length > 0 %}
<div class="badge-error">{{ data.errors|length }}</div>
{% endif %}
@ -437,9 +437,9 @@
{% endmacro %}
{% macro form_tree_details(name, data, forms_by_hash) %}
<div class="tree-details" id="{{ data.id }}-details">
<div class="tree-details" {% if data.id is defined %} id="{{ data.id }}-details"{% endif %}>
<h2>
{{ name }}
{{ name|default('(no name)') }}
{% if data.type_class is defined %}
<span class="form-type">[<abbr title="{{ data.type_class }}">{{ data.type }}</abbr>]</span>
{% endif %}

View File

@ -15,7 +15,7 @@
</select>
<div class="clear-fix"></div>
<label for="url">URL</label>
<input type="url" name="url" id="url" value="{{ url }}" placeholder="e.g. {{ app.request.baseUrl }}">
<input type="url" name="url" id="url" value="{{ url }}" placeholder="e.g. {{ request.baseUrl }}">
<div class="clear-fix"></div>
<label for="token">Token</label>
<input type="text" name="token" id="token" value="{{ token }}" placeholder="e.g. 1f321b">

View File

@ -1,4 +1,4 @@
<!-- START of Symfony2 Web Debug Toolbar -->
<!-- START of Symfony Web Debug Toolbar -->
{% if 'normal' != position %}
<div id="sfMiniToolbar-{{ token }}" class="sf-minitoolbar" data-no-turbolink>
<a href="javascript:void(0);" title="Show Symfony toolbar" onclick="
@ -45,4 +45,4 @@
"></a>
{% endif %}
</div>
<!-- END of Symfony2 Web Debug Toolbar -->
<!-- END of Symfony Web Debug Toolbar -->

View File

@ -249,7 +249,7 @@ EOF
} catch (\Exception $e) {
// something nasty happened and we cannot throw an exception anymore
if ($this->debug) {
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage());
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
} else {
$title = 'Whoops, looks like something went wrong.';
}
@ -384,11 +384,6 @@ EOF;
*/
private function formatArgs(array $args)
{
if (PHP_VERSION_ID >= 50400) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
} else {
$flags = ENT_QUOTES;
}
$result = array();
foreach ($args as $key => $item) {
if ('object' === $item[0]) {
@ -429,7 +424,7 @@ EOF;
$str = iconv($charset, 'UTF-8', $str);
}
return htmlspecialchars($str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
}
/**

View File

@ -360,6 +360,10 @@ class Container implements IntrospectableContainerInterface
return true;
}
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
}
return isset($this->services[$id]) || array_key_exists($id, $this->services);
}

View File

@ -305,6 +305,10 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($sc->initialized('foo'), '->initialized() returns true if service is loaded');
$this->assertFalse($sc->initialized('foo1'), '->initialized() returns false if service is not loaded');
$this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
$this->assertFalse($sc->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
$sc->set('bar', new \stdClass());
$this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
}
public function testEnterLeaveCurrentScope()

View File

@ -1,7 +1,7 @@
EventDispatcher Component
=========================
The Symfony2 EventDispatcher component implements the Mediator pattern in a
The Symfony EventDispatcher component implements the Mediator pattern in a
simple and effective way to make your projects truly extensible.
```php

View File

@ -336,7 +336,7 @@ class Parser
$node = new Node\GetAttrNode($node, $arg, $arguments, $type);
} elseif ('[' === $token->value) {
if ($node instanceof Node\GetAttrNode && Node\GetAttrNode::METHOD_CALL === $node->attributes['type'] && version_compare(PHP_VERSION, '5.4.0', '<')) {
if ($node instanceof Node\GetAttrNode && Node\GetAttrNode::METHOD_CALL === $node->attributes['type'] && PHP_VERSION_ID < 50400) {
throw new SyntaxError('Array calls on a method call is only supported on PHP 5.4+', $token->cursor);
}

View File

@ -31,7 +31,7 @@ class FilePathsIteratorTest extends RealIteratorTestCase
public function getSubPathData()
{
$tmpDir = sys_get_temp_dir().'/symfony2_finder';
$tmpDir = sys_get_temp_dir().'/symfony_finder';
return array(
array(

View File

@ -18,7 +18,7 @@ abstract class RealIteratorTestCase extends IteratorTestCase
public static function setUpBeforeClass()
{
self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony2_finder';
self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
self::$files = array(
'.git/',
@ -74,7 +74,7 @@ abstract class RealIteratorTestCase extends IteratorTestCase
* Without the call to setUpBeforeClass() property can be null.
*/
if (!self::$tmpDir) {
self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony2_finder';
self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
}
if (is_array($files)) {

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
use Symfony\Component\HttpFoundation\Session\Session;
/**
* This provider uses a Symfony2 Session object to retrieve the user's
* This provider uses a Symfony Session object to retrieve the user's
* session ID.
*
* @see DefaultCsrfProvider

View File

@ -20,7 +20,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface;
/**
* Extension supporting the Symfony2 Validator component in forms.
* Extension supporting the Symfony Validator component in forms.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/

View File

@ -49,7 +49,7 @@ class FormConfigTest extends \PHPUnit_Framework_TestCase
array('9', true),
// Contrary to the HTML4 spec, we allow names starting with an
// underscore, since this is already a widely used practice in
// Symfony2.
// Symfony.
// For root forms, leading underscores will be stripped from the
// "id" attribute to produce valid HTML4.
array('_', true),

View File

@ -726,7 +726,19 @@ class Request
*/
public function get($key, $default = null, $deep = false)
{
return $this->query->get($key, $this->attributes->get($key, $this->request->get($key, $default, $deep), $deep), $deep);
if ($this !== $result = $this->query->get($key, $this, $deep)) {
return $result;
}
if ($this !== $result = $this->attributes->get($key, $this, $deep)) {
return $result;
}
if ($this !== $result = $this->request->get($key, $this, $deep)) {
return $result;
}
return $default;
}
/**

View File

@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
/**
* Allows session to be started by PHP and managed by Symfony2
* Allows session to be started by PHP and managed by Symfony
*
* @author Drak <drak@zikula.org>
*/

View File

@ -136,7 +136,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
return array(
array('foo', 'bar', array('foo' => 'bar')),
array('foo.bar', 'too much beer', array('foo.bar' => 'too much beer')),
array('great', 'symfony2 is great', array('great' => 'symfony2 is great')),
array('great', 'symfony is great', array('great' => 'symfony is great')),
);
}
@ -195,7 +195,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
*/
public function testGetIterator()
{
$attributes = array('hello' => 'world', 'symfony2' => 'rocks');
$attributes = array('hello' => 'world', 'symfony' => 'rocks');
foreach ($attributes as $key => $val) {
$this->session->set($key, $val);
}
@ -215,7 +215,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
public function testGetCount()
{
$this->session->set('hello', 'world');
$this->session->set('symfony2', 'rocks');
$this->session->set('symfony', 'rocks');
$this->assertCount(2, $this->session);
}

View File

@ -137,7 +137,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
$options = array(
'cookie_lifetime' => 123456,
'cookie_path' => '/my/cookie/path',
'cookie_domain' => 'symfony2.example.com',
'cookie_domain' => 'symfony.example.com',
'cookie_secure' => true,
'cookie_httponly' => false,
);

View File

@ -11,9 +11,10 @@
namespace Symfony\Component\HttpKernel\EventListener;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
use Symfony\Component\VarDumper\VarDumper;
/**
@ -27,30 +28,23 @@ class DumpListener implements EventSubscriberInterface
private $dumper;
/**
* @param ContainerInterface $container Service container, for lazy loading.
* @param string $dumper var_dumper dumper service to use.
* @param ClonerInterface $cloner Cloner service.
* @param DataDumperInterface $dumper Dumper service.
*/
public function __construct(ContainerInterface $container, $dumper)
public function __construct(ClonerInterface $cloner, DataDumperInterface $dumper)
{
$this->container = $container;
$this->cloner = $cloner;
$this->dumper = $dumper;
}
public function configure()
{
if ($this->container) {
$container = $this->container;
$dumper = $this->dumper;
$this->container = null;
$cloner = $this->cloner;
$dumper = $this->dumper;
VarDumper::setHandler(function ($var) use ($container, $dumper) {
$dumper = $container->get($dumper);
$cloner = $container->get('var_dumper.cloner');
$handler = function ($var) use ($dumper, $cloner) {$dumper->dump($cloner->cloneVar($var));};
VarDumper::setHandler($handler);
$handler($var);
});
}
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
$dumper->dump($cloner->cloneVar($var));
});
}
public static function getSubscribedEvents()

View File

@ -4,7 +4,7 @@ HttpKernel Component
HttpKernel provides the building blocks to create flexible and fast HTTP-based
frameworks.
``HttpKernelInterface`` is the core interface of the Symfony2 full-stack
``HttpKernelInterface`` is the core interface of the Symfony full-stack
framework:
```php
@ -23,11 +23,11 @@ interface HttpKernelInterface
It takes a ``Request`` as an input and should return a ``Response`` as an
output. Using this interface makes your code compatible with all frameworks
using the Symfony2 components. And this will give you many cool features for
using the Symfony components. And this will give you many cool features for
free.
Creating a framework based on the Symfony2 components is really easy. Here is
a very simple, but fully-featured framework based on the Symfony2 components:
Creating a framework based on the Symfony components is really easy. Here is
a very simple, but fully-featured framework based on the Symfony components:
```php
$routes = new RouteCollection();
@ -54,7 +54,7 @@ $kernel = new HttpKernel($dispatcher, $resolver);
$kernel->handle($request)->send();
```
This is all you need to create a flexible framework with the Symfony2
This is all you need to create a flexible framework with the Symfony
components.
Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side

View File

@ -11,10 +11,11 @@
namespace Symfony\Component\HttpKernel\Tests\EventListener;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpKernel\EventListener\DumpListener;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
use Symfony\Component\VarDumper\VarDumper;
/**
@ -34,34 +35,23 @@ class DumpListenerTest extends \PHPUnit_Framework_TestCase
public function testConfigure()
{
$prevDumper = $this->getDumpHandler();
$prevDumper = VarDumper::setHandler('var_dump');
VarDumper::setHandler($prevDumper);
$container = new ContainerBuilder();
$container->setDefinition('var_dumper.cloner', new Definition('Symfony\Component\HttpKernel\Tests\EventListener\MockCloner'));
$container->setDefinition('mock_dumper', new Definition('Symfony\Component\HttpKernel\Tests\EventListener\MockDumper'));
$cloner = new MockCloner();
$dumper = new MockDumper();
ob_start();
$exception = null;
$listener = new DumpListener($container, 'mock_dumper');
$listener = new DumpListener($cloner, $dumper);
try {
$listener->configure();
$lazyDumper = $this->getDumpHandler();
VarDumper::dump('foo');
$loadedDumper = $this->getDumpHandler();
VarDumper::dump('bar');
$this->assertSame('+foo-+bar-', ob_get_clean());
$listenerReflector = new \ReflectionClass($listener);
$lazyReflector = new \ReflectionFunction($lazyDumper);
$loadedReflector = new \ReflectionFunction($loadedDumper);
$this->assertSame($listenerReflector->getFilename(), $lazyReflector->getFilename());
$this->assertSame($listenerReflector->getFilename(), $loadedReflector->getFilename());
$this->assertGreaterThan($lazyReflector->getStartLine(), $loadedReflector->getStartLine());
} catch (\Exception $exception) {
}
@ -71,28 +61,22 @@ class DumpListenerTest extends \PHPUnit_Framework_TestCase
throw $exception;
}
}
private function getDumpHandler()
{
$prevDumper = VarDumper::setHandler('var_dump');
VarDumper::setHandler($prevDumper );
return $prevDumper;
}
}
class MockCloner
class MockCloner implements ClonerInterface
{
public function cloneVar($var)
{
return $var.'-';
return new Data(array($var.'-'));
}
}
class MockDumper
class MockDumper implements DataDumperInterface
{
public function dump($var)
public function dump(Data $data)
{
echo '+'.$var;
$rawData = $data->getRawData();
echo '+'.$rawData[0];
}
}

View File

@ -88,4 +88,4 @@ Once it is, the following steps have to be followed to build the .dat-file:
$ rm -rf build packagelist.txt
3. You can now move region.dat to replace the version bundled with Symfony2.
3. You can now move region.dat to replace the version bundled with Symfony.

View File

@ -38,7 +38,7 @@ if ($argc > 3 || 2 === $argc && '-h' === $argv[1]) {
bailout(<<<MESSAGE
Usage: php update-icu-component.php <path/to/icu/source> <path/to/icu/build>
Updates the ICU data for Symfony2 to the latest version of ICU.
Updates the ICU data for Symfony to the latest version of ICU.
If you downloaded the SVN repository before, you can pass the path to the
repository source in the first optional argument.

View File

@ -51,7 +51,7 @@ class NativeSessionTokenStorageTest extends \PHPUnit_Framework_TestCase
public function testStoreTokenInClosedSessionWithExistingSessionId()
{
if (version_compare(PHP_VERSION, '5.4', '<')) {
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('This test requires PHP 5.4 or later.');
}

View File

@ -108,7 +108,7 @@ class NativeSessionTokenStorage implements TokenStorageInterface
private function startSession()
{
if (version_compare(PHP_VERSION, '5.4', '>=')) {
if (PHP_VERSION_ID >= 50400) {
if (PHP_SESSION_NONE === session_status()) {
session_start();
}

View File

@ -24,7 +24,7 @@ class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler
/**
* Constructor.
*
* @param AuthenticationSuccessHandlerInterface $handler An AuthenticationFailureHandlerInterface instance
* @param AuthenticationSuccessHandlerInterface $handler An AuthenticationSuccessHandlerInterface instance
* @param array $options Options for processing a successful authentication attempt
* @param string $providerKey The provider key
*/

View File

@ -18,7 +18,7 @@ class JsonFileDumperTest extends \PHPUnit_Framework_TestCase
{
public function testDump()
{
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
if (PHP_VERSION_ID < 50400) {
$this->markTestIncomplete('PHP below 5.4 doesn\'t support JSON pretty printing');
}

View File

@ -74,8 +74,8 @@ class IdentityTranslatorTest extends \PHPUnit_Framework_TestCase
public function getTransTests()
{
return array(
array('Symfony2 is great!', 'Symfony2 is great!', array()),
array('Symfony2 is awesome!', 'Symfony2 is %what%!', array('%what%' => 'awesome')),
array('Symfony is great!', 'Symfony is great!', array()),
array('Symfony is awesome!', 'Symfony is %what%!', array('%what%' => 'awesome')),
);
}

View File

@ -356,18 +356,18 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
public function getTransTests()
{
return array(
array('Symfony2 est super !', 'Symfony2 is great!', 'Symfony2 est super !', array(), 'fr', ''),
array('Symfony2 est awesome !', 'Symfony2 is %what%!', 'Symfony2 est %what% !', array('%what%' => 'awesome'), 'fr', ''),
array('Symfony2 est super !', new String('Symfony2 is great!'), 'Symfony2 est super !', array(), 'fr', ''),
array('Symfony est super !', 'Symfony is great!', 'Symfony est super !', array(), 'fr', ''),
array('Symfony est awesome !', 'Symfony is %what%!', 'Symfony est %what% !', array('%what%' => 'awesome'), 'fr', ''),
array('Symfony est super !', new String('Symfony is great!'), 'Symfony est super !', array(), 'fr', ''),
);
}
public function getFlattenedTransTests()
{
$messages = array(
'symfony2' => array(
'symfony' => array(
'is' => array(
'great' => 'Symfony2 est super!',
'great' => 'Symfony est super!',
),
),
'foo' => array(
@ -379,7 +379,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
);
return array(
array('Symfony2 est super!', $messages, 'symfony2.is.great'),
array('Symfony est super!', $messages, 'symfony.is.great'),
array('Foo Bar Baz', $messages, 'foo.bar.baz'),
array('Foo Baz', $messages, 'foo.baz'),
);

View File

@ -1,3 +1,3 @@
en{
symfony{"Symfony 2 is great"}
symfony{"Symfony is great"}
}

View File

@ -1,3 +1,3 @@
fr{
symfony{"Symfony 2 est génial"}
symfony{"Symfony est génial"}
}

View File

@ -35,7 +35,7 @@ class RangeValidator extends ConstraintValidator
if (!is_numeric($value) && !$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
$this->buildViolation($constraint->invalidMessage)
->setParameter('{{ value }}', $this->formatValue($value))
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
->setCode(Range::INVALID_VALUE_ERROR)
->addViolation();
@ -61,7 +61,7 @@ class RangeValidator extends ConstraintValidator
if (null !== $constraint->max && $value > $max) {
$this->buildViolation($constraint->maxMessage)
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
->setParameter('{{ limit }}', $this->formatValue($max, self::PRETTY_DATE))
->setCode(Range::BEYOND_RANGE_ERROR)
->addViolation();
@ -71,7 +71,7 @@ class RangeValidator extends ConstraintValidator
if (null !== $constraint->min && $value < $min) {
$this->buildViolation($constraint->minMessage)
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
->setParameter('{{ limit }}', $this->formatValue($min, self::PRETTY_DATE))
->setCode(Range::BELOW_RANGE_ERROR)
->addViolation();

View File

@ -52,20 +52,20 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
public function getLessThanTen()
{
return array(
array(9.99999),
array('9.99999'),
array(5),
array(1.0),
array(9.99999, '9.99999'),
array('9.99999', '"9.99999"'),
array(5, '5'),
array(1.0, '1.0'),
);
}
public function getMoreThanTwenty()
{
return array(
array(20.000001),
array('20.000001'),
array(21),
array(30.0),
array(20.000001, '20.000001'),
array('20.000001', '"20.000001"'),
array(21, '21'),
array(30.0, '30.0'),
);
}
@ -105,7 +105,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getLessThanTen
*/
public function testInvalidValuesMin($value)
public function testInvalidValuesMin($value, $formattedValue)
{
$constraint = new Range(array(
'min' => 10,
@ -115,7 +115,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate($value, $constraint);
$this->buildViolation('myMessage')
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $formattedValue)
->setParameter('{{ limit }}', 10)
->setCode(Range::BELOW_RANGE_ERROR)
->assertRaised();
@ -124,7 +124,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getMoreThanTwenty
*/
public function testInvalidValuesMax($value)
public function testInvalidValuesMax($value, $formattedValue)
{
$constraint = new Range(array(
'max' => 20,
@ -134,7 +134,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate($value, $constraint);
$this->buildViolation('myMessage')
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $formattedValue)
->setParameter('{{ limit }}', 20)
->setCode(Range::BEYOND_RANGE_ERROR)
->assertRaised();
@ -143,7 +143,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getMoreThanTwenty
*/
public function testInvalidValuesCombinedMax($value)
public function testInvalidValuesCombinedMax($value, $formattedValue)
{
$constraint = new Range(array(
'min' => 10,
@ -155,7 +155,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate($value, $constraint);
$this->buildViolation('myMaxMessage')
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $formattedValue)
->setParameter('{{ limit }}', 20)
->setCode(Range::BEYOND_RANGE_ERROR)
->assertRaised();
@ -164,7 +164,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getLessThanTen
*/
public function testInvalidValuesCombinedMin($value)
public function testInvalidValuesCombinedMin($value, $formattedValue)
{
$constraint = new Range(array(
'min' => 10,
@ -176,7 +176,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate($value, $constraint);
$this->buildViolation('myMinMessage')
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $formattedValue)
->setParameter('{{ limit }}', 10)
->setCode(Range::BELOW_RANGE_ERROR)
->assertRaised();
@ -212,13 +212,13 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->setDefaultTimezone('UTC');
$tests = array(
array(new \DateTime('March 20, 2013')),
array(new \DateTime('March 9, 2014')),
array(new \DateTime('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'),
array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'),
);
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
$tests[] = array(new \DateTimeImmutable('March 20, 2013'));
$tests[] = array(new \DateTimeImmutable('March 9, 2014'));
$tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM');
$tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM');
}
$this->restoreDefaultTimezone();
@ -233,13 +233,13 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->setDefaultTimezone('UTC');
$tests = array(
array(new \DateTime('March 21, 2014')),
array(new \DateTime('March 9, 2015')),
array(new \DateTime('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'),
array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'),
);
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
$tests[] = array(new \DateTimeImmutable('March 21, 2014'));
$tests[] = array(new \DateTimeImmutable('March 9, 2015'));
$tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM');
$tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM');
}
$this->restoreDefaultTimezone();
@ -283,7 +283,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getSoonerThanTenthMarch2014
*/
public function testInvalidDatesMin($value)
public function testInvalidDatesMin($value, $dateTimeAsString)
{
// Conversion of dates to string differs between ICU versions
// Make sure we have the correct version loaded
@ -297,7 +297,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate($value, $constraint);
$this->buildViolation('myMessage')
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $dateTimeAsString)
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
->setCode(Range::BELOW_RANGE_ERROR)
->assertRaised();
@ -306,7 +306,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getLaterThanTwentiethMarch2014
*/
public function testInvalidDatesMax($value)
public function testInvalidDatesMax($value, $dateTimeAsString)
{
// Conversion of dates to string differs between ICU versions
// Make sure we have the correct version loaded
@ -320,7 +320,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate($value, $constraint);
$this->buildViolation('myMessage')
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $dateTimeAsString)
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
->setCode(Range::BEYOND_RANGE_ERROR)
->assertRaised();
@ -329,7 +329,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getLaterThanTwentiethMarch2014
*/
public function testInvalidDatesCombinedMax($value)
public function testInvalidDatesCombinedMax($value, $dateTimeAsString)
{
// Conversion of dates to string differs between ICU versions
// Make sure we have the correct version loaded
@ -345,7 +345,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate($value, $constraint);
$this->buildViolation('myMaxMessage')
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $dateTimeAsString)
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
->setCode(Range::BEYOND_RANGE_ERROR)
->assertRaised();
@ -354,7 +354,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getSoonerThanTenthMarch2014
*/
public function testInvalidDatesCombinedMin($value)
public function testInvalidDatesCombinedMin($value, $dateTimeAsString)
{
// Conversion of dates to string differs between ICU versions
// Make sure we have the correct version loaded
@ -370,7 +370,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
$this->validator->validate($value, $constraint);
$this->buildViolation('myMinMessage')
->setParameter('{{ value }}', $value)
->setParameter('{{ value }}', $dateTimeAsString)
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
->setCode(Range::BELOW_RANGE_ERROR)
->assertRaised();

View File

@ -21,7 +21,7 @@ class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
{
protected function setUp()
{
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
}

View File

@ -21,7 +21,7 @@ class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest
{
protected function setUp()
{
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
}

View File

@ -112,7 +112,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testDefaultApiVersion()
{
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
// Old implementation on PHP < 5.3.9
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
} else {
@ -135,7 +135,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testSetApiVersion24And25()
{
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
}

View File

@ -325,7 +325,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface
));
}
if (version_compare(PHP_VERSION, '5.3.9', '<') && $apiVersion === Validation::API_VERSION_2_5_BC) {
if (PHP_VERSION_ID < 50309 && $apiVersion === Validation::API_VERSION_2_5_BC) {
throw new InvalidArgumentException(sprintf(
'The Validator API that is compatible with both Symfony 2.4 '.
'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. '.
@ -385,7 +385,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface
$apiVersion = $this->apiVersion;
if (null === $apiVersion) {
$apiVersion = version_compare(PHP_VERSION, '5.3.9', '<')
$apiVersion = PHP_VERSION_ID < 50309
? Validation::API_VERSION_2_4
: Validation::API_VERSION_2_5_BC;
}