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 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 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) * 2.3.21 (2014-10-24)
* bug #11696 [Form] Fix #11694 - Enforce options value type check in some form types (kix) * 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 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 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) * 2.5.6 (2014-10-24)
* bug #11696 [Form] Fix #11694 - Enforce options value type check in some form types (kix) * 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 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 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) * 2.6.0-BETA1 (2014-11-03)
* first beta release * first beta release

View File

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

View File

@ -1,10 +1,10 @@
README 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 flexibility in mind. It allows developers to build better and easy to maintain
websites with PHP. websites with PHP.
@ -14,7 +14,7 @@ to high traffic ones like Dailymotion or Yahoo! Answers.
Requirements 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 Be warned that PHP versions before 5.3.8 are known to be buggy and might not
work for you: work for you:
@ -28,35 +28,35 @@ work for you:
known PHP bug (see https://bugs.php.net/bug.php?id=55156). 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 * 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 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]. available at [http://symfony.com/download][1].
Documentation Documentation
------------- -------------
The "[Quick Tour][2]" tutorial gives you a first feeling of the framework. If, 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 the quality of your work to the next level, read the official
[Symfony2 documentation][3]. [Symfony documentation][3].
Contributing 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 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 a pull request, please follow the guidelines in the [Submitting a Patch][5] section
and use [Pull Request Template][6]. 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 Information on how to run the Symfony test suite can be found in the
[Running Symfony2 Tests][7] section. [Running Symfony Tests][7] section.
[1]: http://symfony.com/download [1]: http://symfony.com/download
[2]: http://symfony.com/get_started [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 Then enjoy dumping variables by calling `dump($var)` anywhere in your PHP
and `{% dump var %}` or `{{ dump(var) }}` in Twig. Dumps are displayed and `{% dump var %}` or `{{ dump(var) }}` in Twig. Dumps are displayed
**in the web debug toolbar**. **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 Provides integration for [Doctrine](http://www.doctrine-project.org/) with
various Symfony2 components. various Symfony components.
Resources Resources
--------- ---------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -75,13 +75,13 @@ class TranslationExtensionTest extends \PHPUnit_Framework_TestCase
return array( return array(
// trans tag // trans tag
array('{% trans %}Hello{% endtrans %}', 'Hello'), 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 from elsewhere %}Hello{% endtrans %}', 'Hello'),
array('{% trans %}Hello %name%{% endtrans %}', 'Hello Symfony2', array('name' => 'Symfony2')), array('{% trans %}Hello %name%{% endtrans %}', 'Hello Symfony', array('name' => 'Symfony')),
array('{% trans with { \'%name%\': \'Symfony2\' } %}Hello %name%{% endtrans %}', 'Hello Symfony2'), array('{% trans with { \'%name%\': \'Symfony\' } %}Hello %name%{% endtrans %}', 'Hello Symfony'),
array('{% set vars = { \'%name%\': \'Symfony2\' } %}{% trans with vars %}Hello %name%{% endtrans %}', 'Hello Symfony2'), array('{% set vars = { \'%name%\': \'Symfony\' } %}{% trans with vars %}Hello %name%{% endtrans %}', 'Hello Symfony'),
array('{% trans into "fr"%}Hello{% endtrans %}', 'Hello'), 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 %}', 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),), '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 %}', 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'),), 'There is 5 apples (Symfony)', array('count' => 5, 'name' => 'Symfony'),),
array('{% transchoice count with { \'%name%\': \'Symfony2\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', 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 (Symfony2)', array('count' => 5),), '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 %}', 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),), '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 %}', 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 // trans filter
array('{{ "Hello"|trans }}', 'Hello'), array('{{ "Hello"|trans }}', 'Hello'),
array('{{ name|trans }}', 'Symfony2', array('name' => 'Symfony2')), array('{{ name|trans }}', 'Symfony', array('name' => 'Symfony')),
array('{{ hello|trans({ \'%name%\': \'Symfony2\' }) }}', 'Hello Symfony2', array('hello' => 'Hello %name%')), array('{{ hello|trans({ \'%name%\': \'Symfony\' }) }}', 'Hello Symfony', array('hello' => 'Hello %name%')),
array('{% set vars = { \'%name%\': \'Symfony2\' } %}{{ hello|trans(vars) }}', 'Hello Symfony2', array('hello' => 'Hello %name%')), array('{% set vars = { \'%name%\': \'Symfony\' } %}{{ hello|trans(vars) }}', 'Hello Symfony', array('hello' => 'Hello %name%')),
array('{{ "Hello"|trans({}, "messages", "fr") }}', 'Hello'), array('{{ "Hello"|trans({}, "messages", "fr") }}', 'Hello'),
// transchoice filter // 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('{{ "{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)), 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"> <service id="debug.dump_listener" class="Symfony\Component\HttpKernel\EventListener\DumpListener">
<tag name="kernel.event_subscriber" /> <tag name="kernel.event_subscriber" />
<argument type="service" id="service_container" /> <argument type="service" id="var_dumper.cloner" />
<argument>data_collector.dump</argument> <argument type="service" id="data_collector.dump" />
</service> </service>
<service id="var_dumper.cloner" class="Symfony\Component\VarDumper\Cloner\VarCloner" /> <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 = $this->getTempKernel($realKernel, $namespace, $realKernelClass, $warmupDir);
$tempKernel->boot(); $tempKernel->boot();
$tempKernelReflection = new \ReflectionObject($tempKernel);
$tempKernelFile = $tempKernelReflection->getFileName();
// warmup temporary dir // warmup temporary dir
$warmer = $tempKernel->getContainer()->get('cache_warmer'); $warmer = $tempKernel->getContainer()->get('cache_warmer');
if ($enableOptionalWarmers) { if ($enableOptionalWarmers) {
@ -162,6 +165,9 @@ EOF
file_put_contents(str_replace($search, $replace, $file), $content); file_put_contents(str_replace($search, $replace, $file), $content);
unlink($file); unlink($file);
} }
// remove temp kernel file after cache warmed up
@unlink($tempKernelFile);
} }
/** /**
@ -201,13 +207,30 @@ namespace $namespace
{ {
return '$rootDir'; 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; EOF;
$this->getContainer()->get('filesystem')->mkdir($warmupDir); $this->getContainer()->get('filesystem')->mkdir($warmupDir);
file_put_contents($file = $warmupDir.'/kernel.tmp', $code); file_put_contents($file = $warmupDir.'/kernel.tmp', $code);
require_once $file; require_once $file;
@unlink($file);
$class = "$namespace\\$class"; $class = "$namespace\\$class";
return new $class($parent->getEnvironment(), $parent->isDebug()); return new $class($parent->getEnvironment(), $parent->isDebug());

View File

@ -19,7 +19,7 @@ use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\ProcessBuilder; 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> * @author Michał Pipa <michal.pipa.xsolve@gmail.com>
*/ */
@ -83,12 +83,6 @@ EOF
*/ */
protected function execute(InputInterface $input, OutputInterface $output) 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'); $documentRoot = $input->getOption('docroot');
if (null === $documentRoot) { if (null === $documentRoot) {

View File

@ -33,7 +33,7 @@ class ServerStartCommand extends ServerCommand
$this $this
->setDefinition(array( ->setDefinition(array(
new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'), 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'), new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
)) ))
->setName('server:start') ->setName('server:start')
@ -83,6 +83,18 @@ EOF
return 1; 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'); $env = $this->getContainer()->getParameter('kernel.environment');
if ('prod' === $env) { if ('prod' === $env) {
@ -111,7 +123,7 @@ EOF
return 1; 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; return 1;
} }

View File

@ -498,7 +498,7 @@ class Configuration implements ConfigurationInterface
// API version already during container configuration // API version already during container configuration
// (to adjust service classes etc.) // (to adjust service classes etc.)
// See https://github.com/symfony/symfony/issues/11580 // 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.4'
: '2.5-bc'; : '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() 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.'); $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'), 'static_method' => array('loadValidatorMetadata'),
'translation_domain' => 'validators', 'translation_domain' => 'validators',
'strict_email' => false, '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( 'annotations' => array(
'cache' => 'file', '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->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
$this->assertSame('setApiVersion', $calls[6][0]); $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]); $this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]);
} else { } else {
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]); $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]); $this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations // 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]); $this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
} else { } else {
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); $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]); $this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations // 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]); $this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
} else { } else {
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); $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; use Symfony\Component\Templating\TemplateReferenceInterface;
/** /**
* ExceptionController. * ExceptionController renders error or exception pages for a given
* FlattenException.
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
* @author Matthias Pigulla <mp@webfactory.de> * @author Matthias Pigulla <mp@webfactory.de>
@ -27,6 +28,10 @@ use Symfony\Component\Templating\TemplateReferenceInterface;
class ExceptionController class ExceptionController
{ {
protected $twig; protected $twig;
/**
* @var bool Show error (false) or exception (true) pages by default.
*/
protected $debug; protected $debug;
public function __construct(\Twig_Environment $twig, $debug) public function __construct(\Twig_Environment $twig, $debug)
@ -38,6 +43,10 @@ class ExceptionController
/** /**
* Converts an Exception to a Response. * 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 Request $request The request
* @param FlattenException $exception A FlattenException instance * @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance * @param DebugLoggerInterface $logger A DebugLoggerInterface instance
@ -49,25 +58,20 @@ class ExceptionController
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null) public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
{ {
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1)); $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();
}
/** return new Response($this->twig->render(
* Displays the error page for arbitrary status codes and formats. $this->findTemplate($request, $request->getRequestFormat(), $code, $showException),
* array(
* @param Request $request The request 'status_code' => $code,
* @param int $code The HTTP status code to show the error page for. 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
* 'exception' => $exception,
* @return Response 'logger' => $logger,
* 'currentContent' => $currentContent,
* @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);
} }
/** /**
@ -90,19 +94,19 @@ class ExceptionController
* @param Request $request * @param Request $request
* @param string $format * @param string $format
* @param int $code An HTTP response status code * @param int $code An HTTP response status code
* @param bool $debug * @param bool $showException
* *
* @return TemplateReferenceInterface * @return TemplateReferenceInterface
*/ */
protected function findTemplate(Request $request, $format, $code, $debug) protected function findTemplate(Request $request, $format, $code, $showException)
{ {
$name = $debug ? 'exception' : 'error'; $name = $showException ? 'exception' : 'error';
if ($debug && 'html' == $format) { if ($showException && 'html' == $format) {
$name = 'exception_full'; $name = 'exception_full';
} }
// when not in debug, try to find a template for the specific HTTP status code and format // For error pages, try to find a template for the specific HTTP status code and format
if (!$debug) { if (!$showException) {
$template = new TemplateReference('TwigBundle', 'Exception', $name.$code, $format, 'twig'); $template = new TemplateReference('TwigBundle', 'Exception', $name.$code, $format, 'twig');
if ($this->templateExists($template)) { if ($this->templateExists($template)) {
return $template; return $template;
@ -118,7 +122,7 @@ class ExceptionController
// default to a generic HTML exception // default to a generic HTML exception
$request->setRequestFormat('html'); $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 // to be removed when the minimum required version of Twig is >= 2.0
@ -138,29 +142,4 @@ class ExceptionController
return false; 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 * 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> * @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"> xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="_twig_error_test" path="/{code}.{_format}"> <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> <default key="_format">html</default>
<requirement key="code">\d+</requirement> <requirement key="code">\d+</requirement>
</route> </route>

View File

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

View File

@ -13,6 +13,7 @@ namespace Symfony\Bundle\TwigBundle\Tests\Controller;
use Symfony\Bundle\TwigBundle\Tests\TestCase; use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Bundle\TwigBundle\Controller\ExceptionController; use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
class ExceptionControllerTest extends TestCase class ExceptionControllerTest extends TestCase
@ -42,27 +43,23 @@ class ExceptionControllerTest extends TestCase
$controller->showAction($request, $flatten); $controller->showAction($request, $flatten);
} }
public function testErrorPagesInDebugMode() public function testShowActionCanBeForcedToShowErrorPage()
{ {
$twig = new \Twig_Environment( $twig = new \Twig_Environment(
new \Twig_Loader_Array(array( new \Twig_Loader_Array(array(
'TwigBundle:Exception:error404.html.twig' => ' 'TwigBundle:Exception:error404.html.twig' => 'ok',
{%- if exception is defined and status_text is defined and status_code is defined -%}
OK
{%- else -%}
"exception" variable is missing
{%- endif -%}
',
)) ))
); );
$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->showAction($request, $exception, null);
$response = $controller->testErrorPageAction($request, 404);
$this->assertEquals(200, $response->getStatusCode()); // successful request $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() public function testFallbackToHtmlIfNoTemplateForRequestedFormat()
@ -75,9 +72,10 @@ class ExceptionControllerTest extends TestCase
$request = Request::create('whatever'); $request = Request::create('whatever');
$request->setRequestFormat('txt'); $request->setRequestFormat('txt');
$exception = FlattenException::create(new \Exception());
$controller = new ExceptionController($twig, false); $controller = new ExceptionController($twig, false);
$response = $controller->testErrorPageAction($request, 42);
$response = $controller->showAction($request, $exception);
$this->assertEquals('html', $request->getRequestFormat()); $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, 'start' => $start,
'end' => $end, 'end' => $end,
'limit' => $limit, 'limit' => $limit,
'request' => $request,
)), 200, array('Content-Type' => 'text/html')); )), 200, array('Content-Type' => 'text/html'));
} }

View File

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

View File

@ -15,7 +15,7 @@
</select> </select>
<div class="clear-fix"></div> <div class="clear-fix"></div>
<label for="url">URL</label> <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> <div class="clear-fix"></div>
<label for="token">Token</label> <label for="token">Token</label>
<input type="text" name="token" id="token" value="{{ token }}" placeholder="e.g. 1f321b"> <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 %} {% if 'normal' != position %}
<div id="sfMiniToolbar-{{ token }}" class="sf-minitoolbar" data-no-turbolink> <div id="sfMiniToolbar-{{ token }}" class="sf-minitoolbar" data-no-turbolink>
<a href="javascript:void(0);" title="Show Symfony toolbar" onclick=" <a href="javascript:void(0);" title="Show Symfony toolbar" onclick="
@ -45,4 +45,4 @@
"></a> "></a>
{% endif %} {% endif %}
</div> </div>
<!-- END of Symfony2 Web Debug Toolbar --> <!-- END of Symfony Web Debug Toolbar -->

View File

@ -249,7 +249,7 @@ EOF
} catch (\Exception $e) { } catch (\Exception $e) {
// something nasty happened and we cannot throw an exception anymore // something nasty happened and we cannot throw an exception anymore
if ($this->debug) { 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 { } else {
$title = 'Whoops, looks like something went wrong.'; $title = 'Whoops, looks like something went wrong.';
} }
@ -384,11 +384,6 @@ EOF;
*/ */
private function formatArgs(array $args) private function formatArgs(array $args)
{ {
if (PHP_VERSION_ID >= 50400) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
} else {
$flags = ENT_QUOTES;
}
$result = array(); $result = array();
foreach ($args as $key => $item) { foreach ($args as $key => $item) {
if ('object' === $item[0]) { if ('object' === $item[0]) {
@ -429,7 +424,7 @@ EOF;
$str = iconv($charset, 'UTF-8', $str); $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; return true;
} }
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
}
return isset($this->services[$id]) || array_key_exists($id, $this->services); 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->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('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('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() public function testEnterLeaveCurrentScope()

View File

@ -1,7 +1,7 @@
EventDispatcher Component 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. simple and effective way to make your projects truly extensible.
```php ```php

View File

@ -336,7 +336,7 @@ class Parser
$node = new Node\GetAttrNode($node, $arg, $arguments, $type); $node = new Node\GetAttrNode($node, $arg, $arguments, $type);
} elseif ('[' === $token->value) { } 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); 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() public function getSubPathData()
{ {
$tmpDir = sys_get_temp_dir().'/symfony2_finder'; $tmpDir = sys_get_temp_dir().'/symfony_finder';
return array( return array(
array( array(

View File

@ -18,7 +18,7 @@ abstract class RealIteratorTestCase extends IteratorTestCase
public static function setUpBeforeClass() 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( self::$files = array(
'.git/', '.git/',
@ -74,7 +74,7 @@ abstract class RealIteratorTestCase extends IteratorTestCase
* Without the call to setUpBeforeClass() property can be null. * Without the call to setUpBeforeClass() property can be null.
*/ */
if (!self::$tmpDir) { 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)) { if (is_array($files)) {

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
use Symfony\Component\HttpFoundation\Session\Session; 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. * session ID.
* *
* @see DefaultCsrfProvider * @see DefaultCsrfProvider

View File

@ -20,7 +20,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; 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> * @author Bernhard Schussek <bschussek@gmail.com>
*/ */

View File

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

View File

@ -726,7 +726,19 @@ class Request
*/ */
public function get($key, $default = null, $deep = false) 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; 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> * @author Drak <drak@zikula.org>
*/ */

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ HttpKernel Component
HttpKernel provides the building blocks to create flexible and fast HTTP-based HttpKernel provides the building blocks to create flexible and fast HTTP-based
frameworks. frameworks.
``HttpKernelInterface`` is the core interface of the Symfony2 full-stack ``HttpKernelInterface`` is the core interface of the Symfony full-stack
framework: framework:
```php ```php
@ -23,11 +23,11 @@ interface HttpKernelInterface
It takes a ``Request`` as an input and should return a ``Response`` as an 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 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. free.
Creating a framework based on the Symfony2 components is really easy. Here is Creating a framework based on the Symfony components is really easy. Here is
a very simple, but fully-featured framework based on the Symfony2 components: a very simple, but fully-featured framework based on the Symfony components:
```php ```php
$routes = new RouteCollection(); $routes = new RouteCollection();
@ -54,7 +54,7 @@ $kernel = new HttpKernel($dispatcher, $resolver);
$kernel->handle($request)->send(); $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. components.
Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side 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; 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\EventListener\DumpListener;
use Symfony\Component\HttpKernel\KernelEvents; 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; use Symfony\Component\VarDumper\VarDumper;
/** /**
@ -34,34 +35,23 @@ class DumpListenerTest extends \PHPUnit_Framework_TestCase
public function testConfigure() public function testConfigure()
{ {
$prevDumper = $this->getDumpHandler(); $prevDumper = VarDumper::setHandler('var_dump');
VarDumper::setHandler($prevDumper);
$container = new ContainerBuilder(); $cloner = new MockCloner();
$container->setDefinition('var_dumper.cloner', new Definition('Symfony\Component\HttpKernel\Tests\EventListener\MockCloner')); $dumper = new MockDumper();
$container->setDefinition('mock_dumper', new Definition('Symfony\Component\HttpKernel\Tests\EventListener\MockDumper'));
ob_start(); ob_start();
$exception = null; $exception = null;
$listener = new DumpListener($container, 'mock_dumper'); $listener = new DumpListener($cloner, $dumper);
try { try {
$listener->configure(); $listener->configure();
$lazyDumper = $this->getDumpHandler();
VarDumper::dump('foo'); VarDumper::dump('foo');
$loadedDumper = $this->getDumpHandler();
VarDumper::dump('bar'); VarDumper::dump('bar');
$this->assertSame('+foo-+bar-', ob_get_clean()); $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) { } catch (\Exception $exception) {
} }
@ -71,28 +61,22 @@ class DumpListenerTest extends \PHPUnit_Framework_TestCase
throw $exception; 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) 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 $ 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 bailout(<<<MESSAGE
Usage: php update-icu-component.php <path/to/icu/source> <path/to/icu/build> 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 If you downloaded the SVN repository before, you can pass the path to the
repository source in the first optional argument. repository source in the first optional argument.

View File

@ -51,7 +51,7 @@ class NativeSessionTokenStorageTest extends \PHPUnit_Framework_TestCase
public function testStoreTokenInClosedSessionWithExistingSessionId() 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.'); $this->markTestSkipped('This test requires PHP 5.4 or later.');
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
{ {
protected function setUp() 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'); $this->markTestSkipped('Not supported prior to PHP 5.3.9');
} }

View File

@ -21,7 +21,7 @@ class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest
{ {
protected function setUp() 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'); $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() public function testDefaultApiVersion()
{ {
if (version_compare(PHP_VERSION, '5.3.9', '<')) { if (PHP_VERSION_ID < 50309) {
// Old implementation on PHP < 5.3.9 // Old implementation on PHP < 5.3.9
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator()); $this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
} else { } else {
@ -135,7 +135,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testSetApiVersion24And25() 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'); $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( throw new InvalidArgumentException(sprintf(
'The Validator API that is compatible with both Symfony 2.4 '. '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. '. '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; $apiVersion = $this->apiVersion;
if (null === $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_4
: Validation::API_VERSION_2_5_BC; : Validation::API_VERSION_2_5_BC;
} }