Merge branch '2.7'

* 2.7: (55 commits)
  CS: fix some license headers
  CS: Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline
  Improve triggering of the deprecation error
  [SecurityBundle] Fix typos in LogoutUrlHelper
  [VarDumper] add caster for MongoCursor objects
  make it possible to dump inlined services to XML
  [VarDumper] Fixed notice when Exchange is mocked
  [Translation] keep old array structure of resourcesFiles to avoid BC.
  removed deprecated notices that make the tests fail
  use visited lookup with reference to gain performance
  [VarDumper] with-er interface for Cloner\Data
  Replace GET parameters when changed
  tweaked phpdocs
  [Process] Fix outdated Process->start() docblock
  prevent inlining service configurators
  Improve entropy of generated salt
  Complete the removal of API versions in the validator component
  [Validator] deprecated API version
  Removed 2.5 bc layer
  [SecurityBundle] UserPasswordEncoderCommand: fix help arguments order.
  ...

Conflicts:
	CHANGELOG-2.3.md
	CHANGELOG-2.6.md
	src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
	src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
	src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php
	src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php
	src/Symfony/Bundle/FrameworkBundle/composer.json
	src/Symfony/Bundle/SecurityBundle/composer.json
	src/Symfony/Component/Console/Helper/DialogHelper.php
	src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php
	src/Symfony/Component/Form/ResolvedFormType.php
	src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php
This commit is contained in:
Fabien Potencier 2015-03-24 18:09:17 +01:00
commit 9fe9832049
230 changed files with 2141 additions and 2260 deletions

6
.php_cs Normal file
View File

@ -0,0 +1,6 @@
<?php
return Symfony\CS\Config\Config::create()
->setUsingLinter(false)
->setUsingCache(true)
;

View File

@ -7,8 +7,8 @@ Symfony is the result of the work of many people who made the code better
- Fabien Potencier (fabpot)
- Bernhard Schussek (bschussek)
- Victor Berchet (victor)
- Jordi Boggiano (seldaek)
- Tobias Schultze (tobion)
- Jordi Boggiano (seldaek)
- Johannes S (johannes)
- Kris Wallsmith (kriswallsmith)
- Christophe Coevoet (stof)
@ -28,12 +28,12 @@ Symfony is the result of the work of many people who made the code better
- Igor Wiedler (igorw)
- Martin Hasoň (hason)
- Eriksen Costa (eriksencosta)
- Jonathan Wage (jwage)
- Grégoire Pineau (lyrixx)
- Jonathan Wage (jwage)
- Wouter De Jong (wouterj)
- Alexandre Salomé (alexandresalome)
- William Durand (couac)
- ornicar
- Wouter De Jong (wouterj)
- stealth35 (stealth35)
- Alexander Mols (asm89)
- Bulat Shakirzyanov (avalanche123)
@ -43,10 +43,11 @@ Symfony is the result of the work of many people who made the code better
- Miha Vrhovnik
- Konstantin Kudryashov (everzet)
- Bilal Amarni (bamarni)
- Kévin Dunglas (dunglas)
- Florin Patan (florinpatan)
- Abdellatif Ait Boudad (aitboudad)
- Eric Clemmons (ericclemmons)
- Sarah Khalil (saro0h)
- Eric Clemmons (ericclemmons)
- Andrej Hudec (pulzarraider)
- Deni
- Henrik Westphal (snc)
@ -63,27 +64,28 @@ Symfony is the result of the work of many people who made the code better
- John Wards (johnwards)
- Fran Moreno (franmomu)
- Antoine Hérault (herzult)
- Kevin Bond (kbond)
- Toni Uebernickel (havvg)
- Luis Cordova (cordoval)
- Arnaud Le Blanc (arnaud-lb)
- Kevin Bond (kbond)
- Tim Nagel (merk)
- Brice BERNARD (brikou)
- Kévin Dunglas (dunglas)
- marc.weistroff
- lenar
- Graham Campbell (graham)
- Włodzimierz Gajda (gajdaw)
- Florian Voutzinos (florianv)
- Colin Frei
- Jérôme Tamarelle (gromnan)
- Adrien Brault (adrienbrault)
- Gábor Egyed (1ed)
- excelwebzone
- Jacob Dreesen (jdreesen)
- Florian Voutzinos (florianv)
- Jérôme Tamarelle (gromnan)
- Adrien Brault (adrienbrault)
- Fabien Pennequin (fabienpennequin)
- Peter Kokot (maastermedia)
- Peter Rehm (rpet)
- Michal Piotrowski (eventhorizon)
- Stefano Sala (stefano.sala)
- Gordon Franke (gimler)
- Robert Schönthal (digitalkaoz)
- Juti Noppornpitak (shiroyuki)
@ -94,12 +96,12 @@ Symfony is the result of the work of many people who made the code better
- Jérémy DERUSSÉ (jderusse)
- Pablo Godel (pgodel)
- Eric GELOEN (gelo)
- Peter Rehm (rpet)
- Jérémie Augustin (jaugustin)
- Rafael Dohms (rdohms)
- Stefano Sala (stefano.sala)
- Guilherme Blanco (guilhermeblanco)
- Tigran Azatyan (tigranazatyan)
- Javier Eguiluz (javier.eguiluz)
- Arnaud Kleinpeter (nanocom)
- Richard Shank (iampersistent)
- Clemens Tolboom
- Helmer Aaviksoo
@ -110,13 +112,11 @@ Symfony is the result of the work of many people who made the code better
- Amal Raghav (kertz)
- Jonathan Ingram (jonathaningram)
- Artur Kotyrba
- Guilherme Blanco (guilhermeblanco)
- Rouven Weßling (realityking)
- Dmitrii Chekaliuk (lazyhammer)
- Clément JOBEILI (dator)
- Dorian Villet (gnutix)
- Richard Miller (mr_r_miller)
- Arnaud Kleinpeter (nanocom)
- hacfi (hifi)
- Mario A. Alvarez Garcia (nomack84)
- Dennis Benkert (denderello)
@ -147,10 +147,12 @@ Symfony is the result of the work of many people who made the code better
- Alexander Schwenn (xelaris)
- Lars Strojny (lstrojny)
- Rui Marinho (ruimarinho)
- Mikael Pajunen
- Julien Brochet (mewt)
- Tugdual Saunier (tucksaun)
- Sergey Linnik (linniksa)
- Marcel Beerta (mazen)
- Javier Spagnoletti (phansys)
- Francois Zaninotto
- Alexander Kotynia (olden)
- Daniel Tschinder
@ -182,6 +184,7 @@ Symfony is the result of the work of many people who made the code better
- julien pauli (jpauli)
- Beau Simensen (simensen)
- Robert Kiss (kepten)
- Ruben Gonzalez (rubenrua)
- Kim Hemsø Rasmussen (kimhemsoe)
- Florian Lonqueu-Brochard (florianlb)
- Tom Van Looy (tvlooy)
@ -199,11 +202,11 @@ Symfony is the result of the work of many people who made the code better
- Andrew Moore (finewolf)
- Bertrand Zuchuat (garfield-fr)
- Gabor Toth (tgabi333)
- Alex Pott
- realmfoo
- Thomas Tourlourat (armetiz)
- Andrey Esaulov (andremaha)
- Grégoire Passault (gregwar)
- Mikael Pajunen
- Uwe Jäger (uwej711)
- Aurelijus Valeiša (aurelijus)
- Jan Decavele (jandc)
@ -224,10 +227,12 @@ Symfony is the result of the work of many people who made the code better
- alquerci
- Francesco Levorato
- Vitaliy Zakharov (zakharovvi)
- Tobias Sjösten (tobiassjosten)
- Gyula Sallai (salla)
- Inal DJAFAR (inalgnu)
- Christian Gärtner (dagardner)
- Felix Labrecque
- Vladimir Reznichenko (kalessil)
- Yaroslav Kiliba
- Sébastien Lavoie (lavoiesl)
- Terje Bråten
@ -248,7 +253,6 @@ Symfony is the result of the work of many people who made the code better
- Loïc Chardonnet (gnusat)
- Marek Kalnik (marekkalnik)
- Vyacheslav Salakhutdinov (megazoll)
- Alex Pott
- Tamas Szijarto
- Pavel Volokitin (pvolok)
- Endre Fejes
@ -272,6 +276,7 @@ Symfony is the result of the work of many people who made the code better
- Christophe L. (christophelau)
- Anthon Pang (robocoder)
- Jáchym Toušek
- Thomas Schulz (king2500)
- Jannik Zschiesche (apfelbox)
- Emanuele Gaspari (inmarelibero)
- Dariusz Rumiński
@ -283,18 +288,17 @@ Symfony is the result of the work of many people who made the code better
- Jeanmonod David (jeanmonod)
- Jan Schumann
- Niklas Fiekas
- Ruben Gonzalez (rubenrua)
- lancergr
- Antonio J. García Lagar (ajgarlag)
- Olivier Dolbeau (odolbeau)
- Roumen Damianoff (roumen)
- Tobias Sjösten (tobiassjosten)
- Konstantin Myakshin (koc)
- vagrant
- Asier Illarramendi (doup)
- Alexander M. Turek (derrabus)
- Chris Sedlmayr (catchamonkey)
- Seb Koelen
- Daniel Wehner
- Christoph Mewes (xrstf)
- Vitaliy Tverdokhlib (vitaliytv)
- Ariel Ferrandini (aferrandini)
@ -302,9 +306,12 @@ Symfony is the result of the work of many people who made the code better
- Stepan Anchugov (kix)
- cedric lombardot (cedriclombardot)
- Jonas Flodén (flojon)
- Christian Schmidt
- Marcin Sikoń (marphi)
- franek (franek)
- Dariusz Ruminski
- Adam Harvey
- Diego Saint Esteben (dii3g0)
- Alex Bakhturin
- François-Xavier de Guillebon (de-gui_f)
- boombatower
@ -331,6 +338,7 @@ Symfony is the result of the work of many people who made the code better
- Vicent Soria Durá (vicentgodella)
- Ioan Negulescu
- Jakub Škvára (jskvara)
- Daniel Beyer
- Andrew Udvare (audvare)
- alexpods
- Erik Trapman (eriktrapman)
@ -342,7 +350,6 @@ Symfony is the result of the work of many people who made the code better
- Nils Adermann (naderman)
- Gábor Fási
- Benjamin Leveque (benji07)
- Javier Spagnoletti (phansys)
- sasezaki
- Dawid Pakuła (zulusx)
- Florian Rey (nervo)
@ -357,6 +364,7 @@ Symfony is the result of the work of many people who made the code better
- Massimiliano Arione (garak)
- Ivan Rey (ivanrey)
- Marcin Chyłek (songoq)
- Vadim Kharitonov (virtuozzz)
- Ned Schwartz
- Ziumin
- Lenar Lõhmus
@ -398,7 +406,6 @@ Symfony is the result of the work of many people who made the code better
- Rostyslav Kinash
- Daisuke Ohata
- Vincent Simonin
- Christian Schmidt
- Stefan Warman
- Tristan Maindron (tmaindron)
- Ke WANG (yktd26)
@ -409,18 +416,22 @@ Symfony is the result of the work of many people who made the code better
- umpirski
- Chris Heng (gigablah)
- Ulumuddin Yunus (joenoez)
- Dominik Zogg (dominik.zogg)
- Luc Vieillescazes (iamluc)
- Johann Saunier (prophet777)
- Antoine Corcy
- Artur Eshenbrener
- Arturs Vonda
- Sascha Grossenbacher
- Szijarto Tamas
- Benjamin Zikarsky (bzikarsky)
- Ben Davies (bendavies)
- Mickaël Andrieu (mickaelandrieu)
- Simon Schick (simonsimcity)
- redstar504
- Hossein Bukhamsin
- Paweł Wacławczyk (pwc)
- Oleg Zinchenko (cystbear)
- Diego Saint Esteben (dii3g0)
- Johannes Klauss (cloppy)
- Evan Villemez
- fzerorubigd
@ -432,6 +443,7 @@ Symfony is the result of the work of many people who made the code better
- Vincent AUBERT (vincent)
- Tomasz Kowalczyk (thunderer)
- Mark Sonnabaum
- Alexander Obuhovich (aik099)
- Mathieu Lemoine
- jochenvdv
- Filippo Tessarotto
@ -446,6 +458,7 @@ Symfony is the result of the work of many people who made the code better
- Yuen-Chi Lian
- Besnik Br
- Joshua Nye
- Dave Marshall (davedevelopment)
- avorobiev
- Venu
- Lars Vierbergen
@ -456,7 +469,6 @@ Symfony is the result of the work of many people who made the code better
- 1emming
- Leevi Graham (leevigraham)
- Casper Valdemar Poulsen
- Daniel Wehner
- Josiah (josiah)
- Marek Štípek (maryo)
- John Bohn (jbohn)
@ -464,7 +476,6 @@ Symfony is the result of the work of many people who made the code better
- Andrew Hilobok (hilobok)
- Christian Soronellas (theunic)
- Yosmany Garcia (yosmanyga)
- Daniel Beyer
- Jérôme Vieilledent (lolautruche)
- Degory Valentine
- Benoit Lévêque (benoit_leveque)
@ -533,6 +544,7 @@ Symfony is the result of the work of many people who made the code better
- Jacques Moati
- Balazs Csaba (balazscsaba2006)
- Harry Walter (haswalt)
- Johnson Page (jwpage)
- Michael Roterman (wtfzdotnet)
- Arno Geurts
- Adán Lobato (adanlobato)
@ -540,6 +552,7 @@ Symfony is the result of the work of many people who made the code better
- Maks
- Gábor Tóth
- Daniel Cestari
- Johnny Robeson (johnny)
- Brunet Laurent (lbrunet)
- Magnus Nordlander (magnusnordlander)
- Mikhail Yurasov (mym)
@ -620,7 +633,6 @@ Symfony is the result of the work of many people who made the code better
- Benjamin Paap (benjaminpaap)
- Christian
- Sergii Smertin (nfx)
- Artur Eshenbrener
- Bailey Parker
- Eddie Jaoude
- Haritz Iturbe (hizai)
@ -640,11 +652,13 @@ Symfony is the result of the work of many people who made the code better
- Julien Bianchi (jubianchi)
- Marcin Chwedziak
- Roland Franssen (ro0)
- Tony Cosentino (tony-co)
- Maciej Malarz
- Rodrigo Díez Villamuera (rodrigodiez)
- e-ivanov
- Jochen Bayer (jocl)
- Jeremy Bush
- wizhippo
- rpg600
- Péter Buri (burci)
- Davide Borsatto (davide.borsatto)
@ -659,8 +673,8 @@ Symfony is the result of the work of many people who made the code better
- Artem Kolesnikov (tyomo4ka)
- Gustavo Adrian
- Yannick
- Luc Vieillescazes (iamluc)
- Eduardo García Sanz (coma)
- Sebastian Grodzicki (sgrodzicki)
- Roy Van Ginneken
- David de Boer (ddeboer)
- Gilles Doge (gido)
@ -709,8 +723,10 @@ Symfony is the result of the work of many people who made the code better
- Cédric Girard (enk_)
- Oriol Mangas Abellan (oriolman)
- Sebastian Göttschkes (sgoettschkes)
- Tatsuya Tsuruoka
- Ross Tuck
- Kévin Gomez (kevin)
- Dawid Sajdak
- Ludek Stepan
- Geoffrey Brier
- Aaron Stephens (astephens)
@ -728,7 +744,6 @@ Symfony is the result of the work of many people who made the code better
- steveYeah
- Samy Dindane (dinduks)
- Keri Henare (kerihenare)
- Mickaël Andrieu (mickaelandrieu)
- Cédric Lahouste (rapotor)
- Samuel Vogel (samuelvogel)
- Berat Doğan
@ -741,6 +756,7 @@ Symfony is the result of the work of many people who made the code better
- Ilya Biryukov
- Jason Desrosiers
- m.chwedziak
- Philip Frank
- Lance McNearney
- Frank Neff (fneff)
- Giorgio Premi
@ -750,6 +766,7 @@ Symfony is the result of the work of many people who made the code better
- Pete Mitchell (peterjmit)
- Tom Corrigan (tomcorrigan)
- Martin Pärtel
- Miroslav Sustek
- Evgeniy (ewgraf)
- Patrick Daley (padrig)
- Xavier Briand (xavierbriand)
@ -825,8 +842,8 @@ Symfony is the result of the work of many people who made the code better
- wusuopu
- povilas
- Diego Agulló
- Alexander Obuhovich
- Alessandro Tagliapietra (alex88)
- Biji (biji)
- Gunnar Lium (gunnarlium)
- Tiago Garcia (tiagojsag)
- Artiom
@ -837,7 +854,9 @@ Symfony is the result of the work of many people who made the code better
- Adrian Olek (adrianolek)
- Przemysław Piechota (kibao)
- Leonid Terentyev (li0n)
- Oskar Stark (oskarstark)
- Adam Prager (padam87)
- ryunosuke
- victoria
- Francisco Facioni (fran6co)
- Iwan van Staveren (istaveren)
@ -856,6 +875,7 @@ Symfony is the result of the work of many people who made the code better
- Paul Seiffert (seiffert)
- Vasily Khayrulin (sirian)
- Stefan Koopmanschap (skoop)
- Stefan Hüsges (tronsha)
- Ivan Kurnosov
- stloyd
- Chris Tickner
@ -885,7 +905,6 @@ Symfony is the result of the work of many people who made the code better
- Julius Beckmann
- Romain Dorgueil
- Grayson Koonce (breerly)
- Benjamin Zikarsky (bzikarsky)
- Matt Robinson (inanimatt)
- Karim Cassam Chenaï (ka)
- Nicolas Bastien (nicolas_bastien)
@ -900,7 +919,6 @@ Symfony is the result of the work of many people who made the code better
- Chris
- efeen
- Michał Dąbrowski (defrag)
- Dominik Zogg (dominik.zogg)
- Simone Fumagalli (hpatoio)
- Kevin Vergauwen (innocenzo)
- Alessio Baglio (ioalessio)
@ -911,6 +929,7 @@ Symfony is the result of the work of many people who made the code better
- Milos Colakovic (project2481)
- Rénald Casagraude (rcasagraude)
- Robin Duval (robin-duval)
- Grinbergs Reinis (shima5)
- Artem Lopata (bumz)
- Alexey Popkov
- Artyom Protaskin
@ -920,6 +939,7 @@ Symfony is the result of the work of many people who made the code better
- Bram Van der Sype (brammm)
- Julien Moulin (lizjulien)
- Nikita Nefedov (nikita2206)
- Mauro Foti (skler)
- Yannick Warnier (ywarnier)
- Kevin Decherf
- Jason Woods
@ -940,6 +960,7 @@ Symfony is the result of the work of many people who made the code better
- bertillon
- Luca Genuzio (genuzio)
- Hans Nilsson (hansnilsson)
- Andrew Marcinkevičius (ifdattic)
- Ioana Hazsda (ioana-hazsda)
- Jan Marek (janmarek)
- Mark de Haan (markdehaan)
@ -948,6 +969,7 @@ Symfony is the result of the work of many people who made the code better
- Sofiane HADDAG (sofhad)
- tante kinast (tante)
- Vincent LEFORT (vlefort)
- Sadicov Vladimir (xtech)
- Alexander Zogheb
- Joel Marcey
- David Christmann
@ -999,6 +1021,7 @@ Symfony is the result of the work of many people who made the code better
- Alex
- Klaas Naaijkens
- Daniel González Cerviño
- possum
- Rafał
- Adria Lopez (adlpz)
- Rosio (ben-rosio)
@ -1007,12 +1030,12 @@ Symfony is the result of the work of many people who made the code better
- Masao Maeda (brtriver)
- Darius Leskauskas (darles)
- Dave Hulbert (dave1010)
- Dave Marshall (davedevelopment)
- David Joos (djoos)
- Denis Klementjev (dklementjev)
- Tomáš Polívka (draczris)
- Vincent Composieux (eko)
- Franz Liedke (franzliedke)
- Christophe BECKER (goabonga)
- gondo (gondo)
- Gusakov Nikita (hell0w0rd)
- Osman Üngür (import)
@ -1027,10 +1050,10 @@ Symfony is the result of the work of many people who made the code better
- Michael Pohlers (mick_the_big)
- Mantas Var (mvar)
- Cayetano Soriano Gallego (neoshadybeat)
- Maxime Steinhausser (ogizanagi)
- Pablo Monterde Perez (plebs)
- Jimmy Leger (redpanda)
- Cyrille Jouineau (tuxosaurus)
- Vadim Kharitonov (virtuozzz)
- Yorkie Chadwick (yorkie76)
- Yanick Witschi
- Ondrej Mirtes
@ -1053,6 +1076,7 @@ Symfony is the result of the work of many people who made the code better
- Simon CONSTANS (kosssi)
- Kristof Van Cauwenbergh (kristofvc)
- Ramon Henrique Ornelas (ramonornela)
- Markus S. (staabm)
- Till Klampaeckel (till)
- Tobias Weinert (tweini)
- Ulf Reimers (ureimers)
@ -1060,8 +1084,10 @@ Symfony is the result of the work of many people who made the code better
- goohib
- Xavier HAUSHERR
- Cas
- Dusan Kasan
- Myke79
- Brian Debuire
- Piers Warmers
- Sylvain Lorinet
- klyk50
- Andreas Lutro
@ -1078,6 +1104,7 @@ Symfony is the result of the work of many people who made the code better
- Johannes
- Jörg Rühl
- wesleyh
- sergey
- Michael Genereux
- patrick-mcdougle
- Dariusz Czech
@ -1088,11 +1115,11 @@ Symfony is the result of the work of many people who made the code better
- Steve Müller
- Andras Ratz
- andreabreu98
- Thomas Schulz
- Michael Schneider
- n-aleha
- Kaipi Yann
- Sam Williams
- Adrian Philipp
- James Michael DuPont
- Tammy D
- Ondrej Slinták
@ -1101,6 +1128,7 @@ Symfony is the result of the work of many people who made the code better
- Brian Freytag
- Skorney
- mieszko4
- Arrilot
- Markus Staab
- Pierre-Louis LAUNAY
- djama
@ -1120,6 +1148,7 @@ Symfony is the result of the work of many people who made the code better
- dinitrol
- Penny Leach
- g123456789l
- Giorgio Premi
- oscartv
- DanSync
- Peter Zwosta
@ -1130,6 +1159,7 @@ Symfony is the result of the work of many people who made the code better
- Karolis Daužickas
- tirnanog06
- phc
- Дмитрий Пацура
- ilyes kooli
- Matthias Althaus
- Michaël VEROUX
@ -1168,7 +1198,6 @@ Symfony is the result of the work of many people who made the code better
- Jorge Maiden (jorgemaiden)
- Justin Rainbow (jrainbow)
- JuntaTom (juntatom)
- Johnson Page (jwpage)
- Ismail Faizi (kanafghan)
- Sébastien Armand (khepin)
- Krzysztof Menżyk (krymen)
@ -1190,6 +1219,7 @@ Symfony is the result of the work of many people who made the code better
- Daniel Perez Pinazo (pitiflautico)
- Rich Sage (richsage)
- Ruud Kamphuis (ruudk)
- Bart Ruysseveldt (ruyss)
- scourgen hung (scourgen)
- Sebastian Busch (sebu)
- André Filipe Gonçalves Neves (seven)

View File

@ -218,10 +218,8 @@ class EntityChoiceList extends ObjectChoiceList
if (!$this->loaded) {
// Optimize performance in case we have an entity loader and
// a single-field identifier
if ($this->idAsValue) {
$unorderedEntities = $this->entityLoader
? $this->entityLoader->getEntitiesByIds($this->idField, $values)
: $this->em->getRepository($this->class)->findBy(array($this->idField => $values));
if ($this->idAsValue && $this->entityLoader) {
$unorderedEntities = $this->entityLoader->getEntitiesByIds($this->idField, $values);
$entitiesByValue = array();
$entities = array();

View File

@ -65,9 +65,11 @@ abstract class DoctrineType extends AbstractType
$propertyAccessor = $this->propertyAccessor;
$loader = function (Options $options) {
if (null !== $options['query_builder']) {
return $this->getLoader($options['em'], $options['query_builder'], $options['class']);
}
$queryBuilder = (null !== $options['query_builder'])
? $options['query_builder']
: $options['em']->getRepository($options['class'])->createQueryBuilder('e');
return $this->getLoader($options['em'], $queryBuilder, $options['class']);
};
$choiceList = function (Options $options) use (&$choiceListCache, $propertyAccessor) {

View File

@ -85,10 +85,10 @@ class EntityUserProvider implements UserProviderInterface
// That's the case when the user has been changed by a form with
// validation errors.
if (!$id = $this->metadata->getIdentifierValues($user)) {
throw new \InvalidArgumentException("You cannot refresh a user ".
"from the EntityUserProvider that does not contain an identifier. ".
"The user object has to be serialized with its own identifier ".
"mapped by Doctrine."
throw new \InvalidArgumentException('You cannot refresh a user '.
'from the EntityUserProvider that does not contain an identifier. '.
'The user object has to be serialized with its own identifier '.
'mapped by Doctrine.'
);
}

View File

@ -39,7 +39,7 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(0, $c->getQueryCount());
$queries = array(
array('sql' => "SELECT * FROM table1", 'params' => array(), 'types' => array(), 'executionMS' => 0),
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 0),
);
$c = $this->createCollector($queries);
$c->collect(new Request(), new Response());
@ -53,15 +53,15 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(0, $c->getTime());
$queries = array(
array('sql' => "SELECT * FROM table1", 'params' => array(), 'types' => array(), 'executionMS' => 1),
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1),
);
$c = $this->createCollector($queries);
$c->collect(new Request(), new Response());
$this->assertEquals(1, $c->getTime());
$queries = array(
array('sql' => "SELECT * FROM table1", 'params' => array(), 'types' => array(), 'executionMS' => 1),
array('sql' => "SELECT * FROM table2", 'params' => array(), 'types' => array(), 'executionMS' => 2),
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1),
array('sql' => 'SELECT * FROM table2', 'params' => array(), 'types' => array(), 'executionMS' => 2),
);
$c = $this->createCollector($queries);
$c->collect(new Request(), new Response());
@ -74,7 +74,7 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
public function testCollectQueries($param, $types, $expected, $explainable)
{
$queries = array(
array('sql' => "SELECT * FROM table1 WHERE field1 = ?1", 'params' => array($param), 'types' => $types, 'executionMS' => 1),
array('sql' => 'SELECT * FROM table1 WHERE field1 = ?1', 'params' => array($param), 'types' => $types, 'executionMS' => 1),
);
$c = $this->createCollector($queries);
$c->collect(new Request(), new Response());
@ -90,7 +90,7 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
public function testSerialization($param, $types, $expected, $explainable)
{
$queries = array(
array('sql' => "SELECT * FROM table1 WHERE field1 = ?1", 'params' => array($param), 'types' => $types, 'executionMS' => 1),
array('sql' => 'SELECT * FROM table1 WHERE field1 = ?1', 'params' => array($param), 'types' => $types, 'executionMS' => 1),
);
$c = $this->createCollector($queries);
$c->collect(new Request(), new Response());

View File

@ -250,11 +250,11 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
'message' => 'myMessage',
'fields' => array('name', 'name2'),
'em' => self::EM_NAME,
'errorPath' => "name2",
'errorPath' => 'name2',
));
$entity1 = new DoubleNameEntity(1, 'Foo', "Bar");
$entity2 = new DoubleNameEntity(2, 'Foo', "Bar");
$entity1 = new DoubleNameEntity(1, 'Foo', 'Bar');
$entity2 = new DoubleNameEntity(2, 'Foo', 'Bar');
$this->validator->validate($entity1, $constraint);
@ -405,7 +405,7 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
'em' => self::EM_NAME,
));
$composite = new CompositeIntIdEntity(1, 1, "test");
$composite = new CompositeIntIdEntity(1, 1, 'test');
$associated = new AssociationEntity();
$associated->composite = $composite;

View File

@ -103,8 +103,8 @@ class UniqueEntityValidator extends ConstraintValidator
if (count($relatedId) > 1) {
throw new ConstraintDefinitionException(
"Associated entities are not allowed to have more than one identifier field to be ".
"part of a unique constraint in: ".$class->getName()."#".$fieldName
'Associated entities are not allowed to have more than one identifier field to be '.
'part of a unique constraint in: '.$class->getName().'#'.$fieldName
);
}
$criteria[$fieldName] = array_pop($relatedId);

View File

@ -65,7 +65,7 @@ class CodeExtension extends \Twig_Extension
{
if (false !== strpos($method, '::')) {
list($class, $method) = explode('::', $method, 2);
$result = sprintf("%s::%s()", $this->abbrClass($class), $method);
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
} elseif ('Closure' === $method) {
$result = sprintf("<abbr title=\"%s\">%s</abbr>", $method, $method);
} else {
@ -91,7 +91,7 @@ class CodeExtension extends \Twig_Extension
$short = array_pop($parts);
$formattedValue = sprintf("<em>object</em>(<abbr title=\"%s\">%s</abbr>)", $item[1], $short);
} elseif ('array' === $item[0]) {
$formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
$formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
} elseif ('string' === $item[0]) {
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->charset));
} elseif ('null' === $item[0]) {

View File

@ -101,6 +101,6 @@ class SearchAndRenderBlockNode extends \Twig_Node_Expression_Function
}
}
$compiler->raw(")");
$compiler->raw(')');
}
}

View File

@ -29,6 +29,7 @@ class Client extends BaseClient
{
private $hasPerformedRequest = false;
private $profiler = false;
private $reboot = true;
/**
* {@inheritdoc}
@ -84,6 +85,25 @@ class Client extends BaseClient
}
}
/**
* Disables kernel reboot between requests.
*
* By default, the Client reboots the Kernel for each request. This method
* allows to keep the same kernel across requests.
*/
public function disableReboot()
{
$this->reboot = false;
}
/**
* Enables kernel reboot between requests.
*/
public function enableReboot()
{
$this->reboot = true;
}
/**
* {@inheritdoc}
*
@ -95,7 +115,7 @@ class Client extends BaseClient
{
// avoid shutting down the Kernel if no request has been performed yet
// WebTestCase::createClient() boots the Kernel but do not handle a request
if ($this->hasPerformedRequest) {
if ($this->hasPerformedRequest && $this->reboot) {
$this->kernel->shutdown();
} else {
$this->hasPerformedRequest = true;

View File

@ -14,8 +14,6 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
* A console command for dumping available configuration reference.
@ -43,36 +41,23 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
protected function findExtension($name)
{
$extension = null;
$bundles = $this->initializeBundles();
foreach ($bundles as $bundle) {
$extension = $bundle->getContainerExtension();
$bundles = $this->getContainer()->get('kernel')->getBundles();
if (preg_match('/Bundle$/', $name)) {
// input is bundle name
if (isset($bundles[$name])) {
$extension = $bundles[$name]->getContainerExtension();
}
if (!$extension) {
throw new \LogicException(sprintf('No extensions with configuration available for "%s"', $name));
}
} else {
foreach ($bundles as $bundle) {
$extension = $bundle->getContainerExtension();
if ($extension && $name === $extension->getAlias()) {
break;
}
$extension = null;
}
if (!$extension) {
throw new \LogicException(sprintf('No extension with alias "%s" is enabled', $name));
if ($extension && ($name === $extension->getAlias() || $name === $bundle->getName())) {
break;
}
}
$this->initializeExtensions($bundles);
if (!$extension) {
$message = sprintf('No extension with alias "%s" is enabled', $name);
if (preg_match('/Bundle$/', $name)) {
$message = sprintf('No extensions with configuration available for "%s"', $name);
}
throw new \LogicException($message);
}
return $extension;
}
@ -88,12 +73,12 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
}
}
private function initializeExtensions($bundles)
private function initializeBundles()
{
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
// as this method is not called when the container is loaded from the cache.
$parameters = $this->getContainer()->getParameterBag()->all();
$container = new ContainerBuilder(new ParameterBag($parameters));
$container = $this->getContainerBuilder();
$bundles = $this->getContainer()->get('kernel')->registerBundles();
foreach ($bundles as $bundle) {
if ($extension = $bundle->getContainerExtension()) {
$container->registerExtension($extension);
@ -101,8 +86,9 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
}
foreach ($bundles as $bundle) {
$bundle = clone $bundle;
$bundle->build($container);
}
return $bundles;
}
}

View File

@ -70,11 +70,7 @@ EOF
}
$extension = $this->findExtension($name);
$kernel = $this->getContainer()->get('kernel');
$method = new \ReflectionMethod($kernel, 'buildContainer');
$method->setAccessible(true);
$container = $method->invoke($kernel);
$container = $this->compileContainer();
$configs = $container->getExtensionConfig($extension->getAlias());
$configuration = $extension->getConfiguration($configs, $container);
@ -94,4 +90,17 @@ EOF
$output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
}
private function compileContainer()
{
$kernel = clone $this->getContainer()->get('kernel');
$kernel->boot();
$method = new \ReflectionMethod($kernel, 'buildContainer');
$method->setAccessible(true);
$container = $method->invoke($kernel);
$container->getCompiler()->compile($container);
return $container;
}
}

View File

@ -166,6 +166,10 @@ EOF
*/
protected function getContainerBuilder()
{
if ($this->containerBuilder) {
return $this->containerBuilder;
}
if (!$this->getApplication()->getKernel()->isDebug()) {
throw new \LogicException(sprintf('Debug information about the container is only available in debug mode.'));
}
@ -179,7 +183,7 @@ EOF
$loader = new XmlFileLoader($container, new FileLocator());
$loader->load($cachedFile);
return $container;
return $this->containerBuilder = $container;
}
private function findProperServiceName(InputInterface $input, OutputInterface $output, ContainerBuilder $builder, $name)

View File

@ -471,6 +471,7 @@ class Configuration implements ConfigurationInterface
->scalarNode('translation_domain')->defaultValue('validators')->end()
->booleanNode('strict_email')->defaultFalse()->end()
->enumNode('api')
->info('Deprecated since version 2.7, to be removed in 3.0')
->values(array('2.4', '2.5', '2.5-bc', 'auto'))
->beforeNormalization()
// XML/YAML parse as numbers, not as strings
@ -481,19 +482,6 @@ class Configuration implements ConfigurationInterface
->end()
->end()
->end()
->validate()
->ifTrue(function ($v) { return !isset($v['validation']['api']) || 'auto' === $v['validation']['api']; })
->then(function ($v) {
// This condition is duplicated in ValidatorBuilder. This
// duplication is necessary in order to know the desired
// API version already during container configuration
// (to adjust service classes etc.)
// See https://github.com/symfony/symfony/issues/11580
$v['validation']['api'] = '2.5-bc';
return $v;
})
->end()
;
}
@ -521,6 +509,10 @@ class Configuration implements ConfigurationInterface
->arrayNode('serializer')
->info('serializer configuration')
->canBeEnabled()
->children()
->booleanNode('enable_annotations')->defaultFalse()->end()
->scalarNode('cache')->end()
->end()
->end()
->end()
;

View File

@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Reference;
@ -29,6 +30,7 @@ use Symfony\Component\Validator\Validation;
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jeremy Mikola <jmikola@gmail.com>
* @author Kévin Dunglas <dunglas@gmail.com>
*/
class FrameworkExtension extends Extension
{
@ -122,11 +124,10 @@ class FrameworkExtension extends Extension
}
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
$this->registerPropertyAccessConfiguration($config['property_access'], $container);
if (isset($config['serializer']) && $config['serializer']['enabled']) {
$loader->load('serializer.xml');
if (isset($config['serializer'])) {
$this->registerSerializerConfiguration($config['serializer'], $container, $loader);
}
$loader->load('debug_prod.xml');
@ -699,11 +700,7 @@ class FrameworkExtension extends Extension
foreach ($finder as $file) {
list($domain, $locale, $format) = explode('.', $file->getBasename(), 3);
if (!isset($files[$locale])) {
$files[$locale] = array();
}
$files[$locale][] = (string) $file;
$files[] = (string) $file;
}
$translator->replaceArgument(4, $files);
@ -760,20 +757,11 @@ class FrameworkExtension extends Extension
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache'])));
}
if ('2.5' === $config['api']) {
$api = Validation::API_VERSION_2_5;
} else {
// 2.4 is now the same as 2.5 BC
$api = Validation::API_VERSION_2_5_BC;
// the validation class needs to be changed for BC
$container->setParameter('validator.class', 'Symfony\Component\Validator\ValidatorInterface');
}
$validatorBuilder->addMethodCall('setApiVersion', array($api));
// You can use this parameter to check the API version in your own
// bundle extension classes
$container->setParameter('validator.api', $api);
// This is set to 2.5-bc for compatibility with Symfony 2.5 and 2.6.
// @deprecated since version 2.7, to be removed in 3.0
$container->setParameter('validator.api', '2.5-bc');
}
private function getValidatorMappingFiles(ContainerBuilder $container)
@ -874,6 +862,86 @@ class FrameworkExtension extends Extension
$loader->load('security_csrf.xml');
}
/**
* Loads the serializer configuration.
*
* @param array $config A serializer configuration array
* @param ContainerBuilder $container A ContainerBuilder instance
* @param XmlFileLoader $loader An XmlFileLoader instance
*/
private function registerSerializerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
if (!$config['enabled']) {
return;
}
$loader->load('serializer.xml');
$chainLoader = $container->getDefinition('serializer.mapping.chain_loader');
$serializerLoaders = array();
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
$annotationLoader = new Definition(
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
array(new Reference('annotation_reader'))
);
$annotationLoader->setPublic(false);
$serializerLoaders[] = $annotationLoader;
}
$bundles = $container->getParameter('kernel.bundles');
foreach ($bundles as $bundle) {
$reflection = new \ReflectionClass($bundle);
$dirname = dirname($reflection->getFilename());
if (is_file($file = $dirname.'/Resources/config/serialization.xml')) {
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array(realpath($file)));
$definition->setPublic(false);
$serializerLoaders[] = $definition;
$container->addResource(new FileResource($file));
}
if (is_file($file = $dirname.'/Resources/config/serialization.yml')) {
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array(realpath($file)));
$definition->setPublic(false);
$serializerLoaders[] = $definition;
$container->addResource(new FileResource($file));
}
if (is_dir($dir = $dirname.'/Resources/config/serialization')) {
foreach (Finder::create()->files()->in($dir)->name('*.xml') as $file) {
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file->getRealpath()));
$definition->setPublic(false);
$serializerLoaders[] = $definition;
}
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file->getRealpath()));
$definition->setPublic(false);
$serializerLoaders[] = $definition;
}
$container->addResource(new DirectoryResource($dir));
}
}
$chainLoader->replaceArgument(0, $serializerLoaders);
if (isset($config['cache']) && $config['cache']) {
$container->setParameter(
'serializer.mapping.cache.prefix',
'serializer_'.hash('sha256', $container->getParameter('kernel.root_dir'))
);
$container->getDefinition('serializer.mapping.class_metadata_factory')->replaceArgument(
1, new Reference($config['cache'])
);
}
}
/**
* Returns the base path for the XSD files.
*

View File

@ -32,6 +32,7 @@
<xsd:element name="validation" type="validation" minOccurs="0" maxOccurs="1" />
<xsd:element name="annotations" type="annotations" minOccurs="0" maxOccurs="1" />
<xsd:element name="property-access" type="property_access" minOccurs="0" maxOccurs="1" />
<xsd:element name="serializer" type="serializer" minOccurs="0" maxOccurs="1" />
</xsd:all>
<xsd:attribute name="http-method-override" type="xsd:boolean" />
@ -196,4 +197,10 @@
<xsd:attribute name="magic-call" type="xsd:boolean" />
<xsd:attribute name="throw-exception-on-invalid-index" type="xsd:boolean" />
</xsd:complexType>
<xsd:complexType name="serializer">
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="cache" type="xsd:string" />
<xsd:attribute name="enable-annotations" type="xsd:boolean" />
</xsd:complexType>
</xsd:schema>

View File

@ -8,25 +8,47 @@
<parameter key="serializer.class">Symfony\Component\Serializer\Serializer</parameter>
<parameter key="serializer.encoder.xml.class">Symfony\Component\Serializer\Encoder\XmlEncoder</parameter>
<parameter key="serializer.encoder.json.class">Symfony\Component\Serializer\Encoder\JsonEncoder</parameter>
<parameter key="serializer.mapping.cache.prefix" />
</parameters>
<services>
<service id="serializer" class="%serializer.class%" >
<service id="serializer" class="%serializer.class%">
<argument type="collection" />
<argument type="collection" />
</service>
<!-- Normalizer -->
<service id="serializer.normalizer.get_set_method" class="Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer" public="false">
<service id="serializer.normalizer.object" class="Symfony\Component\Serializer\Normalizer\ObjectNormalizer" public="false">
<argument type="service" id="serializer.mapping.class_metadata_factory" />
<!-- Run after all custom serializers -->
<tag name="serializer.normalizer" priority="-1000" />
</service>
<!-- Loader -->
<service id="serializer.mapping.chain_loader" class="Symfony\Component\Serializer\Mapping\Loader\LoaderChain" public="false">
<argument type="collection" />
</service>
<!-- Class Metadata Factory -->
<service id="serializer.mapping.class_metadata_factory" class="Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory" public="false">
<argument type="service" id="serializer.mapping.chain_loader" />
<argument>null</argument>
</service>
<!-- Cache -->
<service id="serializer.mapping.cache.apc" class="Doctrine\Common\Cache\ApcCache" public="false">
<call method="setNamespace">
<argument>%serializer.mapping.cache.prefix%</argument>
</call>
</service>
<!-- Encoders -->
<service id="serializer.encoder.xml" class="%serializer.encoder.xml.class%" public="false" >
<service id="serializer.encoder.xml" class="%serializer.encoder.xml.class%" public="false">
<tag name="serializer.encoder" />
</service>
<service id="serializer.encoder.json" class="%serializer.encoder.json.class%" public="false" >
<service id="serializer.encoder.json" class="%serializer.encoder.json.class%" public="false">
<tag name="serializer.encoder" />
</service>
</services>

View File

@ -62,7 +62,7 @@ class CodeHelper extends Helper
{
if (false !== strpos($method, '::')) {
list($class, $method) = explode('::', $method, 2);
$result = sprintf("%s::%s()", $this->abbrClass($class), $method);
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
} elseif ('Closure' === $method) {
$result = sprintf("<abbr title=\"%s\">%s</abbr>", $method, $method);
} else {
@ -88,7 +88,7 @@ class CodeHelper extends Helper
$short = array_pop($parts);
$formattedValue = sprintf("<em>object</em>(<abbr title=\"%s\">%s</abbr>)", $item[1], $short);
} elseif ('array' === $item[0]) {
$formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
$formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
} elseif ('string' === $item[0]) {
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
} elseif ('null' === $item[0]) {

View File

@ -0,0 +1,65 @@
<?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\FrameworkBundle\Tests;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
class ClientTest extends WebTestCase
{
public function testRebootKernelBetweenRequests()
{
$mock = $this->getKernelMock();
$mock->expects($this->once())->method('shutdown');
$client = new Client($mock);
$client->request('GET', '/');
$client->request('GET', '/');
}
public function testDisabledRebootKernel()
{
$mock = $this->getKernelMock();
$mock->expects($this->never())->method('shutdown');
$client = new Client($mock);
$client->disableReboot();
$client->request('GET', '/');
$client->request('GET', '/');
}
public function testEnableRebootKernel()
{
$mock = $this->getKernelMock();
$mock->expects($this->once())->method('shutdown');
$client = new Client($mock);
$client->disableReboot();
$client->request('GET', '/');
$client->request('GET', '/');
$client->enableReboot();
$client->request('GET', '/');
}
private function getKernelMock()
{
$mock = $this->getMockBuilder($this->getKernelClass())
->setMethods(array('shutdown', 'boot', 'handle'))
->disableOriginalConstructor()
->getMock();
$mock->expects($this->any())->method('handle')->willReturn(new Response('foo'));
return $mock;
}
}

View File

@ -155,30 +155,30 @@ class RedirectControllerTest extends TestCase
{
return array(
// Standard ports
array('http', null, null, 'http', 80, ""),
array('http', 80, null, 'http', 80, ""),
array('https', null, null, 'http', 80, ""),
array('https', 80, null, 'http', 80, ""),
array('http', null, null, 'http', 80, ''),
array('http', 80, null, 'http', 80, ''),
array('https', null, null, 'http', 80, ''),
array('https', 80, null, 'http', 80, ''),
array('http', null, null, 'https', 443, ""),
array('http', null, 443, 'https', 443, ""),
array('https', null, null, 'https', 443, ""),
array('https', null, 443, 'https', 443, ""),
array('http', null, null, 'https', 443, ''),
array('http', null, 443, 'https', 443, ''),
array('https', null, null, 'https', 443, ''),
array('https', null, 443, 'https', 443, ''),
// Non-standard ports
array('http', null, null, 'http', 8080, ":8080"),
array('http', 4080, null, 'http', 8080, ":4080"),
array('http', 80, null, 'http', 8080, ""),
array('https', null, null, 'http', 8080, ""),
array('https', null, 8443, 'http', 8080, ":8443"),
array('https', null, 443, 'http', 8080, ""),
array('http', null, null, 'http', 8080, ':8080'),
array('http', 4080, null, 'http', 8080, ':4080'),
array('http', 80, null, 'http', 8080, ''),
array('https', null, null, 'http', 8080, ''),
array('https', null, 8443, 'http', 8080, ':8443'),
array('https', null, 443, 'http', 8080, ''),
array('https', null, null, 'https', 8443, ":8443"),
array('https', null, 4443, 'https', 8443, ":4443"),
array('https', null, 443, 'https', 8443, ""),
array('http', null, null, 'https', 8443, ""),
array('http', 8080, 4443, 'https', 8443, ":8080"),
array('http', 80, 4443, 'https', 8443, ""),
array('https', null, null, 'https', 8443, ':8443'),
array('https', null, 4443, 'https', 8443, ':4443'),
array('https', null, 443, 'https', 8443, ''),
array('http', null, null, 'https', 8443, ''),
array('http', 8080, 4443, 'https', 8443, ':8080'),
array('http', 80, 4443, 'https', 8443, ''),
);
}

View File

@ -148,7 +148,6 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
'static_method' => array('loadValidatorMetadata'),
'translation_domain' => 'validators',
'strict_email' => false,
'api' => '2.5-bc',
),
'annotations' => array(
'cache' => 'file',
@ -157,6 +156,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
),
'serializer' => array(
'enabled' => false,
'enable_annotations' => false,
),
'property_access' => array(
'magic_call' => false,

View File

@ -60,6 +60,7 @@ $container->loadFromExtension('framework', array(
'debug' => true,
'file_cache_dir' => '%kernel.cache_dir%/annotations',
),
'serializer' => array('enabled' => true),
'ide' => 'file%%link%%format',
'request' => array(
'formats' => array(

View File

@ -1,9 +0,0 @@
<?php
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'api' => '2.5',
),
));

View File

@ -1,9 +0,0 @@
<?php
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'api' => '2.5-bc',
),
));

View File

@ -1,9 +0,0 @@
<?php
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'api' => 'auto',
),
));

View File

@ -1,8 +0,0 @@
<?php
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
),
));

View File

@ -37,5 +37,6 @@
<framework:translator enabled="true" fallback="fr" logging="true" />
<framework:validation enabled="true" cache="apc" />
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
<framework:serializer enabled="true" />
</framework:config>
</container>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config secret="s3cr3t">
<framework:validation enabled="true" api="2.5" />
</framework:config>
</container>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config secret="s3cr3t">
<framework:validation enabled="true" api="2.5-bc" />
</framework:config>
</container>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config secret="s3cr3t">
<framework:validation enabled="true" api="auto" />
</framework:config>
</container>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config secret="s3cr3t">
<framework:validation enabled="true" />
</framework:config>
</container>

View File

@ -46,6 +46,7 @@ framework:
cache: file
debug: true
file_cache_dir: %kernel.cache_dir%/annotations
serializer: { enabled: true }
ide: file%%link%%format
request:
formats:

View File

@ -1,5 +0,0 @@
framework:
secret: s3cr3t
validation:
enabled: true
api: 2.5

View File

@ -1,5 +0,0 @@
framework:
secret: s3cr3t
validation:
enabled: true
api: 2.5-bc

View File

@ -1,5 +0,0 @@
framework:
secret: s3cr3t
validation:
enabled: true
api: auto

View File

@ -1,4 +0,0 @@
framework:
secret: s3cr3t
validation:
enabled: true

View File

@ -236,7 +236,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals('translator.default', (string) $container->getAlias('translator'), '->registerTranslatorConfiguration() redefines translator service from identity to real translator');
$resources = $container->getDefinition('translator.default')->getArgument(4);
$files = array_map(function ($resource) { return realpath($resource); }, $resources['en']);
$files = array_map(function ($resource) { return realpath($resource); }, $resources);
$ref = new \ReflectionClass('Symfony\Component\Validator\Validation');
$this->assertContains(
strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
@ -287,7 +287,7 @@ abstract class FrameworkExtensionTest extends TestCase
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$this->assertCount(7, $calls);
$this->assertCount(6, $calls);
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
$this->assertEquals(array(new Reference('validator.validator_factory')), $calls[0][1]);
$this->assertSame('setTranslator', $calls[1][0]);
@ -300,8 +300,6 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setMetadataCache', $calls[5][0]);
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
$this->assertSame('setApiVersion', $calls[6][0]);
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
}
/**
@ -317,14 +315,14 @@ abstract class FrameworkExtensionTest extends TestCase
$container = $this->createContainerFromFile('full');
$this->assertInstanceOf('Symfony\Component\Validator\ValidatorInterface', $container->get('validator'));
$this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator'));
}
public function testValidationService()
{
$container = $this->createContainerFromFile('validation_annotations');
$this->assertInstanceOf('Symfony\Component\Validator\ValidatorInterface', $container->get('validator'));
$this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator'));
}
public function testAnnotations()
@ -348,7 +346,7 @@ abstract class FrameworkExtensionTest extends TestCase
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$this->assertCount(7, $calls);
$this->assertCount(6, $calls);
$this->assertSame('enableAnnotationMapping', $calls[4][0]);
$this->assertEquals(array(new Reference('annotation_reader')), $calls[4][1]);
$this->assertSame('addMethodMapping', $calls[5][0]);
@ -358,7 +356,7 @@ abstract class FrameworkExtensionTest extends TestCase
public function testValidationPaths()
{
require_once __DIR__."/Fixtures/TestBundle/TestBundle.php";
require_once __DIR__.'/Fixtures/TestBundle/TestBundle.php';
$container = $this->createContainerFromFile('validation_annotations', array(
'kernel.bundles' => array('TestBundle' => 'Symfony\Bundle\FrameworkBundle\Tests\TestBundle'),
@ -366,7 +364,7 @@ abstract class FrameworkExtensionTest extends TestCase
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$this->assertCount(8, $calls);
$this->assertCount(7, $calls);
$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertSame('addYamlMappings', $calls[4][0]);
$this->assertSame('enableAnnotationMapping', $calls[5][0]);
@ -389,79 +387,11 @@ abstract class FrameworkExtensionTest extends TestCase
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$this->assertCount(5, $calls);
$this->assertCount(4, $calls);
$this->assertSame('addXmlMappings', $calls[3][0]);
// no cache, no annotations, no static methods
}
public function testValidation2Dot5Api()
{
$container = $this->createContainerFromFile('validation_2_5_api');
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$this->assertCount(6, $calls);
$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertSame('addMethodMapping', $calls[4][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setApiVersion', $calls[5][0]);
$this->assertSame(array(Validation::API_VERSION_2_5), $calls[5][1]);
$this->assertSame('Symfony\Component\Validator\Validator\ValidatorInterface', $container->getParameter('validator.class'));
// no cache, no annotations
}
public function testValidation2Dot5BcApi()
{
$container = $this->createContainerFromFile('validation_2_5_bc_api');
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$this->assertCount(6, $calls);
$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertSame('addMethodMapping', $calls[4][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setApiVersion', $calls[5][0]);
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
$this->assertSame('Symfony\Component\Validator\ValidatorInterface', $container->getParameter('validator.class'));
// no cache, no annotations
}
public function testValidationImplicitApi()
{
$container = $this->createContainerFromFile('validation_implicit_api');
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$this->assertCount(6, $calls);
$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertSame('addMethodMapping', $calls[4][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
}
/**
* This feature is equivalent to the implicit api, only that the "api"
* key is explicitly set to "auto".
*/
public function testValidationAutoApi()
{
$container = $this->createContainerFromFile('validation_auto_api');
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$this->assertCount(6, $calls);
$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertSame('addMethodMapping', $calls[4][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
}
public function testFormsCanBeEnabledWithoutCsrfProtection()
{
$container = $this->createContainerFromFile('form_no_csrf');
@ -514,6 +444,18 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertTrue($container->has('debug.stopwatch'));
}
public function testSerializerDisabled()
{
$container = $this->createContainerFromFile('default_config');
$this->assertFalse($container->has('serializer'));
}
public function testSerializerEnabled()
{
$container = $this->createContainerFromFile('full');
$this->assertTrue($container->has('serializer'));
}
protected function createContainer(array $data = array())
{
return new ContainerBuilder(new ParameterBag(array_merge(array(

View File

@ -13,8 +13,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Depe
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
class TestExtension extends Extension
class TestExtension extends Extension implements PrependExtensionInterface
{
private $customConfig;
@ -27,6 +28,14 @@ class TestExtension extends Extension
$config = $this->processConfiguration($configuration, $configs);
}
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
$container->prependExtensionConfig('test', array('custom' => 'foo'));
}
/**
* {@inheritdoc}
*/

View File

@ -0,0 +1,51 @@
<?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\FrameworkBundle\Tests\Functional;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Tester\CommandTester;
/**
* @group functional
*/
class ConfigDebugCommandTest extends WebTestCase
{
private $application;
protected function setUp()
{
$kernel = static::createKernel(array('test_case' => 'ConfigDump', 'root_config' => 'config.yml'));
$this->application = new Application($kernel);
$this->application->doRun(new ArrayInput(array()), new NullOutput());
}
public function testDumpBundleName()
{
$tester = $this->createCommandTester();
$ret = $tester->execute(array('name' => 'TestBundle'));
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('custom: foo', $tester->getDisplay());
}
/**
* @return CommandTester
*/
private function createCommandTester()
{
$command = $this->application->find('debug:config');
return new CommandTester($command);
}
}

View File

@ -35,7 +35,7 @@ class ConfigDumpReferenceCommandTest extends WebTestCase
$tester = $this->createCommandTester();
$ret = $tester->execute(array('name' => 'TestBundle'));
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('test:', $tester->getDisplay());
$this->assertContains(' custom:', $tester->getDisplay());
}

View File

@ -42,8 +42,8 @@ EOF;
"double-quoted key with whitespace and escaped \$\n\" sequences" => "prefixdouble-quoted key with whitespace and escaped \$\n\" sequences",
'single-quoted key with whitespace and nonescaped \$\n\' sequences' => 'prefixsingle-quoted key with whitespace and nonescaped \$\n\' sequences',
'single-quoted key with "quote mark at the end"' => 'prefixsingle-quoted key with "quote mark at the end"',
$expectedHeredoc => "prefix".$expectedHeredoc,
$expectedNowdoc => "prefix".$expectedNowdoc,
$expectedHeredoc => 'prefix'.$expectedHeredoc,
$expectedNowdoc => 'prefix'.$expectedNowdoc,
'{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples' => 'prefix{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
));
$actualCatalogue = $catalogue->all();

View File

@ -106,9 +106,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
{
$loader = new \Symfony\Component\Translation\Loader\YamlFileLoader();
$resourceFiles = array(
'fr' => array(
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
),
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
);
// prime the cache
@ -122,15 +120,19 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$translator->setLocale('fr');
$this->assertEquals('répertoire', $translator->trans('folder'));
// refresh cache when resources is changed in debug mode.
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'debug' => true), array(), 'yml');
$translator->setLocale('fr');
$this->assertEquals('folder', $translator->trans('folder'));
}
public function testLoadRessourcesWithoutCaching()
{
$loader = new \Symfony\Component\Translation\Loader\YamlFileLoader();
$resourceFiles = array(
'fr' => array(
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
),
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
);
$translator = $this->getTranslator($loader, array(), $resourceFiles, 'yml');

View File

@ -77,7 +77,7 @@ class PhpStringTokenParser
if ('\'' === $str[$bLength]) {
return str_replace(
array('\\\\', '\\\''),
array( '\\', '\''),
array('\\', '\''),
substr($str, $bLength + 1, -1)
);
} else {

View File

@ -59,6 +59,9 @@ class Translator extends BaseTranslator
}
$this->options = array_merge($this->options, $options);
if (null !== $this->options['cache_dir'] && $this->options['debug']) {
$this->loadResources();
}
parent::__construct(null, $selector, $this->options['cache_dir'], $this->options['debug']);
}
@ -69,12 +72,12 @@ class Translator extends BaseTranslator
protected function initializeCatalogue($locale)
{
$this->initialize();
$this->loadResources($locale);
parent::initializeCatalogue($locale);
}
protected function initialize()
{
$this->loadResources();
foreach ($this->loaderIds as $id => $aliases) {
foreach ($aliases as $alias) {
$this->addLoader($alias, $this->container->get($id));
@ -82,18 +85,13 @@ class Translator extends BaseTranslator
}
}
private function loadResources($locale)
private function loadResources()
{
$locales = array_merge(array($locale), $this->computeFallbackLocales($locale));
foreach ($locales as $locale) {
if (isset($this->resourceFiles[$locale])) {
foreach ($this->resourceFiles[$locale] as $file) {
// filename is domain.locale.format
list($domain, $locale, $format) = explode('.', basename($file), 3);
$this->addResource($format, $file, $locale, $domain);
}
unset($this->resourceFiles[$locale]);
}
foreach ($this->resourceFiles as $key => $file) {
// filename is domain.locale.format
list($domain, $locale, $format) = explode('.', basename($file), 3);
$this->addResource($format, $file, $locale, $domain);
unset($this->resourceFiles[$key]);
}
}
}

View File

@ -0,0 +1,225 @@
<?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\SecurityBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Helper\Table;
/**
* Encode a user's password.
*
* @author Sarah Khalil <mkhalil.sarah@gmail.com>
*/
class UserPasswordEncoderCommand extends ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('security:encode-password')
->setDescription('Encode a password.')
->addArgument('password', InputArgument::OPTIONAL, 'Enter a password')
->addArgument('user-class', InputArgument::OPTIONAL, 'Enter the user class configured to find the encoder you need.')
->addArgument('salt', InputArgument::OPTIONAL, 'Enter the salt you want to use to encode your password.')
->setHelp(<<<EOF
The <info>%command.name%</info> command allows to encode a password using encoders
that are configured in the application configuration file, under the <comment>security.encoders</comment>.
For instance, if you have the following configuration for your application:
<comment>
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
AppBundle\Model\User: bcrypt
</comment>
According to the response you will give to the question "<question>Provide your configured user class</question>" your
password will be encoded the way it was configured.
- If you answer "<comment>Symfony\Component\Security\Core\User\User</comment>", the password provided will be encoded
with the <comment>plaintext</comment> encoder.
- If you answer <comment>AppBundle\Model\User</comment>, the password provided will be encoded
with the <comment>bcrypt</comment> encoder.
The command allows you to provide your own <comment>salt</comment>. If you don't provide any,
the command will take care about that for you.
You can also use the non interactive way by typing the following command:
<info>php %command.full_name% [password] [user-class] [salt]</info>
EOF
)
;
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->writeIntroduction($output);
$password = $input->getArgument('password');
$salt = $input->getArgument('salt');
$userClass = $input->getArgument('user-class');
$helper = $this->getHelper('question');
if (!$password) {
$passwordQuestion = $this->createPasswordQuestion($input, $output);
$password = $helper->ask($input, $output, $passwordQuestion);
}
if (!$salt) {
$saltQuestion = $this->createSaltQuestion($input, $output);
$salt = $helper->ask($input, $output, $saltQuestion);
}
$output->writeln("\n <comment>Encoders are configured by user type in the security.yml file.</comment>");
if (!$userClass) {
$userClassQuestion = $this->createUserClassQuestion($input, $output);
$userClass = $helper->ask($input, $output, $userClassQuestion);
}
$encoder = $this->getContainer()->get('security.encoder_factory')->getEncoder($userClass);
$encodedPassword = $encoder->encodePassword($password, $salt);
$this->writeResult($output);
$table = new Table($output);
$table
->setHeaders(array('Key', 'Value'))
->addRow(array('Encoder used', get_class($encoder)))
->addRow(array('Encoded password', $encodedPassword))
;
$table->render();
}
/**
* Create the password question to ask the user for the password to be encoded.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return Question
*/
private function createPasswordQuestion(InputInterface $input, OutputInterface $output)
{
$passwordQuestion = new Question("\n > <question>Type in your password to be encoded:</question> ");
$passwordQuestion->setValidator(function ($value) {
if ('' === trim($value)) {
throw new \Exception('The password must not be empty.');
}
return $value;
});
$passwordQuestion->setHidden(true);
$passwordQuestion->setMaxAttempts(20);
return $passwordQuestion;
}
/**
* Create the question that asks for the salt to perform the encoding.
* If there is no provided salt, a random one is automatically generated.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return Question
*/
private function createSaltQuestion(InputInterface $input, OutputInterface $output)
{
$saltQuestion = new Question("\n > (Optional) <question>Provide a salt (press <enter> to generate one):</question> ");
$container = $this->getContainer();
$saltQuestion->setValidator(function ($value) use ($output, $container) {
if ('' === trim($value)) {
$value = base64_encode($container->get('security.secure_random')->nextBytes(30));
$output->writeln("\n<comment>The salt has been generated: </comment>".$value);
$output->writeln(sprintf("<comment>Make sure that your salt storage field fits this salt length: %s chars.</comment>\n", strlen($value)));
}
return $value;
});
return $saltQuestion;
}
/**
* Create the question that asks for the configured user class.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return Question
*/
private function createUserClassQuestion(InputInterface $input, OutputInterface $output)
{
$userClassQuestion = new Question(" > <question>Provide your configured user class:</question> ");
$userClassQuestion->setAutocompleterValues(array('Symfony\Component\Security\Core\User\User'));
$userClassQuestion->setValidator(function ($value) use ($output) {
if ('' === trim($value)) {
$value = 'Symfony\Component\Security\Core\User\User';
$output->writeln("<info>You did not provide any user class.</info> <comment>The user class used is: Symfony\Component\Security\Core\User\User</comment> \n");
}
return $value;
});
return $userClassQuestion;
}
private function writeIntroduction(OutputInterface $output)
{
$output->writeln(array(
'',
$this->getHelperSet()->get('formatter')->formatBlock(
'Symfony Password Encoder Utility',
'bg=blue;fg=white',
true
),
'',
));
$output->writeln(array(
'',
'This command encodes any password you want according to the configuration you',
'made in your configuration file containing the <comment>security.encoders</comment> key.',
'',
));
}
private function writeResult(OutputInterface $output)
{
$output->writeln(array(
'',
$this->getHelperSet()->get('formatter')->formatBlock(
'✔ Password encoding succeeded',
'bg=green;fg=white',
true
),
'',
));
}
}

View File

@ -44,10 +44,10 @@ class LogoutUrlHelper extends Helper
if ($generator instanceof ContainerInterface) {
trigger_error('The '.__CLASS__.' constructor will require a LogoutUrlGenerator instead of a ContainerInterface instance in 3.0.', E_USER_DEPRECATED);
if ($container->has('security.logout_url_generator')) {
$this->generator = $container->get('security.logout_url_generator');
if ($generator->has('security.logout_url_generator')) {
$this->generator = $generator->get('security.logout_url_generator');
} else {
$this->generator = new LogoutUrlGenerator($container->get('request_stack'), $router, $tokenStorage);
$this->generator = new LogoutUrlGenerator($generator->get('request_stack'), $router, $tokenStorage);
}
} else {
$this->generator = $generator;

View File

@ -61,8 +61,8 @@ class SecurityRoutingIntegrationTest extends WebTestCase
*/
public function testSecurityConfigurationForSingleIPAddress($config)
{
$allowedClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array("REMOTE_ADDR" => "10.10.10.10"));
$barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array("REMOTE_ADDR" => "10.10.20.10"));
$allowedClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '10.10.10.10'));
$barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '10.10.20.10'));
$this->assertAllowed($allowedClient, '/secured-by-one-ip');
$this->assertRestricted($barredClient, '/secured-by-one-ip');
@ -74,9 +74,9 @@ class SecurityRoutingIntegrationTest extends WebTestCase
*/
public function testSecurityConfigurationForMultipleIPAddresses($config)
{
$allowedClientA = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array("REMOTE_ADDR" => "1.1.1.1"));
$allowedClientB = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array("REMOTE_ADDR" => "2.2.2.2"));
$barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array("REMOTE_ADDR" => "192.168.1.1"));
$allowedClientA = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '1.1.1.1'));
$allowedClientB = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '2.2.2.2'));
$barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '192.168.1.1'));
$this->assertAllowed($allowedClientA, '/secured-by-two-ips');
$this->assertAllowed($allowedClientB, '/secured-by-two-ips');

View File

@ -0,0 +1,96 @@
<?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\SecurityBundle\Tests\Functional;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand;
use Symfony\Component\Console\Tester\CommandTester;
/**
* Tests UserPasswordEncoderCommand
*
* @author Sarah Khalil <mkhalil.sarah@gmail.com>
*/
class UserPasswordEncoderCommandTest extends WebTestCase
{
private $passwordEncoderCommandTester;
public function testEncodePasswordPasswordPlainText()
{
$this->passwordEncoderCommandTester->execute(array(
'command' => 'security:encode-password',
'password' => 'password',
'user-class' => 'Symfony\Component\Security\Core\User\User',
'salt' => 'AZERTYUIOPOfghjklytrertyuiolnbcxdfghjkytrfghjk',
));
$expected = file_get_contents(__DIR__.'/app/PasswordEncode/plaintext.txt');
$this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay());
}
public function testEncodePasswordBcrypt()
{
$this->passwordEncoderCommandTester->execute(array(
'command' => 'security:encode-password',
'password' => 'password',
'user-class' => 'Custom\Class\Bcrypt\User',
'salt' => 'AZERTYUIOPOfghjklytrertyuiolnbcxdfghjkytrfghjk',
));
$expected = file_get_contents(__DIR__.'/app/PasswordEncode/bcrypt.txt');
$this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay());
}
public function testEncodePasswordPbkdf2()
{
$this->passwordEncoderCommandTester->execute(array(
'command' => 'security:encode-password',
'password' => 'password',
'user-class' => 'Custom\Class\Pbkdf2\User',
'salt' => 'AZERTYUIOPOfghjklytrertyuiolnbcxdfghjkytrfghjk',
));
$expected = file_get_contents(__DIR__.'/app/PasswordEncode/pbkdf2.txt');
$this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay());
}
public function testEncodePasswordNoConfigForGivenUserClass()
{
$this->setExpectedException('\RuntimeException', 'No encoder has been configured for account "Wrong/User/Class".');
$this->passwordEncoderCommandTester->execute(array(
'command' => 'security:encode-password',
'password' => 'password',
'user-class' => 'Wrong/User/Class',
'salt' => 'AZERTYUIOPOfghjklytrertyuiolnbcxdfghjkytrfghjk',
));
}
protected function setUp()
{
$kernel = $this->createKernel(array('test_case' => 'PasswordEncode'));
$kernel->boot();
$application = new Application($kernel);
$application->add(new UserPasswordEncoderCommand());
$passwordEncoderCommand = $application->find('security:encode-password');
$this->passwordEncoderCommandTester = new CommandTester($passwordEncoderCommand);
}
protected function tearDown()
{
$this->passwordEncoderCommandTester = null;
}
}

View File

@ -0,0 +1,22 @@
Symfony Password Encoder Utility
This command encodes any password you want according to the configuration you
made in your configuration file containing the security.encoders key.
Encoders are configured by user type in the security.yml file.
✔ Password encoding succeeded
+------------------+---------------------------------------------------------------+
| Key | Value |
+------------------+---------------------------------------------------------------+
| Encoder used | Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder |
| Encoded password | $2y$13$AZERTYUIOPOfghjklytreeBTRM4Wd.D3IW7dtnQ6xGA7z3fY8zg4. |
+------------------+---------------------------------------------------------------+

View File

@ -0,0 +1,6 @@
<?php
return array(
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
);

View File

@ -0,0 +1,21 @@
imports:
- { resource: ./../config/framework.yml }
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
Custom\Class\Bcrypt\User: bcrypt
Custom\Class\Pbkdf2\User: pbkdf2
Custom\Class\Test\User: test
providers:
in_memory:
memory:
users:
user: { password: userpass, roles: [ 'ROLE_USER' ] }
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
firewalls:
test:
pattern: ^/
security: false

View File

@ -0,0 +1,22 @@
Symfony Password Encoder Utility
This command encodes any password you want according to the configuration you
made in your configuration file containing the security.encoders key.
Encoders are configured by user type in the security.yml file.
✔ Password encoding succeeded
+------------------+---------------------------------------------------------------+
| Key | Value |
+------------------+---------------------------------------------------------------+
| Encoder used | Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder |
| Encoded password | nvGk/kUwqj6PHzmqUqXxJA6GEhxD1TSJziV8P4ThqsEi4ZHF6yHp6g== |
+------------------+---------------------------------------------------------------+

View File

@ -0,0 +1,22 @@
Symfony Password Encoder Utility
This command encodes any password you want according to the configuration you
made in your configuration file containing the security.encoders key.
Encoders are configured by user type in the security.yml file.
✔ Password encoding succeeded
+------------------+------------------------------------------------------------------+
| Key | Value |
+------------------+------------------------------------------------------------------+
| Encoder used | Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder |
| Encoded password | password{AZERTYUIOPOfghjklytrertyuiolnbcxdfghjkytrfghjk} |
+------------------+------------------------------------------------------------------+

View File

@ -37,7 +37,8 @@
"symfony/yaml": "~2.7|~3.0",
"symfony/expression-language": "~2.7|~3.0",
"doctrine/doctrine-bundle": "~1.2",
"twig/twig": "~1.12"
"twig/twig": "~1.12",
"ircmaxell/password-compat": "~1.0"
},
"autoload": {
"psr-0": { "Symfony\\Bundle\\SecurityBundle\\": "" }

View File

@ -373,7 +373,7 @@
throw "Tab target " + targetId + " does not exist";
}
clickHandler(buttons[i], select);
clickHandler(tabs[i], select);
Sfjs.addClass(target, 'hidden');
}
@ -398,7 +398,7 @@
e = window.event;
}
callback(e.target || e.srcElement);
callback(this);
if (e.preventDefault) {
e.preventDefault();

View File

@ -4,6 +4,17 @@
var noop = function() {},
collectionToArray = function (collection) {
var length = collection.length || 0,
results = new Array(length);
while (length--) {
results[length] = collection[length];
}
return results;
},
profilerStorageKey = 'sf2/profiler/',
request = function(url, onSuccess, onError, payload, options) {
@ -134,13 +145,13 @@
}
} else if (request.loading) {
requestState = 'loading';
state = 'loading'
state = 'loading';
}
row.className = 'sf-ajax-request sf-ajax-request-' + requestState;
}
var infoSpan = document.querySelectorAll(".sf-toolbar-ajax-info")[0];
var children = Array.prototype.slice.call(tbody.children);
var children = collectionToArray(tbody.children);
for (var i = 0; i < children.length; i++) {
tbody.removeChild(children[i]);
}
@ -188,7 +199,7 @@
}
{% if excluded_ajax_paths is defined %}
if (window.XMLHttpRequest) {
if (window.XMLHttpRequest && XMLHttpRequest.addEventListener) {
var proxied = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
@ -265,9 +276,7 @@
},
toggle: function(selector, elOn, elOff) {
var i,
style,
tmp = elOn.style.display,
var tmp = elOn.style.display,
el = document.getElementById(selector);
elOn.style.display = elOff.style.display;

View File

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

View File

@ -33,10 +33,10 @@
Sfjs.renderAjaxRequests();
/* Handle toolbar-info position */
var toolbarBlocks = document.getElementsByClassName('sf-toolbar-block');
var toolbarBlocks = document.querySelectorAll('.sf-toolbar-block');
for (var i = 0; i < toolbarBlocks.length; i += 1) {
toolbarBlocks[i].onmouseover = function () {
var toolbarInfo = this.getElementsByClassName('sf-toolbar-info')[0];
var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0];
var pageWidth = document.body.clientWidth;
var elementWidth = toolbarInfo.offsetWidth;
var leftValue = (elementWidth + this.offsetLeft) - pageWidth;

View File

@ -76,7 +76,7 @@ class FileLoaderLoadException extends \Exception
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
}
return sprintf("Array(%s)", implode(', ', $a));
return sprintf('Array(%s)', implode(', ', $a));
}
if (is_resource($var)) {

View File

@ -45,7 +45,7 @@ class ExampleConfiguration implements ConfigurationInterface
->info(
"this is a long\n".
"multi-line info text\n".
"which should be indented"
'which should be indented'
)
->example('example setting')
->end()

View File

@ -724,15 +724,15 @@ class Application
$output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line));
}
$output->writeln("");
$output->writeln("");
$output->writeln('');
$output->writeln('');
}
} while ($e = $e->getPrevious());
if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())));
$output->writeln("");
$output->writeln("");
$output->writeln('');
$output->writeln('');
}
}

View File

@ -18,12 +18,12 @@ class Foo3Command extends Command
{
try {
try {
throw new \Exception("First exception <p>this is html</p>");
throw new \Exception('First exception <p>this is html</p>');
} catch (\Exception $e) {
throw new \Exception("Second exception <comment>comment</comment>", 0, $e);
throw new \Exception('Second exception <comment>comment</comment>', 0, $e);
}
} catch (\Exception $e) {
throw new \Exception("Third exception <fg=blue;bg=red>comment</>", 0, $e);
throw new \Exception('Third exception <fg=blue;bg=red>comment</>', 0, $e);
}
}
}

View File

@ -19,15 +19,15 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase
public function testEmptyTag()
{
$formatter = new OutputFormatter(true);
$this->assertEquals("foo<>bar", $formatter->format('foo<>bar'));
$this->assertEquals('foo<>bar', $formatter->format('foo<>bar'));
}
public function testLGCharEscaping()
{
$formatter = new OutputFormatter(true);
$this->assertEquals("foo<bar", $formatter->format('foo\\<bar'));
$this->assertEquals("<info>some info</info>", $formatter->format('\\<info>some info\\</info>'));
$this->assertEquals('foo<bar', $formatter->format('foo\\<bar'));
$this->assertEquals('<info>some info</info>', $formatter->format('\\<info>some info\\</info>'));
$this->assertEquals("\\<info>some info\\</info>", OutputFormatter::escape('<info>some info</info>'));
$this->assertEquals(
@ -176,16 +176,16 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($formatter->hasStyle('question'));
$this->assertEquals(
"some error", $formatter->format('<error>some error</error>')
'some error', $formatter->format('<error>some error</error>')
);
$this->assertEquals(
"some info", $formatter->format('<info>some info</info>')
'some info', $formatter->format('<info>some info</info>')
);
$this->assertEquals(
"some comment", $formatter->format('<comment>some comment</comment>')
'some comment', $formatter->format('<comment>some comment</comment>')
);
$this->assertEquals(
"some question", $formatter->format('<question>some question</question>')
'some question', $formatter->format('<question>some question</question>')
);
$formatter->setDecorated(true);

View File

@ -81,8 +81,8 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
array('--long-option="foo bar"', array('--long-option=foo bar'), '->tokenize() parses long options with a value'),
array('--long-option="foo bar""another"', array('--long-option=foo baranother'), '->tokenize() parses long options with a value'),
array('--long-option=\'foo bar\'', array('--long-option=foo bar'), '->tokenize() parses long options with a value'),
array("--long-option='foo bar''another'", array("--long-option=foo baranother"), '->tokenize() parses long options with a value'),
array("--long-option='foo bar'\"another\"", array("--long-option=foo baranother"), '->tokenize() parses long options with a value'),
array("--long-option='foo bar''another'", array('--long-option=foo baranother'), '->tokenize() parses long options with a value'),
array("--long-option='foo bar'\"another\"", array('--long-option=foo baranother'), '->tokenize() parses long options with a value'),
array('foo -a -ffoo --long bar', array('foo', '-a', '-ffoo', '--long', 'bar'), '->tokenize() parses when several arguments and options'),
);
}

View File

@ -19,6 +19,6 @@ namespace Symfony\Component\CssSelector\Exception;
*
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
*/
class ExpressionErrorException extends ParseException implements ExceptionInterface
class ExpressionErrorException extends ParseException
{
}

View File

@ -19,6 +19,6 @@ namespace Symfony\Component\CssSelector\Exception;
*
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
*/
class InternalErrorException extends ParseException implements ExceptionInterface
class InternalErrorException extends ParseException
{
}

View File

@ -21,7 +21,7 @@ use Symfony\Component\CssSelector\Parser\Token;
*
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
*/
class SyntaxErrorException extends ParseException implements ExceptionInterface
class SyntaxErrorException extends ParseException
{
/**
* @param string $expectedValue

View File

@ -37,23 +37,23 @@ class CssSelectorTest extends \PHPUnit_Framework_TestCase
$this->fail('->parse() throws an Exception if the css selector is not valid');
} catch (\Exception $e) {
$this->assertInstanceOf('\Symfony\Component\CssSelector\Exception\ParseException', $e, '->parse() throws an Exception if the css selector is not valid');
$this->assertEquals("Expected identifier, but <eof at 3> found.", $e->getMessage(), '->parse() throws an Exception if the css selector is not valid');
$this->assertEquals('Expected identifier, but <eof at 3> found.', $e->getMessage(), '->parse() throws an Exception if the css selector is not valid');
}
}
public function getCssToXPathWithoutPrefixTestData()
{
return array(
array('h1', "h1"),
array('foo|h1', "foo:h1"),
array('h1, h2, h3', "h1 | h2 | h3"),
array('h1', 'h1'),
array('foo|h1', 'foo:h1'),
array('h1, h2, h3', 'h1 | h2 | h3'),
array('h1:nth-child(3n+1)', "*/*[name() = 'h1' and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"),
array('h1 > p', "h1/p"),
array('h1 > p', 'h1/p'),
array('h1#foo', "h1[@id = 'foo']"),
array('h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
array('h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"),
array('h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"),
array('h1[class]', "h1[@class]"),
array('h1[class]', 'h1[@class]'),
array('h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
array('h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"),
array('h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"),

View File

@ -90,12 +90,12 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
public function getCssToXPathTestData()
{
return array(
array('*', "*"),
array('e', "e"),
array('*|e', "e"),
array('e|f', "e:f"),
array('e[foo]', "e[@foo]"),
array('e[foo|bar]', "e[@foo:bar]"),
array('*', '*'),
array('e', 'e'),
array('*|e', 'e'),
array('e|f', 'e:f'),
array('e[foo]', 'e[@foo]'),
array('e[foo|bar]', 'e[@foo:bar]'),
array('e[foo="bar"]', "e[@foo = 'bar']"),
array('e[foo~="bar"]', "e[@foo and contains(concat(' ', normalize-space(@foo), ' '), ' bar ')]"),
array('e[foo^="bar"]', "e[@foo and starts-with(@foo, 'bar')]"),
@ -105,29 +105,29 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
array('e:nth-child(1)', "*/*[name() = 'e' and (position() = 1)]"),
array('e:nth-last-child(1)', "*/*[name() = 'e' and (position() = last() - 0)]"),
array('e:nth-last-child(2n+2)', "*/*[name() = 'e' and (last() - position() - 1 >= 0 and (last() - position() - 1) mod 2 = 0)]"),
array('e:nth-of-type(1)', "*/e[position() = 1]"),
array('e:nth-last-of-type(1)', "*/e[position() = last() - 0]"),
array('e:nth-of-type(1)', '*/e[position() = 1]'),
array('e:nth-last-of-type(1)', '*/e[position() = last() - 0]'),
array('div e:nth-last-of-type(1) .aclass', "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')]"),
array('e:first-child', "*/*[name() = 'e' and (position() = 1)]"),
array('e:last-child', "*/*[name() = 'e' and (position() = last())]"),
array('e:first-of-type', "*/e[position() = 1]"),
array('e:last-of-type', "*/e[position() = last()]"),
array('e:first-of-type', '*/e[position() = 1]'),
array('e:last-of-type', '*/e[position() = last()]'),
array('e:only-child', "*/*[name() = 'e' and (last() = 1)]"),
array('e:only-of-type', "e[last() = 1]"),
array('e:empty', "e[not(*) and not(string-length())]"),
array('e:EmPTY', "e[not(*) and not(string-length())]"),
array('e:root', "e[not(parent::*)]"),
array('e:hover', "e[0]"),
array('e:only-of-type', 'e[last() = 1]'),
array('e:empty', 'e[not(*) and not(string-length())]'),
array('e:EmPTY', 'e[not(*) and not(string-length())]'),
array('e:root', 'e[not(parent::*)]'),
array('e:hover', 'e[0]'),
array('e:contains("foo")', "e[contains(string(.), 'foo')]"),
array('e:ConTains(foo)', "e[contains(string(.), 'foo')]"),
array('e.warning', "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')]"),
array('e#myid', "e[@id = 'myid']"),
array('e:not(:nth-child(odd))', "e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]"),
array('e:nOT(*)', "e[0]"),
array('e f', "e/descendant-or-self::*/f"),
array('e > f', "e/f"),
array('e:not(:nth-child(odd))', 'e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]'),
array('e:nOT(*)', 'e[0]'),
array('e f', 'e/descendant-or-self::*/f'),
array('e > f', 'e/f'),
array('e + f', "e/following-sibling::*[name() = 'f' and (position() = 1)]"),
array('e ~ f', "e/following-sibling::f"),
array('e ~ f', 'e/following-sibling::f'),
array('div#container p', "div[@id = 'container']/descendant-or-self::*/p"),
);
}

View File

@ -98,9 +98,9 @@ class HtmlExtension extends AbstractExtension
public function translateDisabled(XPathExpr $xpath)
{
return $xpath->addCondition(
"("
."@disabled and"
."("
'('
.'@disabled and'
.'('
."(name(.) = 'input' and @type != 'hidden')"
." or name(.) = 'button'"
." or name(.) = 'select'"
@ -109,14 +109,14 @@ class HtmlExtension extends AbstractExtension
." or name(.) = 'fieldset'"
." or name(.) = 'optgroup'"
." or name(.) = 'option'"
.")"
.") or ("
.')'
.') or ('
."(name(.) = 'input' and @type != 'hidden')"
." or name(.) = 'button'"
." or name(.) = 'select'"
." or name(.) = 'textarea'"
.")"
." and ancestor::fieldset[@disabled]"
.')'
.' and ancestor::fieldset[@disabled]'
);
// todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any."
}
@ -150,10 +150,10 @@ class HtmlExtension extends AbstractExtension
." or name(.) = 'textarea'"
." or name(.) = 'keygen'"
.')'
." and not (@disabled or ancestor::fieldset[@disabled])"
.' and not (@disabled or ancestor::fieldset[@disabled])'
.') or ('
."name(.) = 'option' and not("
."@disabled or ancestor::optgroup[@disabled]"
.'@disabled or ancestor::optgroup[@disabled]'
.')'
.')'
);

View File

@ -417,9 +417,9 @@ EOF;
$result = array();
foreach ($args as $key => $item) {
if ('object' === $item[0]) {
$formattedValue = sprintf("<em>object</em>(%s)", $this->formatClass($item[1]));
$formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
} elseif ('array' === $item[0]) {
$formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
$formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
} elseif ('string' === $item[0]) {
$formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
} elseif ('null' === $item[0]) {

View File

@ -65,6 +65,9 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
$configurator = $this->inlineArguments($container, array($definition->getConfigurator()));
$definition->setConfigurator($configurator[0]);
$factory = $this->inlineArguments($container, array($definition->getFactory()));
$definition->setFactory($factory[0]);
}
}

View File

@ -55,10 +55,10 @@ class MergeExtensionConfigurationPass implements CompilerPassInterface
$extension->load($config, $tmpContainer);
$container->merge($tmpContainer);
$container->getParameterBag()->add($parameters);
}
$container->addDefinitions($definitions);
$container->addAliases($aliases);
$container->getParameterBag()->add($parameters);
}
}

View File

@ -180,7 +180,7 @@ class GraphvizDumper extends Dumper
foreach ($container->getServiceIds() as $id) {
$service = $container->get($id);
if (in_array($id, array_keys($container->getAliases()))) {
if (array_key_exists($id, $container->getAliases())) {
continue;
}

View File

@ -560,7 +560,7 @@ class PhpDumper extends Dumper
if ($definition->isSynthetic()) {
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
} elseif ($class = $definition->getClass()) {
$return[] = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'object' : "\\".$class, $class);
$return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : "\\".$class, $class);
} elseif ($definition->getFactory()) {
$factory = $definition->getFactory();
if (is_string($factory)) {
@ -1241,7 +1241,7 @@ EOF;
*
* @return bool
*/
private function hasReference($id, array $arguments, $deep = false, array $visited = array())
private function hasReference($id, array $arguments, $deep = false, array &$visited = array())
{
foreach ($arguments as $argument) {
if (is_array($argument)) {
@ -1340,7 +1340,7 @@ EOF;
} elseif (null !== $value->getFactoryService(false)) {
$service = $this->dumpValue($value->getFactoryService(false));
return sprintf("%s->%s(%s)", 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
return sprintf('%s->%s(%s)', 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
} else {
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
}

View File

@ -178,7 +178,11 @@ class XmlDumper extends Dumper
if ($callable = $definition->getFactory()) {
$factory = $this->document->createElement('factory');
if (is_array($callable)) {
if (is_array($callable) && $callable[0] instanceof Definition) {
$this->addService($callable[0], null, $factory);
$factory->setAttribute('method', $callable[1]);
} elseif (is_array($callable)) {
$factory->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
$factory->setAttribute('method', $callable[1]);
} else {
@ -189,7 +193,11 @@ class XmlDumper extends Dumper
if ($callable = $definition->getConfigurator()) {
$configurator = $this->document->createElement('configurator');
if (is_array($callable)) {
if (is_array($callable) && $callable[0] instanceof Definition) {
$this->addService($callable[0], null, $configurator);
$configurator->setAttribute('method', $callable[1]);
} elseif (is_array($callable)) {
$configurator->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
$configurator->setAttribute('method', $callable[1]);
} else {

View File

@ -116,25 +116,27 @@ class XmlFileLoader extends FileLoader
}
foreach ($services as $service) {
$this->parseDefinition((string) $service->getAttribute('id'), $service, $file);
if (null !== $definition = $this->parseDefinition($service, $file)) {
$this->container->setDefinition((string) $service->getAttribute('id'), $definition);
}
}
}
/**
* Parses an individual Definition.
*
* @param string $id
* @param \DOMElement $service
* @param string $file
*
* @return Definition|null
*/
private function parseDefinition($id, \DOMElement $service, $file)
private function parseDefinition(\DOMElement $service)
{
if ($alias = $service->getAttribute('alias')) {
$public = true;
if ($publicAttr = $service->getAttribute('public')) {
$public = XmlUtils::phpize($publicAttr);
}
$this->container->setAlias($id, new Alias($alias, $public));
$this->container->setAlias((string) $service->getAttribute('id'), new Alias($alias, $public));
return;
}
@ -153,7 +155,7 @@ class XmlFileLoader extends FileLoader
}
if ($value = $service->getAttribute('synchronized')) {
$definition->setSynchronized(XmlUtils::phpize($value), 'request' !== $id);
$definition->setSynchronized(XmlUtils::phpize($value), 'request' !== (string) $service->getAttribute('id'));
}
if ($files = $this->getChildren($service, 'file')) {
@ -168,7 +170,11 @@ class XmlFileLoader extends FileLoader
if ($function = $factory->getAttribute('function')) {
$definition->setFactory($function);
} else {
if ($childService = $factory->getAttribute('service')) {
$factoryService = $this->getChildren($factory, 'service');
if (isset($factoryService[0])) {
$class = $this->parseDefinition($factoryService[0]);
} elseif ($childService = $factory->getAttribute('service')) {
$class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false);
} else {
$class = $factory->getAttribute('class');
@ -183,7 +189,11 @@ class XmlFileLoader extends FileLoader
if ($function = $configurator->getAttribute('function')) {
$definition->setConfigurator($function);
} else {
if ($childService = $configurator->getAttribute('service')) {
$configuratorService = $this->getChildren($configurator, 'service');
if (isset($configuratorService[0])) {
$class = $this->parseDefinition($configuratorService[0]);
} elseif ($childService = $configurator->getAttribute('service')) {
$class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false);
} else {
$class = $configurator->getAttribute('class');
@ -219,7 +229,7 @@ class XmlFileLoader extends FileLoader
$definition->setDecoratedService($value, $renameId);
}
$this->container->setDefinition($id, $definition);
return $definition;
}
/**
@ -295,7 +305,9 @@ class XmlFileLoader extends FileLoader
// we could not use the constant false here, because of XML parsing
$domElement->setAttribute('public', 'false');
$this->parseDefinition($id, $domElement, $file);
if (null !== $definition = $this->parseDefinition($domElement, $file)) {
$this->container->setDefinition($id, $definition);
}
if (true === $wild) {
$tmpDomElement = new \DOMElement('_services', null, self::NS);

View File

@ -237,8 +237,15 @@ class YamlFileLoader extends FileLoader
}
foreach ($service['calls'] as $call) {
$args = isset($call[1]) ? $this->resolveServices($call[1]) : array();
$definition->addMethodCall($call[0], $args);
if (isset($call['method'])) {
$method = $call['method'];
$args = isset($call['arguments']) ? $this->resolveServices($call['arguments']) : array();
} else {
$method = $call[0];
$args = isset($call[1]) ? $this->resolveServices($call[1]) : array();
}
$definition->addMethodCall($method, $args);
}
}

View File

@ -65,6 +65,9 @@
</xsd:complexType>
<xsd:complexType name="callable">
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="service" type="service" minOccurs="0" maxOccurs="1" />
</xsd:choice>
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="service" type="xsd:string" />
<xsd:attribute name="class" type="xsd:string" />

View File

@ -237,23 +237,6 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
$this->assertSame($ref, $calls[0][1][0]);
}
public function testProcessDoesNotInlineFactories()
{
$container = new ContainerBuilder();
$container
->register('foo.factory')
->setPublic(false)
;
$container
->register('foo')
->setFactory(array(new Reference('foo.factory'), 'getFoo'))
;
$this->process($container);
$factory = $container->getDefinition('foo')->getFactory();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $factory[0]);
}
protected function process(ContainerBuilder $container)
{
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new InlineServiceDefinitionsPass()));

View File

@ -1,6 +1,5 @@
<?php
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;

View File

@ -48,8 +48,8 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
'.' => 'dot as a key',
'.\'\'.' => 'concatenation as a key',
'\'\'.' => 'concatenation from the start key',
'optimize concatenation' => "string1%some_string%string2",
'optimize concatenation with empty string' => "string1%empty_value%string2",
'optimize concatenation' => 'string1%some_string%string2',
'optimize concatenation with empty string' => 'string1%empty_value%string2',
'optimize concatenation from the start' => '%empty_value%start',
'optimize concatenation at the end' => 'end%empty_value%',
));

View File

@ -169,9 +169,18 @@ class XmlDumperTest extends \PHPUnit_Framework_TestCase
{
return array(
array('container8'),
array('container9'),
array('container11'),
array('container12'),
array('container14'),
);
}
public function testDumpInlinedServices()
{
$container = include self::$fixturesPath.'/containers/container21.php';
$dumper = new XmlDumper($container);
$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services21.xml'), $dumper->dump());
}
}

View File

@ -0,0 +1,20 @@
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
$container = new ContainerBuilder();
$bar = new Definition('Bar');
$bar->setConfigurator(array(new Definition('Baz'), 'configureBar'));
$fooFactory = new Definition('FooFactory');
$fooFactory->setFactory(array(new Definition('Foobar'), 'createFooFactory'));
$container
->register('foo', 'Foo')
->setFactory(array($fooFactory, 'createFoo'))
->setConfigurator(array($bar, 'configureFoo'))
;
return $container;

View File

@ -46,7 +46,6 @@ class ProjectServiceContainer extends Container
'foo_bar' => 'getFooBarService',
'foo_with_inline' => 'getFooWithInlineService',
'method_call1' => 'getMethodCall1Service',
'new_factory' => 'getNewFactoryService',
'new_factory_service' => 'getNewFactoryServiceService',
'request' => 'getRequestService',
'service_from_static_method' => 'getServiceFromStaticMethodService',
@ -265,7 +264,10 @@ class ProjectServiceContainer extends Container
*/
protected function getNewFactoryServiceService()
{
$this->services['new_factory_service'] = $instance = $this->get('new_factory')->getInstance();
$a = new \FactoryClass();
$a->foo = 'bar';
$this->services['new_factory_service'] = $instance = $a->getInstance();
$instance->foo = 'bar';
@ -298,27 +300,6 @@ class ProjectServiceContainer extends Container
return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance();
}
/**
* Gets the 'new_factory' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* This service is private.
* If you want to be able to request this service from the container directly,
* make it public, otherwise you might end up with broken code.
*
* @return \FactoryClass A FactoryClass instance.
*/
protected function getNewFactoryService()
{
$this->services['new_factory'] = $instance = new \FactoryClass();
$instance->foo = 'bar';
return $instance;
}
/**
* {@inheritdoc}
*/

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="foo" class="Foo">
<factory method="createFoo">
<service class="FooFactory">
<factory method="createFooFactory">
<service class="Foobar"/>
</factory>
</service>
</factory>
<configurator method="configureFoo">
<service class="Bar">
<configurator method="configureBar">
<service class="Baz"/>
</configurator>
</service>
</configurator>
</service>
</services>
</container>

View File

@ -0,0 +1,15 @@
services:
manager:
class: UserManager
arguments:
- true
calls:
- method: setLogger
arguments:
- @logger
- method: setClass
arguments:
- User
tags:
- name: manager
alias: user

View File

@ -274,31 +274,31 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
public function testConvertDomElementToArray()
{
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo>bar</foo>');
$this->assertEquals('bar', XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo foo="bar" />');
$this->assertEquals(array('foo' => 'bar'), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo>bar</foo></foo>');
$this->assertEquals(array('foo' => 'bar'), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo>bar<foo>bar</foo></foo></foo>');
$this->assertEquals(array('foo' => array('value' => 'bar', 'foo' => 'bar')), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo></foo></foo>');
$this->assertEquals(array('foo' => null), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo><!-- foo --></foo></foo>');
$this->assertEquals(array('foo' => null), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo foo="bar"/><foo foo="bar"/></foo>');
$this->assertEquals(array('foo' => array(array('foo' => 'bar'), array('foo' => 'bar'))), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
}
@ -467,4 +467,33 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('index_0' => 'app'), $container->findDefinition('logger')->getArguments());
}
public function testLoadInlinedServices()
{
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
$loader->load('services21.xml');
$foo = $container->getDefinition('foo');
$fooFactory = $foo->getFactory();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $fooFactory[0]);
$this->assertSame('FooFactory', $fooFactory[0]->getClass());
$this->assertSame('createFoo', $fooFactory[1]);
$fooFactoryFactory = $fooFactory[0]->getFactory();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $fooFactoryFactory[0]);
$this->assertSame('Foobar', $fooFactoryFactory[0]->getClass());
$this->assertSame('createFooFactory', $fooFactoryFactory[1]);
$fooConfigurator = $foo->getConfigurator();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $fooConfigurator[0]);
$this->assertSame('Bar', $fooConfigurator[0]->getClass());
$this->assertSame('configureFoo', $fooConfigurator[1]);
$barConfigurator = $fooConfigurator[0]->getConfigurator();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $barConfigurator[0]);
$this->assertSame('Baz', $barConfigurator[0]->getClass());
$this->assertSame('configureBar', $barConfigurator[1]);
}
}

View File

@ -270,4 +270,16 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertStringStartsWith('A "tags" attribute must be of a scalar-type for service "foo_service", tag "foo", attribute "bar"', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar');
}
}
public function testLoadYamlOnlyWithKeys()
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('services21.yml');
$definition = $container->getDefinition('manager');
$this->assertEquals(array(array('setLogger', array(new Reference('logger'))), array('setClass', array('User'))), $definition->getMethodCalls());
$this->assertEquals(array(true), $definition->getArguments());
$this->assertEquals(array('manager' => array(array('alias' => 'user'))), $definition->getTags());
}
}

View File

@ -839,7 +839,7 @@ class Crawler extends \SplObjectStorage
}
}
return sprintf("concat(%s)", implode($parts, ', '));
return sprintf('concat(%s)', implode($parts, ', '));
}
/**
@ -1019,7 +1019,7 @@ class Crawler extends \SplObjectStorage
*/
private function findNamespacePrefixes($xpath)
{
if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*):[^"\/]/i', $xpath, $matches)) {
if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*):[^"\/:]/i', $xpath, $matches)) {
return array_unique($matches['prefix']);
}

View File

@ -197,9 +197,18 @@ class Form extends Link implements \ArrayAccess
{
$uri = parent::getUri();
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH')) && $queryString = http_build_query($this->getValues(), null, '&')) {
$sep = false === strpos($uri, '?') ? '?' : '&';
$uri .= $sep.$queryString;
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
$query = parse_url($uri, PHP_URL_QUERY);
$currentParameters = array();
if ($query) {
parse_str($query, $currentParameters);
}
$queryString = http_build_query(array_merge($currentParameters, $this->getValues()), null, '&');
$pos = strpos($uri, '?');
$base = false === $pos ? $uri : substr($uri, 0, $pos);
$uri = rtrim($base.'?'.$queryString, '?');
}
return $uri;

View File

@ -176,7 +176,7 @@ class FormFieldRegistry
private function walk(array $array, $base = '', array &$output = array())
{
foreach ($array as $k => $v) {
$path = empty($base) ? $k : sprintf("%s[%s]", $base, $k);
$path = empty($base) ? $k : sprintf('%s[%s]', $base, $k);
if (is_array($v)) {
$this->walk($v, $path, $output);
} else {

View File

@ -417,7 +417,7 @@ class FormTest extends \PHPUnit_Framework_TestCase
public function testMultiselectSetValues()
{
$form = $this->createForm('<form><select multiple="multiple" name="multi"><option value="foo">foo</option><option value="bar">bar</option></select><input type="submit" /></form>');
$form->setValues(array('multi' => array("foo", "bar")));
$form->setValues(array('multi' => array('foo', 'bar')));
$this->assertEquals(array('multi' => array('foo', 'bar')), $form->getValues(), '->setValue() sets the values of select');
}
@ -593,6 +593,12 @@ class FormTest extends \PHPUnit_Framework_TestCase
array(),
'/foo?bar=bar&foo=foo',
),
array(
'replaces query values with the form values',
'<form action="/foo?bar=bar"><input type="text" name="bar" value="foo" /><input type="submit" /></form>',
array(),
'/foo?bar=foo',
),
array(
'returns an empty URI if the action is empty',
'<form><input type="submit" /></form>',

View File

@ -43,10 +43,9 @@ class Filesystem
$this->mkdir(dirname($targetFile));
if (!$override && is_file($targetFile) && null === parse_url($originFile, PHP_URL_HOST)) {
$doCopy = true;
if (!$override && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
$doCopy = filemtime($originFile) > filemtime($targetFile);
} else {
$doCopy = true;
}
if ($doCopy) {
@ -306,16 +305,15 @@ class Filesystem
}
}
if (!$ok) {
if (true !== @symlink($originDir, $targetDir)) {
$report = error_get_last();
if (is_array($report)) {
if ('\\' === DIRECTORY_SEPARATOR && false !== strpos($report['message'], 'error code(1314)')) {
throw new IOException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?');
}
if (!$ok && true !== @symlink($originDir, $targetDir)) {
$report = error_get_last();
if (is_array($report)) {
if ('\\' === DIRECTORY_SEPARATOR && false !== strpos($report['message'], 'error code(1314)')) {
throw new IOException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?');
}
throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
}
throw new IOException(sprintf('Failed to create symbolic link from %s to %s', $originDir, $targetDir));
}
}
@ -354,9 +352,9 @@ class Filesystem
$endPathRemainder = implode('/', array_slice($endPathArr, $index));
// Construct $endPath from traversing to the common path, then to the remaining $endPath
$relativePath = $traverser.(strlen($endPathRemainder) > 0 ? $endPathRemainder.'/' : '');
$relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
return (strlen($relativePath) === 0) ? './' : $relativePath;
return '' === $relativePath ? './' : $relativePath;
}
/**

View File

@ -392,7 +392,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
$paths[] = $file->getRelativePath();
}
$ref = array("", "", "", "", "foo", "");
$ref = array('', '', '', '', 'foo', '');
sort($ref);
sort($paths);
@ -413,7 +413,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
$paths[] = $file->getRelativePathname();
}
$ref = array("test.php", "toto", "test.py", "foo", "foo".DIRECTORY_SEPARATOR."bar.tmp", "foo bar");
$ref = array('test.php', 'toto', 'test.py', 'foo', 'foo'.DIRECTORY_SEPARATOR.'bar.tmp', 'foo bar');
sort($paths);
sort($ref);

View File

@ -194,9 +194,7 @@ class Button implements \IteratorAggregate, FormInterface
*
* This method should not be invoked.
*
* @param string $modelData
*
* @throws BadMethodCallException
* @param mixed $modelData
*/
public function setData($modelData)
{

View File

@ -2,12 +2,12 @@
/*
* 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.
*/
*
* (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\Component\Form\Extension\Core\ChoiceList;

View File

@ -1,4 +1,5 @@
<?php
/*
* This file is part of the Symfony package.
*

View File

@ -184,10 +184,10 @@ class NativeRequestHandler implements RequestHandlerInterface
unset($files[$k]);
}
foreach (array_keys($data['name']) as $key) {
foreach ($data['name'] as $key => $name) {
$files[$key] = self::fixPhpFilesArray(array(
'error' => $data['error'][$key],
'name' => $data['name'][$key],
'name' => $name,
'type' => $data['type'][$key],
'tmp_name' => $data['tmp_name'][$key],
'size' => $data['size'][$key],

Some files were not shown because too many files have changed in this diff Show More