From 73b7d8da6c151c20991b0ae2206fd10f374a56fd Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Wed, 5 Dec 2012 19:30:06 -0500 Subject: [PATCH] Issue #1834594 by effulgentsia, Rob Loach: Update dependencies (Symfony and Twig). --- core/composer.json | 18 +- core/composer.lock | 507 ++++-------- core/vendor/autoload.php | 2 +- core/vendor/composer/autoload_classmap.php | 1 + core/vendor/composer/autoload_real.php | 14 +- core/vendor/composer/installed.json | 732 +++++++----------- core/vendor/doctrine/common/composer.json | 2 +- .../Doctrine/Common/Annotations/DocLexer.php | 79 +- .../lib/Doctrine/Common/Cache/FileCache.php | 4 +- .../common/lib/Doctrine/Common/Version.php | 2 +- .../Component/ClassLoader/.gitattributes | 2 + .../Symfony/Component/ClassLoader/.gitignore | 2 + .../Component/ClassLoader/ApcClassLoader.php | 30 +- .../ClassLoader/ClassCollectionLoader.php | 58 +- .../Symfony/Component/ClassLoader/README.md | 9 +- .../Tests/ClassCollectionLoaderTest.php | 117 ++- .../Tests/ClassMapGeneratorTest.php | 14 +- .../Fixtures/Namespaced/WithComments.php | 18 + .../Tests/Fixtures/Pearlike/WithComments.php | 16 + .../Tests/UniversalClassLoaderTest.php | 8 +- .../Component/ClassLoader/Tests/bootstrap.php | 22 - .../ClassLoader/UniversalClassLoader.php | 4 + .../Component/ClassLoader/composer.json | 7 +- .../Component/ClassLoader/phpunit.xml.dist | 2 +- .../DependencyInjection/.gitattributes | 2 + .../Component/DependencyInjection/.gitignore | 2 + .../Compiler/AnalyzeServiceReferencesPass.php | 2 +- .../Compiler/CheckCircularReferencesPass.php | 2 +- .../Compiler/InlineServiceDefinitionsPass.php | 2 + .../Compiler/RepeatedPass.php | 16 +- .../ReplaceAliasByActualDefinitionPass.php | 2 + .../ResolveDefinitionTemplatesPass.php | 2 + .../Compiler/ResolveInvalidReferencesPass.php | 4 + .../ResolveParameterPlaceHoldersPass.php | 2 + .../Compiler/ServiceReferenceGraph.php | 7 +- .../DependencyInjection/Container.php | 19 + .../DependencyInjection/ContainerBuilder.php | 106 ++- .../ContainerInterface.php | 4 + .../DependencyInjection/Definition.php | 10 +- .../DefinitionDecorator.php | 6 +- .../Dumper/GraphvizDumper.php | 2 +- .../DependencyInjection/Dumper/PhpDumper.php | 22 +- .../DependencyInjection/Dumper/XmlDumper.php | 40 +- .../DependencyInjection/Dumper/YamlDumper.php | 12 +- .../DependencyInjection/Loader/FileLoader.php | 6 +- .../Loader/XmlFileLoader.php | 20 +- .../Loader/YamlFileLoader.php | 4 +- .../ParameterBag/ParameterBag.php | 8 +- .../Component/DependencyInjection/README.md | 9 +- .../Tests/ContainerTest.php | 30 +- .../Tests/Fixtures/php/services9.php | 2 +- .../Tests/ParameterBag/ParameterBagTest.php | 2 + .../DependencyInjection/Tests/bootstrap.php | 22 - .../DependencyInjection/composer.json | 12 +- .../DependencyInjection/phpunit.xml.dist | 2 +- .../Component/EventDispatcher/.gitattributes | 2 + .../Component/EventDispatcher/.gitignore | 2 + .../Component/EventDispatcher/Event.php | 6 +- .../Component/EventDispatcher/README.md | 9 +- .../EventDispatcher/Tests/bootstrap.php | 22 - .../Component/EventDispatcher/composer.json | 10 +- .../EventDispatcher/phpunit.xml.dist | 2 +- .../Component/HttpFoundation/.gitattributes | 2 + .../Component/HttpFoundation/.gitignore | 4 + .../Component/HttpFoundation/AcceptHeader.php | 172 ++++ .../HttpFoundation/AcceptHeaderItem.php | 226 ++++++ .../HttpFoundation/BinaryFileResponse.php | 259 +++++++ .../Component/HttpFoundation/CHANGELOG.md | 7 + .../Component/HttpFoundation/File/File.php | 18 +- .../HttpFoundation/File/UploadedFile.php | 17 +- .../Component/HttpFoundation/HeaderBag.php | 4 +- .../Component/HttpFoundation/README.md | 6 +- .../Component/HttpFoundation/Request.php | 267 +++++-- .../HttpFoundation/RequestMatcher.php | 38 +- .../stubs/SessionHandlerInterface.php | 2 + .../Component/HttpFoundation/Response.php | 13 +- .../HttpFoundation/ResponseHeaderBag.php | 32 +- .../Component/HttpFoundation/ServerBag.php | 2 +- .../Session/Flash/FlashBagInterface.php | 14 +- .../Storage/Handler/MongoDbSessionHandler.php | 45 +- .../Storage/Handler/PdoSessionHandler.php | 12 +- .../Session/Storage/NativeSessionStorage.php | 8 +- .../HttpFoundation/StreamedResponse.php | 4 - .../Tests/AcceptHeaderItemTest.php | 112 +++ .../HttpFoundation/Tests/AcceptHeaderTest.php | 102 +++ .../Tests/BinaryFileResponseTest.php | 124 +++ .../HttpFoundation/Tests/CookieTest.php | 17 + .../HttpFoundation/Tests/File/FileTest.php | 35 + .../Tests/File/UploadedFileTest.php | 14 + .../HttpFoundation/Tests/HeaderBagTest.php | 43 + .../HttpFoundation/Tests/JsonResponseTest.php | 72 +- .../HttpFoundation/Tests/ParameterBagTest.php | 22 + .../Tests/RedirectResponseTest.php | 25 + .../Tests/RequestMatcherTest.php | 62 +- .../HttpFoundation/Tests/RequestTest.php | 312 ++++++-- .../Tests/ResponseHeaderBagTest.php | 96 +++ .../HttpFoundation/Tests/ResponseTest.php | 97 +++ .../Attribute/NamespacedAttributeBagTest.php | 2 +- .../Tests/Session/SessionTest.php | 23 + .../Handler/MongoDbSessionHandlerTest.php | 168 +++- .../Tests/Session/Storage/MetadataBagTest.php | 8 + .../Storage/NativeSessionStorageTest.php | 2 + .../Tests/StreamedResponseTest.php | 11 +- .../HttpFoundation/Tests/bootstrap.php | 22 - .../Component/HttpFoundation/composer.json | 8 +- .../Component/HttpFoundation/phpunit.xml.dist | 2 +- .../Component/HttpKernel/.gitattributes | 2 + .../Symfony/Component/HttpKernel/.gitignore | 2 + .../Symfony/Component/HttpKernel/CHANGELOG.md | 12 + .../Symfony/Component/HttpKernel/Client.php | 7 +- .../TraceableControllerResolver.php | 66 ++ .../DataCollector/ConfigDataCollector.php | 35 +- .../DataCollector/DataCollector.php | 41 + .../DataCollector/EventDataCollector.php | 38 +- .../DataCollector/ExceptionDataCollector.php | 1 - .../DataCollector/MemoryDataCollector.php | 17 +- .../DataCollector/RequestDataCollector.php | 42 +- .../DataCollector/TimeDataCollector.php | 4 +- ...ContainerAwareTraceableEventDispatcher.php | 318 -------- .../HttpKernel/Debug/ExceptionHandler.php | 220 +++--- .../Component/HttpKernel/Debug/Stopwatch.php | 251 ------ .../HttpKernel/Debug/StopwatchEvent.php | 182 ----- .../Debug/TraceableEventDispatcher.php | 452 +++++++++++ .../HttpKernel/Event/FilterResponseEvent.php | 6 +- .../HttpKernel/Event/GetResponseEvent.php | 6 +- .../GetResponseForControllerResultEvent.php | 15 +- .../HttpKernel/Event/KernelEvent.php | 8 +- .../Exception/AccessDeniedHttpException.php | 6 +- .../Exception/BadRequestHttpException.php | 32 + .../Exception/ConflictHttpException.php | 32 + .../HttpKernel/Exception/FlattenException.php | 10 + .../Exception/GoneHttpException.php | 32 + .../Exception/LengthRequiredHttpException.php | 32 + .../MethodNotAllowedHttpException.php | 8 +- .../Exception/NotAcceptableHttpException.php | 32 + .../Exception/NotFoundHttpException.php | 6 +- .../PreconditionFailedHttpException.php | 32 + .../PreconditionRequiredHttpException.php | 33 + .../ServiceUnavailableHttpException.php | 38 + .../TooManyRequestsHttpException.php | 39 + .../Exception/UnauthorizedHttpException.php | 35 + .../UnsupportedMediaTypeHttpException.php | 32 + .../HttpKernel/HttpCache/HttpCache.php | 4 +- .../Component/HttpKernel/HttpCache/Store.php | 38 +- .../HttpKernel/HttpCache/StoreInterface.php | 11 + .../Symfony/Component/HttpKernel/Kernel.php | 73 +- .../Component/HttpKernel/KernelInterface.php | 6 +- .../Profiler/FileProfilerStorage.php | 2 +- .../Profiler/MongoDbProfilerStorage.php | 36 +- .../Profiler/PdoProfilerStorage.php | 2 +- .../Component/HttpKernel/Profiler/Profile.php | 62 +- .../HttpKernel/Profiler/Profiler.php | 33 +- .../Symfony/Component/HttpKernel/README.md | 9 +- .../Component/HttpKernel/Tests/ClientTest.php | 17 + .../DataCollector/ConfigDataCollectorTest.php | 4 +- .../DataCollector/EventDataCollectorTest.php | 45 -- .../RequestDataCollectorTest.php | 129 +++ ...ainerAwareTraceableEventDispatcherTest.php | 80 -- .../Tests/Debug/ExceptionHandlerTest.php | 4 +- .../Tests/Debug/StopwatchEventTest.php | 152 ---- .../HttpKernel/Tests/Debug/StopwatchTest.php | 120 --- .../Debug/TraceableEventDispatcherTest.php | 201 +++++ .../Tests/Exception/FlattenExceptionTest.php | 109 ++- .../HttpKernel/Tests/Fixtures/TestClient.php | 7 +- .../HttpKernel/Tests/HttpCache/StoreTest.php | 25 + .../Tests/Profiler/Mock/RedisMock.php | 2 +- .../Profiler/MongoDbProfilerStorageTest.php | 48 ++ .../Component/HttpKernel/Tests/bootstrap.php | 22 - .../Component/HttpKernel/composer.json | 37 +- .../Component/HttpKernel/phpunit.xml.dist | 2 +- .../Symfony/Component/Process/.gitattributes | 2 + .../Symfony/Component/Process/Process.php | 171 +++- .../Process/Tests/PhpExecutableFinderTest.php | 64 -- .../Process/Tests/ProcessBuilderTest.php | 108 --- .../Tests/ProcessFailedExceptionTest.php | 75 -- .../Component/Process/Tests/ProcessTest.php | 202 ----- .../Process/Tests/ProcessTestHelper.php | 63 -- .../Component/Process/Tests/bootstrap.php | 18 - .../Component/Process/phpunit.xml.dist | 28 - .../Symfony/Component/Routing/.gitattributes | 2 + .../Symfony/Component/Routing/.gitignore | 2 + .../Component/Routing/Annotation/Route.php | 13 +- .../Symfony/Component/Routing/CHANGELOG.md | 27 +- .../Component/Routing/CompiledRoute.php | 65 +- .../Exception/MethodNotAllowedException.php | 10 +- .../ConfigurableRequirementsInterface.php | 31 +- .../Generator/Dumper/GeneratorDumper.php | 3 + .../Generator/Dumper/PhpGeneratorDumper.php | 7 +- .../Routing/Generator/UrlGenerator.php | 105 ++- .../Routing/Loader/AnnotationClassLoader.php | 50 +- .../Loader/AnnotationDirectoryLoader.php | 4 +- .../Routing/Loader/AnnotationFileLoader.php | 10 +- .../Routing/Loader/ClosureLoader.php | 4 +- .../Routing/Loader/PhpFileLoader.php | 4 +- .../Routing/Loader/XmlFileLoader.php | 39 +- .../Routing/Loader/YamlFileLoader.php | 14 +- .../Loader/schema/routing/routing-1.0.xsd | 49 +- .../Routing/Matcher/ApacheUrlMatcher.php | 49 +- .../Matcher/Dumper/ApacheMatcherDumper.php | 202 +++-- .../Matcher/Dumper/DumperCollection.php | 159 ++++ .../Matcher/Dumper/DumperPrefixCollection.php | 106 +++ .../Routing/Matcher/Dumper/DumperRoute.php | 64 ++ .../Routing/Matcher/Dumper/MatcherDumper.php | 3 + .../Matcher/Dumper/PhpMatcherDumper.php | 187 ++++- .../RedirectableUrlMatcherInterface.php | 6 +- .../Component/Routing/Matcher/UrlMatcher.php | 46 +- .../Symfony/Component/Routing/README.md | 9 +- .../Component/Routing/RequestContext.php | 7 +- .../Symfony/Component/Routing/Route.php | 131 +++- .../Component/Routing/RouteCollection.php | 87 ++- .../Component/Routing/RouteCompiler.php | 174 ++++- .../Symfony/Component/Routing/Router.php | 47 +- .../Routing/Tests/Annotation/RouteTest.php | 3 +- .../Routing/Tests/CompiledRouteTest.php | 10 +- .../Fixtures/AnnotatedClasses/BarClass.php | 19 + .../Tests/Fixtures/dumper/url_matcher1.apache | 150 +++- .../Tests/Fixtures/dumper/url_matcher1.php | 281 ++++--- .../Tests/Fixtures/dumper/url_matcher2.apache | 2 +- .../Tests/Fixtures/dumper/url_matcher2.php | 291 ++++--- .../Tests/Fixtures/dumper/url_matcher3.php | 6 +- .../Tests/Fixtures/special_route_name.yml | 2 + .../Routing/Tests/Fixtures/validpattern.php | 5 +- .../Routing/Tests/Fixtures/validpattern.xml | 3 +- .../Routing/Tests/Fixtures/validpattern.yml | 6 +- .../Routing/Tests/Fixtures/validresource.xml | 4 +- .../Routing/Tests/Fixtures/validresource.yml | 11 +- .../Tests/Generator/UrlGeneratorTest.php | 193 ++++- .../Loader/AnnotationClassLoaderTest.php | 51 +- .../Loader/AnnotationDirectoryLoaderTest.php | 8 +- .../Tests/Loader/PhpFileLoaderTest.php | 4 + .../Tests/Loader/XmlFileLoaderTest.php | 10 +- .../Tests/Loader/YamlFileLoaderTest.php | 20 +- .../Tests/Matcher/ApacheUrlMatcherTest.php | 60 +- .../Dumper/ApacheMatcherDumperTest.php | 65 ++ .../Matcher/Dumper/DumperCollectionTest.php | 24 + .../Dumper/DumperPrefixCollectionTest.php | 114 +++ .../Matcher/Dumper/PhpMatcherDumperTest.php | 54 +- .../Routing/Tests/Matcher/UrlMatcherTest.php | 130 ++++ .../Routing/Tests/RouteCollectionTest.php | 43 +- .../Routing/Tests/RouteCompilerTest.php | 165 +++- .../Component/Routing/Tests/RouteTest.php | 17 +- .../Component/Routing/Tests/bootstrap.php | 22 - .../Symfony/Component/Routing/composer.json | 14 +- .../Component/Routing/phpunit.xml.dist | 2 +- .../Component/Serializer/.gitattributes | 2 + .../Symfony/Component/Serializer/.gitignore | 4 + .../Serializer/Encoder/DecoderInterface.php | 1 + .../Serializer/Encoder/EncoderInterface.php | 1 + .../Serializer/Encoder/XmlEncoder.php | 3 + .../Normalizer/CustomNormalizer.php | 2 + .../Normalizer/DenormalizerInterface.php | 2 + .../Normalizer/GetSetMethodNormalizer.php | 9 +- .../Normalizer/NormalizableInterface.php | 1 + .../Normalizer/NormalizerInterface.php | 2 + .../Symfony/Component/Serializer/README.md | 4 +- .../Component/Serializer/Serializer.php | 2 + .../Serializer/SerializerInterface.php | 3 + .../Component/Serializer/Tests/bootstrap.php | 18 - .../Component/Serializer/composer.json | 4 +- .../Component/Serializer/phpunit.xml.dist | 2 +- .../Symfony/Component/Yaml/.gitattributes | 2 + .../yaml/Symfony/Component/Yaml/.gitignore | 4 + .../yaml/Symfony/Component/Yaml/Escaper.php | 4 +- .../Yaml/Exception/DumpException.php | 2 +- .../Yaml/Exception/ParseException.php | 2 +- .../Yaml/Exception/RuntimeException.php | 23 + .../yaml/Symfony/Component/Yaml/Parser.php | 6 +- .../yaml/Symfony/Component/Yaml/README.md | 4 +- .../Yaml/Tests/Fixtures/escapedCharacters.yml | 8 + .../Component/Yaml/Tests/bootstrap.php | 18 - .../yaml/Symfony/Component/Yaml/Unescaper.php | 4 +- .../yaml/Symfony/Component/Yaml/composer.json | 4 +- .../Symfony/Component/Yaml/phpunit.xml.dist | 2 +- core/vendor/twig/twig/.gitignore | 2 + core/vendor/twig/twig/CHANGELOG | 59 ++ core/vendor/twig/twig/composer.json | 2 +- core/vendor/twig/twig/doc/advanced.rst | 65 +- core/vendor/twig/twig/doc/api.rst | 149 +++- core/vendor/twig/twig/doc/filters/date.rst | 41 +- .../twig/twig/doc/filters/date_modify.rst | 18 + core/vendor/twig/twig/doc/filters/escape.rst | 54 +- core/vendor/twig/twig/doc/filters/index.rst | 3 + .../twig/twig/doc/filters/number_format.rst | 4 +- core/vendor/twig/twig/doc/filters/split.rst | 47 ++ core/vendor/twig/twig/doc/functions/index.rst | 1 + .../doc/functions/template_from_string.rst | 27 + core/vendor/twig/twig/doc/intro.rst | 5 + core/vendor/twig/twig/doc/recipes.rst | 138 +++- core/vendor/twig/twig/doc/tags/extends.rst | 85 +- core/vendor/twig/twig/doc/tags/import.rst | 28 +- core/vendor/twig/twig/doc/tags/macro.rst | 34 +- core/vendor/twig/twig/doc/tags/sandbox.rst | 2 +- core/vendor/twig/twig/doc/templates.rst | 76 +- core/vendor/twig/twig/doc/tests/empty.rst | 2 +- core/vendor/twig/twig/ext/twig/php_twig.h | 20 +- core/vendor/twig/twig/ext/twig/twig.c | 310 ++++---- core/vendor/twig/twig/lib/Twig/Autoloader.php | 4 +- core/vendor/twig/twig/lib/Twig/Compiler.php | 18 +- .../twig/twig/lib/Twig/CompilerInterface.php | 4 +- .../vendor/twig/twig/lib/Twig/Environment.php | 6 +- core/vendor/twig/twig/lib/Twig/Error.php | 52 +- .../twig/twig/lib/Twig/Error/Loader.php | 12 + .../twig/lib/Twig/ExistsLoaderInterface.php | 28 + .../twig/twig/lib/Twig/ExpressionParser.php | 23 +- .../twig/twig/lib/Twig/Extension/Core.php | 257 +++++- .../twig/twig/lib/Twig/Extension/Debug.php | 2 +- .../twig/twig/lib/Twig/Extension/Escaper.php | 1 - .../twig/lib/Twig/Extension/StringLoader.php | 64 ++ .../twig/twig/lib/Twig/ExtensionInterface.php | 18 +- .../twig/twig/lib/Twig/FilterInterface.php | 16 +- .../twig/twig/lib/Twig/Function/Node.php | 2 +- .../twig/twig/lib/Twig/FunctionInterface.php | 12 +- .../twig/twig/lib/Twig/LexerInterface.php | 2 +- .../twig/twig/lib/Twig/Loader/Array.php | 27 +- .../twig/twig/lib/Twig/Loader/Chain.php | 72 +- .../twig/twig/lib/Twig/Loader/Filesystem.php | 117 ++- .../twig/twig/lib/Twig/Loader/String.php | 31 +- .../twig/twig/lib/Twig/LoaderInterface.php | 6 +- core/vendor/twig/twig/lib/Twig/Node.php | 6 +- .../twig/lib/Twig/Node/Expression/Filter.php | 2 +- .../lib/Twig/Node/Expression/Function.php | 2 +- .../twig/lib/Twig/Node/Expression/GetAttr.php | 4 +- .../lib/Twig/Node/Expression/MethodCall.php | 4 + .../twig/lib/Twig/Node/Expression/Name.php | 18 +- .../twig/lib/Twig/Node/Expression/Test.php | 2 +- .../lib/Twig/Node/Expression/Test/Defined.php | 2 +- core/vendor/twig/twig/lib/Twig/Node/Macro.php | 8 +- .../twig/lib/Twig/Node/SandboxedModule.php | 2 +- .../twig/twig/lib/Twig/NodeInterface.php | 6 +- .../twig/lib/Twig/NodeVisitor/Escaper.php | 8 + .../lib/Twig/NodeVisitor/SafeAnalysis.php | 14 + .../twig/lib/Twig/NodeVisitor/Sandbox.php | 13 - .../twig/lib/Twig/NodeVisitorInterface.php | 6 +- core/vendor/twig/twig/lib/Twig/Parser.php | 63 +- .../twig/twig/lib/Twig/ParserInterface.php | 2 +- .../Twig/Sandbox/SecurityPolicyInterface.php | 6 +- core/vendor/twig/twig/lib/Twig/Template.php | 32 +- .../twig/twig/lib/Twig/TemplateInterface.php | 6 +- .../lib/Twig/Test/IntegrationTestCase.php | 155 ++++ .../Twig/Test/NodeTestCase.php} | 2 +- .../twig/twig/lib/Twig/TestInterface.php | 2 +- core/vendor/twig/twig/lib/Twig/Token.php | 8 +- .../twig/lib/Twig/TokenParser/AutoEscape.php | 15 +- .../twig/twig/lib/Twig/TokenParser/Block.php | 4 +- .../twig/lib/Twig/TokenParser/Extends.php | 4 +- .../twig/twig/lib/Twig/TokenParser/From.php | 2 +- .../twig/twig/lib/Twig/TokenParser/If.php | 13 +- .../twig/twig/lib/Twig/TokenParser/Import.php | 2 + .../twig/twig/lib/Twig/TokenParser/Macro.php | 13 +- .../twig/lib/Twig/TokenParser/Sandbox.php | 13 + .../twig/twig/lib/Twig/TokenParser/Set.php | 4 +- .../twig/twig/lib/Twig/TokenParser/Use.php | 5 +- .../twig/twig/lib/Twig/TokenParserBroker.php | 4 +- .../lib/Twig/TokenParserBrokerInterface.php | 6 +- .../twig/lib/Twig/TokenParserInterface.php | 6 +- .../vendor/twig/twig/lib/Twig/TokenStream.php | 4 +- .../twig/test/Twig/Tests/EnvironmentTest.php | 2 +- .../twig/twig/test/Twig/Tests/ErrorTest.php | 61 +- .../test/Twig/Tests/Extension/SandboxTest.php | 15 +- .../twig/test/Twig/Tests/FileCachingTest.php | 2 +- .../test/Twig/Tests/Fixtures/errors/base.html | 1 + .../Twig/Tests/Fixtures/errors/index.html | 7 + .../Tests/Fixtures/expressions/bitwise.test | 2 + .../Fixtures/expressions/method_call.test | 2 +- .../Tests/Fixtures/expressions/postfix.test | 5 +- .../Twig/Tests/Fixtures/filters/date.test | 9 +- .../Tests/Fixtures/filters/date_interval.test | 11 +- .../Tests/Fixtures/filters/date_modify.test | 14 + .../Twig/Tests/Fixtures/filters/default.test | 4 +- .../Tests/Fixtures/filters/force_escape.test | 2 +- .../Twig/Tests/Fixtures/filters/join.test | 2 +- .../Twig/Tests/Fixtures/filters/merge.test | 4 +- .../Twig/Tests/Fixtures/filters/split.test | 18 + .../Tests/Fixtures/functions/attribute.test | 2 +- .../Twig/Tests/Fixtures/functions/dump.test | 2 + .../functions/template_from_string.test | 11 + .../Tests/Fixtures/macros/nested_calls.test | 18 + .../Fixtures/macros/reserved_variables.test | 14 + .../Fixtures/tags/autoescape/functions.test | 2 +- .../Fixtures/tags/autoescape/strategy.test | 4 +- .../Tests/Fixtures/tags/autoescape/type.test | 10 +- .../Tests/Fixtures/tags/embed/nested.test | 42 + .../Tests/Fixtures/tags/include/missing.test | 8 + .../Fixtures/tags/include/missing_nested.test | 16 + .../Twig/Tests/Fixtures/tags/macro/basic.test | 6 +- .../Fixtures/tags/macro/endmacro_name.test | 6 +- .../Fixtures/tags/macro/special_chars.test | 4 +- .../Twig/Tests/Fixtures/tests/constant.test | 4 +- .../Twig/Tests/Fixtures/tests/defined.test | 4 +- .../Tests/Fixtures/tests/in_with_objects.test | 19 + .../test/Twig/Tests/Loader/FilesystemTest.php | 38 + .../Tests/Loader/Fixtures/named/index.html | 1 + .../Loader/Fixtures/named_bis/index.html | 1 + .../Loader/Fixtures/named_final/index.html | 1 + .../Loader/Fixtures/named_ter/index.html | 1 + .../Tests/Loader/Fixtures/normal/index.html | 1 + .../Loader/Fixtures/normal_bis/index.html | 1 + .../Loader/Fixtures/normal_final/index.html | 1 + .../Loader/Fixtures/normal_ter/index.html | 1 + .../test/Twig/Tests/NativeExtensionTest.php | 29 + .../test/Twig/Tests/Node/AutoEscapeTest.php | 14 +- .../Twig/Tests/Node/BlockReferenceTest.php | 12 +- .../twig/test/Twig/Tests/Node/BlockTest.php | 13 +- .../twig/twig/test/Twig/Tests/Node/DoTest.php | 14 +- .../Twig/Tests/Node/Expression/ArrayTest.php | 18 +- .../Tests/Node/Expression/AssignNameTest.php | 8 +- .../Tests/Node/Expression/Binary/AddTest.php | 16 +- .../Tests/Node/Expression/Binary/AndTest.php | 16 +- .../Node/Expression/Binary/ConcatTest.php | 16 +- .../Tests/Node/Expression/Binary/DivTest.php | 16 +- .../Node/Expression/Binary/FloorDivTest.php | 16 +- .../Tests/Node/Expression/Binary/ModTest.php | 16 +- .../Tests/Node/Expression/Binary/MulTest.php | 16 +- .../Tests/Node/Expression/Binary/OrTest.php | 16 +- .../Tests/Node/Expression/Binary/SubTest.php | 16 +- .../Tests/Node/Expression/ConditionalTest.php | 20 +- .../Tests/Node/Expression/ConstantTest.php | 8 +- .../Twig/Tests/Node/Expression/FilterTest.php | 45 +- .../Tests/Node/Expression/FunctionTest.php | 18 +- .../Tests/Node/Expression/GetAttrTest.php | 34 +- .../Twig/Tests/Node/Expression/NameTest.php | 14 +- .../Twig/Tests/Node/Expression/ParentTest.php | 8 +- .../Twig/Tests/Node/Expression/TestTest.php | 20 +- .../Tests/Node/Expression/Unary/NegTest.php | 12 +- .../Tests/Node/Expression/Unary/NotTest.php | 12 +- .../Tests/Node/Expression/Unary/PosTest.php | 12 +- .../twig/test/Twig/Tests/Node/ForTest.php | 68 +- .../twig/twig/test/Twig/Tests/Node/IfTest.php | 49 +- .../twig/test/Twig/Tests/Node/ImportTest.php | 22 +- .../twig/test/Twig/Tests/Node/IncludeTest.php | 54 +- .../twig/test/Twig/Tests/Node/MacroTest.php | 25 +- .../twig/test/Twig/Tests/Node/ModuleTest.php | 26 +- .../twig/test/Twig/Tests/Node/PrintTest.php | 10 +- .../twig/test/Twig/Tests/Node/SandboxTest.php | 13 +- .../Twig/Tests/Node/SandboxedModuleTest.php | 21 +- .../Twig/Tests/Node/SandboxedPrintTest.php | 9 +- .../twig/test/Twig/Tests/Node/SetTest.php | 48 +- .../test/Twig/Tests/Node/SpacelessTest.php | 13 +- .../twig/test/Twig/Tests/Node/TextTest.php | 8 +- .../twig/twig/test/Twig/Tests/ParserTest.php | 78 +- .../twig/test/Twig/Tests/TemplateTest.php | 139 +++- .../twig/test/Twig/Tests/TokenStreamTest.php | 18 +- .../twig/test/Twig/Tests/escapingTest.php | 320 ++++++++ .../twig/test/Twig/Tests/integrationTest.php | 135 +--- 444 files changed, 11223 insertions(+), 5499 deletions(-) create mode 100644 core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/.gitattributes create mode 100644 core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithComments.php create mode 100644 core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/Pearlike/WithComments.php delete mode 100644 core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/bootstrap.php create mode 100644 core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitattributes delete mode 100644 core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/bootstrap.php create mode 100644 core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitattributes delete mode 100644 core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/bootstrap.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitattributes create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php create mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php delete mode 100644 core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/bootstrap.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitattributes create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php delete mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php delete mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/Stopwatch.php delete mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php delete mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/EventDataCollectorTest.php delete mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ContainerAwareTraceableEventDispatcherTest.php delete mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchEventTest.php delete mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchTest.php create mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php delete mode 100644 core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/bootstrap.php create mode 100644 core/vendor/symfony/process/Symfony/Component/Process/.gitattributes delete mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php delete mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php delete mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php delete mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTest.php delete mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php delete mode 100644 core/vendor/symfony/process/Symfony/Component/Process/Tests/bootstrap.php delete mode 100644 core/vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/.gitattributes create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php create mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php delete mode 100644 core/vendor/symfony/routing/Symfony/Component/Routing/Tests/bootstrap.php create mode 100644 core/vendor/symfony/serializer/Symfony/Component/Serializer/.gitattributes create mode 100644 core/vendor/symfony/serializer/Symfony/Component/Serializer/.gitignore delete mode 100644 core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/bootstrap.php create mode 100644 core/vendor/symfony/yaml/Symfony/Component/Yaml/.gitattributes create mode 100644 core/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore create mode 100644 core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php delete mode 100644 core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/bootstrap.php create mode 100644 core/vendor/twig/twig/.gitignore create mode 100644 core/vendor/twig/twig/doc/filters/date_modify.rst create mode 100644 core/vendor/twig/twig/doc/filters/split.rst create mode 100644 core/vendor/twig/twig/doc/functions/template_from_string.rst create mode 100644 core/vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php create mode 100644 core/vendor/twig/twig/lib/Twig/Extension/StringLoader.php create mode 100644 core/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php rename core/vendor/twig/twig/{test/Twig/Tests/Node/TestCase.php => lib/Twig/Test/NodeTestCase.php} (95%) create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/base.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_modify.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/nested_calls.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/reserved_variables.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/nested.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing_nested.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in_with_objects.test create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_bis/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_final/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_ter/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_bis/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_final/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_ter/index.html create mode 100644 core/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php create mode 100644 core/vendor/twig/twig/test/Twig/Tests/escapingTest.php diff --git a/core/composer.json b/core/composer.json index fd0e942dea60..1fc8db9199b9 100644 --- a/core/composer.json +++ b/core/composer.json @@ -3,15 +3,15 @@ "description": "Drupal is an open source content management platform powering millions of websites and applications.", "license": "GPL-2.0+", "require": { - "symfony/class-loader": "2.1.*", - "symfony/dependency-injection": "2.1.*", - "symfony/event-dispatcher": "2.1.*", - "symfony/http-foundation": "2.1.*", - "symfony/http-kernel": "2.1.*", - "symfony/routing": "2.1.*", - "symfony/serializer": "2.1.*", - "symfony/yaml": "2.1.*", - "twig/twig": "1.8.*", + "symfony/class-loader": "<2.4@dev", + "symfony/dependency-injection": "<2.4@dev", + "symfony/event-dispatcher": "<2.4@dev", + "symfony/http-foundation": "<2.4@dev", + "symfony/http-kernel": "<2.4@dev", + "symfony/routing": "<2.4@dev", + "symfony/serializer": "<2.4@dev", + "symfony/yaml": "<2.4@dev", + "twig/twig": "1.*", "doctrine/common": "2.3.*", "guzzle/http": "3.*", "kriswallsmith/assetic": "1.1.*" diff --git a/core/composer.lock b/core/composer.lock index fa87f0eba491..94dc922f5389 100644 --- a/core/composer.lock +++ b/core/composer.lock @@ -1,24 +1,24 @@ { - "hash": "90e0986bd0957088356cb234e33f6332", + "hash": "1a2c52fedf8d9a23498df41568d82ff4", "packages": [ { "name": "doctrine/common", - "version": "2.3.0-RC2", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/common", - "reference": "2.3.0-RC2" + "reference": "2.3.0" }, "dist": { "type": "zip", - "url": "https://github.com/doctrine/common/zipball/2.3.0-RC2", - "reference": "2.3.0-RC2", + "url": "https://github.com/doctrine/common/zipball/2.3.0", + "reference": "2.3.0", "shasum": "" }, "require": { "php": ">=5.3.2" }, - "time": "2012-08-29 13:06:32", + "time": "2012-09-19 22:55:18", "type": "library", "extra": { "branch-alias": { @@ -31,6 +31,7 @@ "Doctrine\\Common": "lib/" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -38,26 +39,20 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/", - "role": null + "homepage": "http://www.jwage.com/" }, { "name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com", - "homepage": null, - "role": null + "homepage": "http://www.instaclick.com" }, { "name": "Roman Borschel", - "email": "roman@code-factory.org", - "homepage": null, - "role": null + "email": "roman@code-factory.org" }, { "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de", - "homepage": null, - "role": null + "email": "kontakt@beberlei.de" }, { "name": "Johannes Schmitt", @@ -76,178 +71,6 @@ "persistence" ] }, - { - "name": "guzzle/common", - "version": "v3.0.5", - "target-dir": "Guzzle/Common", - "source": { - "type": "git", - "url": "git://github.com/guzzle/common.git", - "reference": "v3.0.5" - }, - "dist": { - "type": "zip", - "url": "https://github.com/guzzle/common/archive/v3.0.5.zip", - "reference": "v3.0.5", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "symfony/event-dispatcher": "2.1.*" - }, - "time": "2012-11-19 00:15:33", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Guzzle\\Common": "" - } - }, - "license": [ - "MIT" - ], - "description": "Common libraries used by Guzzle", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "event", - "exception", - "common", - "collection" - ] - }, - { - "name": "guzzle/http", - "version": "v3.0.5", - "target-dir": "Guzzle/Http", - "source": { - "type": "git", - "url": "git://github.com/guzzle/http.git", - "reference": "v3.0.5" - }, - "dist": { - "type": "zip", - "url": "https://github.com/guzzle/http/archive/v3.0.5.zip", - "reference": "v3.0.5", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "guzzle/common": "self.version", - "guzzle/parser": "self.version", - "guzzle/stream": "self.version" - }, - "time": "2012-11-18 05:28:55", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Guzzle\\Http": "" - } - }, - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "HTTP libraries used by Guzzle", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "curl", - "http", - "http client", - "client", - "Guzzle" - ] - }, - { - "name": "guzzle/parser", - "version": "v3.0.5", - "target-dir": "Guzzle/Parser", - "source": { - "type": "git", - "url": "git://github.com/guzzle/parser.git", - "reference": "v3.0.5" - }, - "dist": { - "type": "zip", - "url": "https://github.com/guzzle/parser/archive/v3.0.5.zip", - "reference": "v3.0.5", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "time": "2012-11-19 00:07:13", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Guzzle\\Parser": "" - } - }, - "license": [ - "MIT" - ], - "description": "Interchangeable parsers used by Guzzle", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "http", - "url", - "message", - "cookie", - "URI Template" - ] - }, - { - "name": "guzzle/stream", - "version": "v3.0.5", - "target-dir": "Guzzle/Stream", - "source": { - "type": "git", - "url": "https://github.com/guzzle/stream", - "reference": "v3.0.5" - }, - "dist": { - "type": "zip", - "url": "https://github.com/guzzle/stream/archive/v3.0.5.zip", - "reference": "v3.0.5", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "guzzle/common": "self.version" - }, - "time": "2012-11-11 23:54:57", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Guzzle\\Stream": "" - } - }, - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle stream wrapper component", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "stream", - "Guzzle", - "component" - ] - }, { "name": "kriswallsmith/assetic", "version": "v1.1.0-alpha1", @@ -311,53 +134,50 @@ }, { "name": "symfony/class-loader", - "version": "v2.1.0-RC2", + "version": "dev-master", "target-dir": "Symfony/Component/ClassLoader", "source": { "type": "git", "url": "https://github.com/symfony/ClassLoader", - "reference": "v2.1.0-RC2" + "reference": "329e3c07fd7222160c647013d4dc936a76743ff6" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/ClassLoader/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/ClassLoader/archive/329e3c07fd7222160c647013d4dc936a76743ff6.zip", + "reference": "329e3c07fd7222160c647013d4dc936a76743ff6", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/finder": "2.1.*" + "symfony/finder": "2.2.*" }, - "time": "2012-08-27 14:51:49", + "time": "2012-11-19 12:58:52", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\ClassLoader": "" + "Symfony\\Component\\ClassLoader\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony ClassLoader Component", @@ -365,58 +185,55 @@ }, { "name": "symfony/dependency-injection", - "version": "v2.1.0-RC2", + "version": "dev-master", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection", - "reference": "v2.1.0-RC2" + "reference": "e2713da6f3713eba1bc26dfeeaa7aefde8914676" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/DependencyInjection/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/DependencyInjection/archive/e2713da6f3713eba1bc26dfeeaa7aefde8914676.zip", + "reference": "e2713da6f3713eba1bc26dfeeaa7aefde8914676", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/yaml": "2.1.*", - "symfony/config": "2.1.*" + "symfony/yaml": "2.2.*", + "symfony/config": "2.2.*" }, "suggest": { - "symfony/yaml": "v2.1.0-RC2", - "symfony/config": "v2.1.0-RC2" + "symfony/yaml": "2.2.*", + "symfony/config": "2.2.*" }, - "time": "2012-08-28 06:54:42", + "time": "2012-11-19 12:58:52", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\DependencyInjection": "" + "Symfony\\Component\\DependencyInjection\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony DependencyInjection Component", @@ -424,57 +241,54 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.1.0-RC2", + "version": "dev-master", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher", - "reference": "v2.1.0-RC2" + "reference": "eb290a447c0af5bea0d3de5d95d498afd8c82f89" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/EventDispatcher/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/EventDispatcher/archive/eb290a447c0af5bea0d3de5d95d498afd8c82f89.zip", + "reference": "eb290a447c0af5bea0d3de5d95d498afd8c82f89", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": "2.1.*" + "symfony/dependency-injection": "2.2.*" }, "suggest": { - "symfony/dependency-injection": "v2.1.0-RC2", - "symfony/http-kernel": "v2.1.0-RC2" + "symfony/dependency-injection": "2.2.*", + "symfony/http-kernel": "2.2.*" }, - "time": "2012-08-22 12:48:41", + "time": "2012-11-13 14:08:04", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\EventDispatcher": "" + "Symfony\\Component\\EventDispatcher\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony EventDispatcher Component", @@ -482,51 +296,50 @@ }, { "name": "symfony/http-foundation", - "version": "v2.1.0-RC2", + "version": "dev-master", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation", - "reference": "v2.1.0-RC2" + "reference": "c209d2d5b6c99121d4f3144a41e449200f4c1477" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/HttpFoundation/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/HttpFoundation/archive/c209d2d5b6c99121d4f3144a41e449200f4c1477.zip", + "reference": "c209d2d5b6c99121d4f3144a41e449200f4c1477", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-22 12:48:41", + "time": "2012-12-03 13:31:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\HttpFoundation": "", - "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" - } + "Symfony\\Component\\HttpFoundation\\": "" + }, + "classmap": [ + "Symfony/Component/HttpFoundation/Resources/stubs" + ] }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony HttpFoundation Component", @@ -534,70 +347,68 @@ }, { "name": "symfony/http-kernel", - "version": "v2.1.0-RC2", + "version": "dev-master", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel", - "reference": "v2.1.0-RC2" + "reference": "b8d175c14bdf4eb9771690eae9718673dcca8408" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/HttpKernel/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/HttpKernel/archive/b8d175c14bdf4eb9771690eae9718673dcca8408.zip", + "reference": "b8d175c14bdf4eb9771690eae9718673dcca8408", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/event-dispatcher": "2.1.*", - "symfony/http-foundation": "2.1.*" + "symfony/event-dispatcher": "2.2.*", + "symfony/http-foundation": "2.2.*" }, "require-dev": { - "symfony/browser-kit": "2.1.*", - "symfony/class-loader": "2.1.*", - "symfony/config": "2.1.*", - "symfony/console": "2.1.*", - "symfony/dependency-injection": "2.1.*", - "symfony/finder": "2.1.*", - "symfony/process": "2.1.*", - "symfony/routing": "2.1.*" + "symfony/browser-kit": "2.2.*", + "symfony/class-loader": "2.2.*", + "symfony/config": "2.2.*", + "symfony/console": "2.2.*", + "symfony/dependency-injection": "2.2.*", + "symfony/finder": "2.2.*", + "symfony/process": "2.2.*", + "symfony/routing": "2.2.*", + "symfony/stopwatch": "2.2.*" }, "suggest": { - "symfony/browser-kit": "v2.1.0-RC2", - "symfony/class-loader": "v2.1.0-RC2", - "symfony/config": "v2.1.0-RC2", - "symfony/console": "v2.1.0-RC2", - "symfony/dependency-injection": "v2.1.0-RC2", - "symfony/finder": "v2.1.0-RC2" - }, - "time": "2012-08-28 07:00:18", + "symfony/browser-kit": "2.2.*", + "symfony/class-loader": "2.2.*", + "symfony/config": "2.2.*", + "symfony/console": "2.2.*", + "symfony/dependency-injection": "2.2.*", + "symfony/finder": "2.2.*" + }, + "time": "2012-11-24 12:13:43", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\HttpKernel": "" + "Symfony\\Component\\HttpKernel\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony HttpKernel Component", @@ -605,23 +416,23 @@ }, { "name": "symfony/process", - "version": "v2.1.0-RC2", + "version": "v2.1.4", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process", - "reference": "v2.1.0-RC2" + "reference": "v2.1.4" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Process/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/Process/archive/v2.1.4.zip", + "reference": "v2.1.4", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-26 06:13:51", + "time": "2012-11-19 20:53:52", "type": "library", "extra": { "branch-alias": { @@ -634,6 +445,7 @@ "Symfony\\Component\\Process": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -652,61 +464,58 @@ }, { "name": "symfony/routing", - "version": "v2.1.0-RC2", + "version": "dev-master", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing", - "reference": "v2.1.0-RC2" + "reference": "de5f6ded706bf50922c89864693c60793d21e935" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Routing/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/Routing/archive/de5f6ded706bf50922c89864693c60793d21e935.zip", + "reference": "de5f6ded706bf50922c89864693c60793d21e935", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/config": "2.1.*", - "symfony/yaml": "2.1.*", - "symfony/http-kernel": "2.1.*", - "doctrine/common": ">=2.2,<2.4-dev" + "doctrine/common": ">=2.2,<2.4-dev", + "symfony/config": "2.2.*", + "symfony/yaml": "2.2.*", + "symfony/http-kernel": "2.2.*" }, "suggest": { - "symfony/config": "v2.1.0-RC2", - "symfony/yaml": "v2.1.0-RC2", - "doctrine/common": ">=2.2,<2.4-dev" + "doctrine/common": ">=2.2,<2.4-dev", + "symfony/config": "2.2.*", + "symfony/yaml": "2.2.*" }, - "time": "2012-08-28 06:54:42", + "time": "2012-12-03 22:11:37", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\Routing": "" + "Symfony\\Component\\Routing\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony Routing Component", @@ -714,35 +523,36 @@ }, { "name": "symfony/serializer", - "version": "v2.1.2", + "version": "dev-master", "target-dir": "Symfony/Component/Serializer", "source": { "type": "git", "url": "https://github.com/symfony/Serializer", - "reference": "v2.1.2" + "reference": "60abc7e72a5198192c42fc07bb8c1e3082e7229e" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Serializer/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/Serializer/archive/60abc7e72a5198192c42fc07bb8c1e3082e7229e.zip", + "reference": "60abc7e72a5198192c42fc07bb8c1e3082e7229e", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-28 00:54:42", + "time": "2012-11-17 17:07:16", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\Serializer": "" + "Symfony\\Component\\Serializer\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -761,50 +571,47 @@ }, { "name": "symfony/yaml", - "version": "v2.1.0-RC2", + "version": "dev-master", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml", - "reference": "v2.1.0-RC2" + "reference": "bed4fddc24392513e01b32a78d600b1272ed9a6c" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Yaml/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/Yaml/archive/bed4fddc24392513e01b32a78d600b1272ed9a6c.zip", + "reference": "bed4fddc24392513e01b32a78d600b1272ed9a6c", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-22 12:48:41", + "time": "2012-11-13 14:08:04", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\Yaml": "" + "Symfony\\Component\\Yaml\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony Yaml Component", @@ -812,26 +619,26 @@ }, { "name": "twig/twig", - "version": "v1.8.3", + "version": "v1.11.1", "source": { "type": "git", "url": "git://github.com/fabpot/Twig.git", - "reference": "v1.8.3" + "reference": "v1.11.1" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Twig/zipball/v1.8.3", - "reference": "v1.8.3", + "url": "https://github.com/fabpot/Twig/archive/v1.11.1.zip", + "reference": "v1.11.1", "shasum": "" }, "require": { "php": ">=5.2.4" }, - "time": "2012-06-18 18:48:16", + "time": "2012-11-11 17:17:59", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.11-dev" } }, "installation-source": "dist", @@ -840,21 +647,18 @@ "Twig_": "lib/" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "homepage": null, - "role": null + "email": "armin.ronacher@active-4.com" } ], "description": "Twig, the flexible, fast, and secure template language for PHP", @@ -869,7 +673,14 @@ ], "minimum-stability": "alpha", - "stability-flags": [ - - ] + "stability-flags": { + "symfony/class-loader": 20, + "symfony/dependency-injection": 20, + "symfony/event-dispatcher": 20, + "symfony/http-foundation": 20, + "symfony/http-kernel": 20, + "symfony/routing": 20, + "symfony/serializer": 20, + "symfony/yaml": 20 + } } diff --git a/core/vendor/autoload.php b/core/vendor/autoload.php index 004ba3a81d18..9cf42c1e7254 100644 --- a/core/vendor/autoload.php +++ b/core/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit::getLoader(); +return ComposerAutoloaderInitac017267abab05dbc458e3a320f5ad98::getLoader(); diff --git a/core/vendor/composer/autoload_classmap.php b/core/vendor/composer/autoload_classmap.php index 4a9177d7fe10..590381a3be5a 100644 --- a/core/vendor/composer/autoload_classmap.php +++ b/core/vendor/composer/autoload_classmap.php @@ -6,4 +6,5 @@ $baseDir = dirname($vendorDir); return array( + 'SessionHandlerInterface' => $baseDir . '/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php', ); diff --git a/core/vendor/composer/autoload_real.php b/core/vendor/composer/autoload_real.php index 9028b7363aff..72e789fcef24 100644 --- a/core/vendor/composer/autoload_real.php +++ b/core/vendor/composer/autoload_real.php @@ -2,19 +2,27 @@ // autoload_real.php generated by Composer -require __DIR__ . '/ClassLoader.php'; - -class ComposerAutoloaderInit +class ComposerAutoloaderInitac017267abab05dbc458e3a320f5ad98 { private static $loader; + public static function loadClassLoader($class) + { + if ('Composer\Autoload\ClassLoader' === $class) { + require __DIR__ . '/ClassLoader.php'; + } + } + public static function getLoader() { if (null !== static::$loader) { return static::$loader; } + spl_autoload_register(array('ComposerAutoloaderInitac017267abab05dbc458e3a320f5ad98', 'loadClassLoader')); static::$loader = $loader = new \Composer\Autoload\ClassLoader(); + spl_autoload_unregister(array('ComposerAutoloaderInitac017267abab05dbc458e3a320f5ad98', 'loadClassLoader')); + $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index fc7a6190a3f5..620f56b9882f 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -1,108 +1,113 @@ [ { - "name": "twig/twig", - "version": "v1.8.3", - "version_normalized": "1.8.3.0", + "name": "kriswallsmith/assetic", + "version": "v1.1.0-alpha1", + "version_normalized": "1.1.0.0-alpha1", "source": { "type": "git", - "url": "git://github.com/fabpot/Twig.git", - "reference": "v1.8.3" + "url": "http://github.com/kriswallsmith/assetic.git", + "reference": "v1.1.0-alpha1" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Twig/zipball/v1.8.3", - "reference": "v1.8.3", + "url": "https://github.com/kriswallsmith/assetic/zipball/v1.1.0-alpha1", + "reference": "v1.1.0-alpha1", "shasum": "" }, "require": { - "php": ">=5.2.4" + "php": ">=5.3.1", + "symfony/process": "2.1.*" }, - "time": "2012-06-18 18:48:16", + "require-dev": { + "twig/twig": ">=1.6.0,<2.0", + "leafo/lessphp": "*", + "leafo/scssphp": "*", + "ptachoire/cssembed": "*" + }, + "suggest": { + "twig/twig": "Assetic provides the integration with the Twig templating engine", + "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", + "leafo/scssphp": "Assetic provides the integration with the scssphp SCSS compiler", + "ptachoire/cssembed": "Assetic provides the integration with phpcssembed to embed data uris" + }, + "time": "2012-08-28 05:33:44", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.1-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "Twig_": "lib/" + "Assetic": "src/" } }, "license": [ - "BSD-3" + "MIT" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "homepage": null, - "role": null + "name": "Kris Wallsmith", + "email": "kris.wallsmith@gmail.com", + "homepage": "http://kriswallsmith.net/" } ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", + "description": "Asset Management for PHP", + "homepage": "https://github.com/kriswallsmith/assetic", "keywords": [ - "templating" + "assets", + "compression", + "minification" ] }, { "name": "symfony/class-loader", - "version": "v2.1.0-RC2", - "version_normalized": "2.1.0.0-RC2", + "version": "dev-master", + "version_normalized": "9999999-dev", "target-dir": "Symfony/Component/ClassLoader", "source": { "type": "git", "url": "https://github.com/symfony/ClassLoader", - "reference": "v2.1.0-RC2" + "reference": "329e3c07fd7222160c647013d4dc936a76743ff6" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/ClassLoader/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/ClassLoader/archive/329e3c07fd7222160c647013d4dc936a76743ff6.zip", + "reference": "329e3c07fd7222160c647013d4dc936a76743ff6", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/finder": "2.1.*" + "symfony/finder": "2.2.*" }, - "time": "2012-08-27 14:51:49", + "time": "2012-11-19 12:58:52", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\ClassLoader": "" + "Symfony\\Component\\ClassLoader\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony ClassLoader Component", @@ -110,319 +115,234 @@ }, { "name": "symfony/dependency-injection", - "version": "v2.1.0-RC2", - "version_normalized": "2.1.0.0-RC2", + "version": "dev-master", + "version_normalized": "9999999-dev", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection", - "reference": "v2.1.0-RC2" + "reference": "e2713da6f3713eba1bc26dfeeaa7aefde8914676" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/DependencyInjection/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/DependencyInjection/archive/e2713da6f3713eba1bc26dfeeaa7aefde8914676.zip", + "reference": "e2713da6f3713eba1bc26dfeeaa7aefde8914676", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/yaml": "2.1.*", - "symfony/config": "2.1.*" + "symfony/yaml": "2.2.*", + "symfony/config": "2.2.*" }, "suggest": { - "symfony/yaml": "v2.1.0-RC2", - "symfony/config": "v2.1.0-RC2" + "symfony/yaml": "2.2.*", + "symfony/config": "2.2.*" }, - "time": "2012-08-28 06:54:42", + "time": "2012-11-19 12:58:52", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\DependencyInjection": "" + "Symfony\\Component\\DependencyInjection\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony DependencyInjection Component", "homepage": "http://symfony.com" }, { - "name": "doctrine/common", - "version": "2.3.0-RC2", - "version_normalized": "2.3.0.0-RC2", + "name": "symfony/event-dispatcher", + "version": "dev-master", + "version_normalized": "9999999-dev", + "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", - "url": "https://github.com/doctrine/common", - "reference": "2.3.0-RC2" + "url": "https://github.com/symfony/EventDispatcher", + "reference": "eb290a447c0af5bea0d3de5d95d498afd8c82f89" }, "dist": { "type": "zip", - "url": "https://github.com/doctrine/common/zipball/2.3.0-RC2", - "reference": "2.3.0-RC2", + "url": "https://github.com/symfony/EventDispatcher/archive/eb290a447c0af5bea0d3de5d95d498afd8c82f89.zip", + "reference": "eb290a447c0af5bea0d3de5d95d498afd8c82f89", "shasum": "" }, "require": { - "php": ">=5.3.2" - }, - "time": "2012-08-29 13:06:32", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Doctrine\\Common": "lib/" - } - }, - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/", - "role": null - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": null, - "role": null - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org", - "homepage": null, - "role": null - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de", - "homepage": null, - "role": null - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Common Library for Doctrine projects", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "collections", - "spl", - "eventmanager", - "annotations", - "persistence" - ] - }, - { - "name": "symfony/http-foundation", - "version": "v2.1.0-RC2", - "version_normalized": "2.1.0.0-RC2", - "target-dir": "Symfony/Component/HttpFoundation", - "source": { - "type": "git", - "url": "https://github.com/symfony/HttpFoundation", - "reference": "v2.1.0-RC2" + "php": ">=5.3.3" }, - "dist": { - "type": "zip", - "url": "https://github.com/symfony/HttpFoundation/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", - "shasum": "" + "require-dev": { + "symfony/dependency-injection": "2.2.*" }, - "require": { - "php": ">=5.3.3" + "suggest": { + "symfony/dependency-injection": "2.2.*", + "symfony/http-kernel": "2.2.*" }, - "time": "2012-08-22 12:48:41", + "time": "2012-11-13 14:08:04", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\HttpFoundation": "", - "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" + "Symfony\\Component\\EventDispatcher\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], - "description": "Symfony HttpFoundation Component", + "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com" }, { - "name": "symfony/event-dispatcher", - "version": "v2.1.0-RC2", - "version_normalized": "2.1.0.0-RC2", - "target-dir": "Symfony/Component/EventDispatcher", + "name": "symfony/http-foundation", + "version": "dev-master", + "version_normalized": "9999999-dev", + "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", - "url": "https://github.com/symfony/EventDispatcher", - "reference": "v2.1.0-RC2" + "url": "https://github.com/symfony/HttpFoundation", + "reference": "c209d2d5b6c99121d4f3144a41e449200f4c1477" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/EventDispatcher/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/HttpFoundation/archive/c209d2d5b6c99121d4f3144a41e449200f4c1477.zip", + "reference": "c209d2d5b6c99121d4f3144a41e449200f4c1477", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "require-dev": { - "symfony/dependency-injection": "2.1.*" - }, - "suggest": { - "symfony/dependency-injection": "v2.1.0-RC2", - "symfony/http-kernel": "v2.1.0-RC2" - }, - "time": "2012-08-22 12:48:41", + "time": "2012-12-03 13:31:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\EventDispatcher": "" - } + "Symfony\\Component\\HttpFoundation\\": "" + }, + "classmap": [ + "Symfony/Component/HttpFoundation/Resources/stubs" + ] }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], - "description": "Symfony EventDispatcher Component", + "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com" }, { "name": "symfony/http-kernel", - "version": "v2.1.0-RC2", - "version_normalized": "2.1.0.0-RC2", + "version": "dev-master", + "version_normalized": "9999999-dev", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel", - "reference": "v2.1.0-RC2" + "reference": "b8d175c14bdf4eb9771690eae9718673dcca8408" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/HttpKernel/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/HttpKernel/archive/b8d175c14bdf4eb9771690eae9718673dcca8408.zip", + "reference": "b8d175c14bdf4eb9771690eae9718673dcca8408", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/event-dispatcher": "2.1.*", - "symfony/http-foundation": "2.1.*" + "symfony/event-dispatcher": "2.2.*", + "symfony/http-foundation": "2.2.*" }, "require-dev": { - "symfony/browser-kit": "2.1.*", - "symfony/class-loader": "2.1.*", - "symfony/config": "2.1.*", - "symfony/console": "2.1.*", - "symfony/dependency-injection": "2.1.*", - "symfony/finder": "2.1.*", - "symfony/process": "2.1.*", - "symfony/routing": "2.1.*" + "symfony/browser-kit": "2.2.*", + "symfony/class-loader": "2.2.*", + "symfony/config": "2.2.*", + "symfony/console": "2.2.*", + "symfony/dependency-injection": "2.2.*", + "symfony/finder": "2.2.*", + "symfony/process": "2.2.*", + "symfony/routing": "2.2.*", + "symfony/stopwatch": "2.2.*" }, "suggest": { - "symfony/browser-kit": "v2.1.0-RC2", - "symfony/class-loader": "v2.1.0-RC2", - "symfony/config": "v2.1.0-RC2", - "symfony/console": "v2.1.0-RC2", - "symfony/dependency-injection": "v2.1.0-RC2", - "symfony/finder": "v2.1.0-RC2" - }, - "time": "2012-08-28 07:00:18", + "symfony/browser-kit": "2.2.*", + "symfony/class-loader": "2.2.*", + "symfony/config": "2.2.*", + "symfony/console": "2.2.*", + "symfony/dependency-injection": "2.2.*", + "symfony/finder": "2.2.*" + }, + "time": "2012-11-24 12:13:43", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\HttpKernel": "" + "Symfony\\Component\\HttpKernel\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony HttpKernel Component", @@ -430,151 +350,146 @@ }, { "name": "symfony/routing", - "version": "v2.1.0-RC2", - "version_normalized": "2.1.0.0-RC2", + "version": "dev-master", + "version_normalized": "9999999-dev", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing", - "reference": "v2.1.0-RC2" + "reference": "de5f6ded706bf50922c89864693c60793d21e935" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Routing/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/Routing/archive/de5f6ded706bf50922c89864693c60793d21e935.zip", + "reference": "de5f6ded706bf50922c89864693c60793d21e935", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/config": "2.1.*", - "symfony/yaml": "2.1.*", - "symfony/http-kernel": "2.1.*", - "doctrine/common": ">=2.2,<2.4-dev" + "doctrine/common": ">=2.2,<2.4-dev", + "symfony/config": "2.2.*", + "symfony/yaml": "2.2.*", + "symfony/http-kernel": "2.2.*" }, "suggest": { - "symfony/config": "v2.1.0-RC2", - "symfony/yaml": "v2.1.0-RC2", - "doctrine/common": ">=2.2,<2.4-dev" + "doctrine/common": ">=2.2,<2.4-dev", + "symfony/config": "2.2.*", + "symfony/yaml": "2.2.*" }, - "time": "2012-08-28 06:54:42", + "time": "2012-12-03 22:11:37", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\Routing": "" + "Symfony\\Component\\Routing\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony Routing Component", "homepage": "http://symfony.com" }, { - "name": "symfony/yaml", - "version": "v2.1.0-RC2", - "version_normalized": "2.1.0.0-RC2", - "target-dir": "Symfony/Component/Yaml", + "name": "symfony/serializer", + "version": "dev-master", + "version_normalized": "9999999-dev", + "target-dir": "Symfony/Component/Serializer", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml", - "reference": "v2.1.0-RC2" + "url": "https://github.com/symfony/Serializer", + "reference": "60abc7e72a5198192c42fc07bb8c1e3082e7229e" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Yaml/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/Serializer/archive/60abc7e72a5198192c42fc07bb8c1e3082e7229e.zip", + "reference": "60abc7e72a5198192c42fc07bb8c1e3082e7229e", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-22 12:48:41", + "time": "2012-11-17 17:07:16", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\Yaml": "" + "Symfony\\Component\\Serializer\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": null, - "role": null + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "email": null, - "homepage": "http://symfony.com/contributors", - "role": null + "homepage": "http://symfony.com/contributors" } ], - "description": "Symfony Yaml Component", + "description": "Symfony Serializer Component", "homepage": "http://symfony.com" }, { - "name": "symfony/process", - "version": "v2.1.0-RC2", - "version_normalized": "2.1.0.0-RC2", - "target-dir": "Symfony/Component/Process", + "name": "symfony/yaml", + "version": "dev-master", + "version_normalized": "9999999-dev", + "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", - "url": "https://github.com/symfony/Process", - "reference": "v2.1.0-RC2" + "url": "https://github.com/symfony/Yaml", + "reference": "bed4fddc24392513e01b32a78d600b1272ed9a6c" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Process/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/Yaml/archive/bed4fddc24392513e01b32a78d600b1272ed9a6c.zip", + "reference": "bed4fddc24392513e01b32a78d600b1272ed9a6c", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-26 06:13:51", + "time": "2012-11-13 14:08:04", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { - "Symfony\\Component\\Process": "" + "Symfony\\Component\\Yaml\\": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -588,293 +503,178 @@ "homepage": "http://symfony.com/contributors" } ], - "description": "Symfony Process Component", + "description": "Symfony Yaml Component", "homepage": "http://symfony.com" }, { - "name": "kriswallsmith/assetic", - "version": "v1.1.0-alpha1", - "version_normalized": "1.1.0.0-alpha1", + "name": "twig/twig", + "version": "v1.11.1", + "version_normalized": "1.11.1.0", "source": { "type": "git", - "url": "http://github.com/kriswallsmith/assetic.git", - "reference": "v1.1.0-alpha1" + "url": "git://github.com/fabpot/Twig.git", + "reference": "v1.11.1" }, "dist": { "type": "zip", - "url": "https://github.com/kriswallsmith/assetic/zipball/v1.1.0-alpha1", - "reference": "v1.1.0-alpha1", + "url": "https://github.com/fabpot/Twig/archive/v1.11.1.zip", + "reference": "v1.11.1", "shasum": "" }, "require": { - "php": ">=5.3.1", - "symfony/process": "2.1.*" - }, - "require-dev": { - "twig/twig": ">=1.6.0,<2.0", - "leafo/lessphp": "*", - "leafo/scssphp": "*", - "ptachoire/cssembed": "*" - }, - "suggest": { - "twig/twig": "Assetic provides the integration with the Twig templating engine", - "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", - "leafo/scssphp": "Assetic provides the integration with the scssphp SCSS compiler", - "ptachoire/cssembed": "Assetic provides the integration with phpcssembed to embed data uris" + "php": ">=5.2.4" }, - "time": "2012-08-28 05:33:44", + "time": "2012-11-11 17:17:59", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.11-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "Assetic": "src/" + "Twig_": "lib/" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3" ], "authors": [ { - "name": "Kris Wallsmith", - "email": "kris.wallsmith@gmail.com", - "homepage": "http://kriswallsmith.net/" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com" } ], - "description": "Asset Management for PHP", - "homepage": "https://github.com/kriswallsmith/assetic", + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", "keywords": [ - "assets", - "compression", - "minification" + "templating" ] }, { - "name": "symfony/serializer", - "version": "v2.1.2", - "version_normalized": "2.1.2.0", - "target-dir": "Symfony/Component/Serializer", + "name": "doctrine/common", + "version": "2.3.0", + "version_normalized": "2.3.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/Serializer", - "reference": "v2.1.2" + "url": "https://github.com/doctrine/common", + "reference": "2.3.0" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Serializer/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/doctrine/common/zipball/2.3.0", + "reference": "2.3.0", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.2" }, - "time": "2012-08-28 00:54:42", + "time": "2012-09-19 22:55:18", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.3.x-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "Symfony\\Component\\Serializer": "" + "Doctrine\\Common": "lib/" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/" }, { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Serializer Component", - "homepage": "http://symfony.com" - }, - { - "name": "guzzle/common", - "version": "v3.0.5", - "version_normalized": "3.0.5.0", - "target-dir": "Guzzle/Common", - "source": { - "type": "git", - "url": "git://github.com/guzzle/common.git", - "reference": "v3.0.5" - }, - "dist": { - "type": "zip", - "url": "https://github.com/guzzle/common/archive/v3.0.5.zip", - "reference": "v3.0.5", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "symfony/event-dispatcher": "2.1.*" - }, - "time": "2012-11-19 00:15:33", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Guzzle\\Common": "" - } - }, - "license": [ - "MIT" - ], - "description": "Common libraries used by Guzzle", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "event", - "exception", - "common", - "collection" - ] - }, - { - "name": "guzzle/stream", - "version": "v3.0.5", - "version_normalized": "3.0.5.0", - "target-dir": "Guzzle/Stream", - "source": { - "type": "git", - "url": "https://github.com/guzzle/stream", - "reference": "v3.0.5" - }, - "dist": { - "type": "zip", - "url": "https://github.com/guzzle/stream/archive/v3.0.5.zip", - "reference": "v3.0.5", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "guzzle/common": "self.version" - }, - "time": "2012-11-11 23:54:57", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Guzzle\\Stream": "" - } - }, - "license": [ - "MIT" - ], - "authors": [ + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" } ], - "description": "Guzzle stream wrapper component", - "homepage": "http://guzzlephp.org/", + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", "keywords": [ - "stream", - "Guzzle", - "component" + "collections", + "spl", + "eventmanager", + "annotations", + "persistence" ] }, { - "name": "guzzle/parser", - "version": "v3.0.5", - "version_normalized": "3.0.5.0", - "target-dir": "Guzzle/Parser", + "name": "symfony/process", + "version": "v2.1.4", + "version_normalized": "2.1.4.0", + "target-dir": "Symfony/Component/Process", "source": { "type": "git", - "url": "git://github.com/guzzle/parser.git", - "reference": "v3.0.5" + "url": "https://github.com/symfony/Process", + "reference": "v2.1.4" }, "dist": { "type": "zip", - "url": "https://github.com/guzzle/parser/archive/v3.0.5.zip", - "reference": "v3.0.5", + "url": "https://github.com/symfony/Process/archive/v2.1.4.zip", + "reference": "v2.1.4", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": ">=5.3.3" }, - "time": "2012-11-19 00:07:13", + "time": "2012-11-19 20:53:52", "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Guzzle\\Parser": "" + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" } }, - "license": [ - "MIT" - ], - "description": "Interchangeable parsers used by Guzzle", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "http", - "url", - "message", - "cookie", - "URI Template" - ] - }, - { - "name": "guzzle/http", - "version": "v3.0.5", - "version_normalized": "3.0.5.0", - "target-dir": "Guzzle/Http", - "source": { - "type": "git", - "url": "git://github.com/guzzle/http.git", - "reference": "v3.0.5" - }, - "dist": { - "type": "zip", - "url": "https://github.com/guzzle/http/archive/v3.0.5.zip", - "reference": "v3.0.5", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "guzzle/common": "self.version", - "guzzle/parser": "self.version", - "guzzle/stream": "self.version" - }, - "time": "2012-11-18 05:28:55", - "type": "library", "installation-source": "dist", "autoload": { "psr-0": { - "Guzzle\\Http": "" + "Symfony\\Component\\Process": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" } ], - "description": "HTTP libraries used by Guzzle", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "curl", - "http", - "http client", - "client", - "Guzzle" - ] + "description": "Symfony Process Component", + "homepage": "http://symfony.com" } ] diff --git a/core/vendor/doctrine/common/composer.json b/core/vendor/doctrine/common/composer.json index ff87dba4283f..c87258de0aef 100644 --- a/core/vendor/doctrine/common/composer.json +++ b/core/vendor/doctrine/common/composer.json @@ -1,6 +1,6 @@ { "name": "doctrine/common", - "type": "library","version":"2.3.0-RC2", + "type": "library", "description": "Common Library for Doctrine projects", "keywords": ["collections", "spl", "eventmanager", "annotations", "persistence"], "homepage": "http://www.doctrine-project.org", diff --git a/core/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php b/core/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php index fc3c2d425499..c9a6f7a2d8fa 100644 --- a/core/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php +++ b/core/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php @@ -52,6 +52,24 @@ final class DocLexer extends Lexer const T_NULL = 111; const T_COLON = 112; + protected $noCase = array( + '@' => self::T_AT, + ',' => self::T_COMMA, + '(' => self::T_OPEN_PARENTHESIS, + ')' => self::T_CLOSE_PARENTHESIS, + '{' => self::T_OPEN_CURLY_BRACES, + '}' => self::T_CLOSE_CURLY_BRACES, + '=' => self::T_EQUALS, + ':' => self::T_COLON, + '\\' => self::T_NAMESPACE_SEPARATOR + ); + + protected $withCase = array( + 'true' => self::T_TRUE, + 'false' => self::T_FALSE, + 'null' => self::T_NULL + ); + /** * {@inheritdoc} */ @@ -83,61 +101,30 @@ protected function getType(&$value) { $type = self::T_NONE; - // Checking numeric value - if (is_numeric($value)) { - return (strpos($value, '.') !== false || stripos($value, 'e') !== false) - ? self::T_FLOAT : self::T_INTEGER; - } - if ($value[0] === '"') { $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2)); return self::T_STRING; - } else { - switch (strtolower($value)) { - case '@': - return self::T_AT; - - case ',': - return self::T_COMMA; - - case '(': - return self::T_OPEN_PARENTHESIS; - - case ')': - return self::T_CLOSE_PARENTHESIS; - - case '{': - return self::T_OPEN_CURLY_BRACES; - - case '}': - return self::T_CLOSE_CURLY_BRACES; - - case '=': - return self::T_EQUALS; - - case '\\': - return self::T_NAMESPACE_SEPARATOR; - - case 'true': - return self::T_TRUE; + } - case 'false': - return self::T_FALSE; + if (isset($this->noCase[$value])) { + return $this->noCase[$value]; + } - case 'null': - return self::T_NULL; + if ($value[0] === '_' || $value[0] === '\\' || ctype_alpha($value[0])) { + return self::T_IDENTIFIER; + } - case ':': - return self::T_COLON; + $lowerValue = strtolower($value); - default: - if (ctype_alpha($value[0]) || $value[0] === '_' || $value[0] === '\\') { - return self::T_IDENTIFIER; - } + if (isset($this->withCase[$lowerValue])) { + return $this->withCase[$lowerValue]; + } - break; - } + // Checking numeric value + if (is_numeric($value)) { + return (strpos($value, '.') !== false || stripos($value, 'e') !== false) + ? self::T_FLOAT : self::T_INTEGER; } return $type; diff --git a/core/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php b/core/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php index 44359754eb05..da650b4c6e6b 100644 --- a/core/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php +++ b/core/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php @@ -102,7 +102,7 @@ protected function getFilename($id) */ protected function doDelete($id) { - return unlink($this->getFilename($id)); + return @unlink($this->getFilename($id)); } /** @@ -116,7 +116,7 @@ protected function doFlush() $iterator = new \RegexIterator($iterator, $pattern); foreach ($iterator as $name => $file) { - unlink($name); + @unlink($name); } return true; diff --git a/core/vendor/doctrine/common/lib/Doctrine/Common/Version.php b/core/vendor/doctrine/common/lib/Doctrine/Common/Version.php index 0782163b707c..cca4894dfcbf 100644 --- a/core/vendor/doctrine/common/lib/Doctrine/Common/Version.php +++ b/core/vendor/doctrine/common/lib/Doctrine/Common/Version.php @@ -36,7 +36,7 @@ class Version /** * Current Doctrine Version */ - const VERSION = '2.3.0-RC2'; + const VERSION = '2.3.0'; /** * Compares a Doctrine version with the current one. diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/.gitattributes b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/.gitignore b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/.gitignore index d1502b087b4d..44de97a36a6d 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/.gitignore +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/.gitignore @@ -1,2 +1,4 @@ vendor/ composer.lock +phpunit.xml + diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php index 0c99e6ad3d95..0ce22f6b944e 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php @@ -42,28 +42,35 @@ class ApcClassLoader { private $prefix; - private $classFinder; + + /** + * The class loader object being decorated. + * + * @var \Symfony\Component\ClassLoader\ClassLoader + * A class loader object that implements the findFile() method. + */ + protected $decorated; /** * Constructor. * - * @param string $prefix A prefix to create a namespace in APC - * @param object $classFinder An object that implements findFile() method. + * @param string $prefix The APC namespace prefix to use. + * @param object $decorated A class loader object that implements the findFile() method. * * @api */ - public function __construct($prefix, $classFinder) + public function __construct($prefix, $decorated) { if (!extension_loaded('apc')) { throw new \RuntimeException('Unable to use ApcClassLoader as APC is not enabled.'); } - if (!method_exists($classFinder, 'findFile')) { + if (!method_exists($decorated, 'findFile')) { throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); } $this->prefix = $prefix; - $this->classFinder = $classFinder; + $this->decorated = $decorated; } /** @@ -110,9 +117,18 @@ public function loadClass($class) public function findFile($class) { if (false === $file = apc_fetch($this->prefix.$class)) { - apc_store($this->prefix.$class, $file = $this->classFinder->findFile($class)); + apc_store($this->prefix.$class, $file = $this->decorated->findFile($class)); } return $file; } + + /** + * Passes through all unknown calls onto the decorated object. + */ + public function __call($method, $args) + { + return call_user_func_array(array($this->decorated, $method), $args); + } + } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php index 7f5bdd1e4754..b0e761841800 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -20,6 +20,7 @@ class ClassCollectionLoader { private static $loaded; private static $seen; + private static $useTokenizer = true; /** * Loads a list of classes and caches them in one big file. @@ -103,14 +104,14 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = $c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($class->getFileName())); - // add namespace declaration for global code + // fakes namespace declaration for global code if (!$class->inNamespace()) { - $c = "\nnamespace\n{\n".self::stripComments($c)."\n}\n"; - } else { - $c = self::fixNamespaceDeclarations('<?php '.$c); - $c = preg_replace('/^\s*<\?php/', '', $c); + $c = "\nnamespace\n{\n".$c."\n}\n"; } + $c = self::fixNamespaceDeclarations('<?php '.$c); + $c = preg_replace('/^\s*<\?php/', '', $c); + $content .= $c; } @@ -135,7 +136,11 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = */ public static function fixNamespaceDeclarations($source) { - if (!function_exists('token_get_all')) { + if (!function_exists('token_get_all') || !self::$useTokenizer) { + if (preg_match('/namespace(.*?)\s*;/', $source)) { + $source = preg_replace('/namespace(.*?)\s*;/', "namespace$1\n{", $source)."}\n"; + } + return $source; } @@ -200,43 +205,12 @@ private static function writeCacheFile($file, $content) throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); } - /** - * Removes comments from a PHP source string. - * - * We don't use the PHP php_strip_whitespace() function - * as we want the content to be readable and well-formatted. - * - * @param string $source A PHP string - * - * @return string The PHP string with the comments removed - */ - private static function stripComments($source) - { - if (!function_exists('token_get_all')) { - return $source; - } - - $output = ''; - foreach (token_get_all($source) as $token) { - if (is_string($token)) { - $output .= $token; - } elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { - $output .= $token[1]; - } - } - - // replace multiple new lines with a single newline - $output = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $output); - - return $output; - } - /** * Gets an ordered array of passed classes including all their dependencies. * * @param array $classes * - * @return array An array of sorted \ReflectionClass instances (dependencies added if needed) + * @return \ReflectionClass[] An array of sorted \ReflectionClass instances (dependencies added if needed) * * @throws \InvalidArgumentException When a class can't be loaded */ @@ -317,4 +291,12 @@ private static function getTraits(\ReflectionClass $class) return $classes; } + + /** + * This method is only useful for testing. + */ + public static function enableTokenizer($bool) + { + self::$useTokenizer = (Boolean) $bool; + } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/README.md b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/README.md index 64dffe9a68a9..5ac31c64890d 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/README.md +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/README.md @@ -64,9 +64,6 @@ Resources You can run the unit tests with the following command: - phpunit - -If you also want to run the unit tests that depend on other Symfony -Components, install dev dependencies before running PHPUnit: - - php composer.phar install --dev + $ cd path/to/Symfony/Component/ClassLoader/ + $ composer.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index 90eca1dedad1..95fafeae82a6 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -117,60 +117,93 @@ public function getDifferentOrdersForTraits() ); } - public function testFixNamespaceDeclarations() + /** + * @dataProvider getFixNamespaceDeclarationsData + */ + public function testFixNamespaceDeclarations($source, $expected) { - $source = <<<EOF -<?php + $this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source)); + } -namespace Foo; -class Foo {} -namespace Bar ; -class Foo {} -namespace Foo\Bar; -class Foo {} -namespace Foo\Bar\Bar -{ - class Foo {} -} -namespace -{ - class Foo {} -} -EOF; + /** + * @dataProvider getFixNamespaceDeclarationsData + */ + public function testFixNamespaceDeclarationsWithoutTokenizer($source, $expected) + { + ClassCollectionLoader::enableTokenizer(false); + $this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source)); + ClassCollectionLoader::enableTokenizer(true); + } - $expected = <<<EOF -<?php + public function getFixNamespaceDeclarationsData() + { + return array( + array("namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}\n"), + array("namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}\n"), + array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}\n"), + array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}\n"), + array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n"), + array("namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}\n"), + ); + } -namespace Foo -{ -class Foo {} -} -namespace Bar + /** + * @expectedException InvalidArgumentException + */ + public function testUnableToLoadClassException() + { + if (is_file($file = sys_get_temp_dir().'/foo.php')) { + unlink($file); + } + + ClassCollectionLoader::load(array('SomeNotExistingClass'), sys_get_temp_dir(), 'foo', false); + } + + public function testCommentStripping() + { + if (is_file($file = sys_get_temp_dir().'/bar.php')) { + unlink($file); + } + spl_autoload_register($r = function ($class) { + require_once __DIR__.'/Fixtures/'.str_replace(array('\\', '_'), '/', $class).'.php'; + }); + + ClassCollectionLoader::load(array('Namespaced\\WithComments', 'Pearlike_WithComments'), sys_get_temp_dir(), 'bar', false); + + spl_autoload_unregister($r); + + $this->assertEquals(<<<EOF +<?php + + + +namespace Namespaced { -class Foo {} -} -namespace Foo\Bar + +class WithComments { -class Foo {} + + public static \$loaded = true; } -namespace Foo\Bar\Bar -{ - class Foo {} } + namespace { - class Foo {} + + + + +class Pearlike_WithComments +{ + + public static \$loaded = true; } -EOF; - $this->assertEquals($expected, ClassCollectionLoader::fixNamespaceDeclarations($source)); - } +} - /** - * @expectedException InvalidArgumentException - */ - public function testUnableToLoadClassException() - { - ClassCollectionLoader::load(array('SomeNotExistingClass'), '', 'foo', false); +EOF + , file_get_contents($file)); + + unlink($file); } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index e69502b17d75..c4ef810ca174 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -72,9 +72,10 @@ public function getTestCreateMapTests() { $data = array( array(__DIR__.'/Fixtures/Namespaced', array( - 'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php', - 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php', - 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php', + 'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php', + 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php', + 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php', + 'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php', ) ), array(__DIR__.'/Fixtures/beta/NamespaceCollision', array( @@ -84,9 +85,10 @@ public function getTestCreateMapTests() 'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php', )), array(__DIR__.'/Fixtures/Pearlike', array( - 'Pearlike_Foo' => realpath(__DIR__).'/Fixtures/Pearlike/Foo.php', - 'Pearlike_Bar' => realpath(__DIR__).'/Fixtures/Pearlike/Bar.php', - 'Pearlike_Baz' => realpath(__DIR__).'/Fixtures/Pearlike/Baz.php', + 'Pearlike_Foo' => realpath(__DIR__).'/Fixtures/Pearlike/Foo.php', + 'Pearlike_Bar' => realpath(__DIR__).'/Fixtures/Pearlike/Bar.php', + 'Pearlike_Baz' => realpath(__DIR__).'/Fixtures/Pearlike/Baz.php', + 'Pearlike_WithComments' => realpath(__DIR__).'/Fixtures/Pearlike/WithComments.php', )), array(__DIR__.'/Fixtures/classmap', array( 'Foo\\Bar\\A' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php', diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithComments.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithComments.php new file mode 100644 index 000000000000..6973653fdb97 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithComments.php @@ -0,0 +1,18 @@ +<?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 Namespaced; + +class WithComments +{ + /** @Boolean */ + public static $loaded = true; +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/Pearlike/WithComments.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/Pearlike/WithComments.php new file mode 100644 index 000000000000..d0fd2060d3da --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/Pearlike/WithComments.php @@ -0,0 +1,16 @@ +<?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. + */ + +class Pearlike_WithComments +{ + /** @Boolean */ + public static $loaded = true; +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php index fd60fdf8e8d9..308700b18b2e 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php @@ -23,7 +23,7 @@ public function testLoadClass($className, $testClassName, $message) $loader = new UniversalClassLoader(); $loader->registerNamespace('Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->registerPrefix('Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); - $loader->loadClass($testClassName); + $this->assertTrue($loader->loadClass($testClassName)); $this->assertTrue(class_exists($className), $message); } @@ -92,7 +92,7 @@ public function testLoadClassFromFallback($className, $testClassName, $message) $loader->registerPrefix('Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); $loader->registerNamespaceFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback')); $loader->registerPrefixFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback')); - $loader->loadClass($testClassName); + $this->assertTrue($loader->loadClass($testClassName)); $this->assertTrue(class_exists($className), $message); } @@ -128,7 +128,7 @@ public function testLoadClassNamespaceCollision($namespaces, $className, $messag $loader = new UniversalClassLoader(); $loader->registerNamespaces($namespaces); - $loader->loadClass($className); + $this->assertTrue($loader->loadClass($className)); $this->assertTrue(class_exists($className), $message); } @@ -178,7 +178,7 @@ public function testLoadClassPrefixCollision($prefixes, $className, $message) $loader = new UniversalClassLoader(); $loader->registerPrefixes($prefixes); - $loader->loadClass($className); + $this->assertTrue($loader->loadClass($className)); $this->assertTrue(class_exists($className), $message); } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/bootstrap.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/bootstrap.php deleted file mode 100644 index 54dac3fd265d..000000000000 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/bootstrap.php +++ /dev/null @@ -1,22 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\ClassLoader')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\ClassLoader')).'.php')) { - require_once $file; - } - } -}); - -if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) { - require_once $loader; -} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php index b6128ad6793a..e3170ccee088 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php @@ -242,11 +242,15 @@ public function register($prepend = false) * Loads the given class or interface. * * @param string $class The name of the class + * + * @return Boolean|null True, if loaded */ public function loadClass($class) { if ($file = $this->findFile($class)) { require $file; + + return true; } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json index ccd9ba9bc700..cd56c8c2faa4 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json @@ -20,16 +20,15 @@ "php": ">=5.3.3" }, "require-dev": { - "symfony/finder": "2.1.*" + "symfony/finder": "2.2.*" }, "autoload": { - "psr-0": { "Symfony\\Component\\ClassLoader": "" } + "psr-0": { "Symfony\\Component\\ClassLoader\\": "" } }, "target-dir": "Symfony/Component/ClassLoader", - "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/phpunit.xml.dist b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/phpunit.xml.dist index ae7e2ad9518c..0d29c115323e 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/phpunit.xml.dist +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="Tests/bootstrap.php" + bootstrap="vendor/autoload.php" > <testsuites> <testsuite name="Symfony ClassLoader Component Test Suite"> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitattributes b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitignore b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitignore index d1502b087b4d..44de97a36a6d 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitignore +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitignore @@ -1,2 +1,4 @@ vendor/ composer.lock +phpunit.xml + diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php index 19079b4038da..f7aa471dd8a3 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php @@ -116,7 +116,7 @@ private function processArguments(array $arguments) * * @param string $id A full id or alias for a service definition. * - * @return Definition The definition related to the supplied id + * @return Definition|null The definition related to the supplied id */ private function getDefinition($id) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php index 9cb3ff060dc9..e24b5b020253 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php @@ -49,7 +49,7 @@ public function process(ContainerBuilder $container) /** * Checks for circular references. * - * @param array $edges An array of Nodes + * @param ServiceReferenceGraphEdge[] $edges An array of Edges * * @throws ServiceCircularReferenceException When a circular reference is found. */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index 70592dfda335..ab8895a8c9a5 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -70,6 +70,8 @@ public function process(ContainerBuilder $container) * * @param ContainerBuilder $container The ContainerBuilder * @param array $arguments An array of arguments + * + * @return array */ private function inlineArguments(ContainerBuilder $container, array $arguments) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php index d4af4310c1bc..6073abe69d66 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php @@ -21,14 +21,22 @@ */ class RepeatedPass implements CompilerPassInterface { - private $repeat; + /** + * @var Boolean + */ + private $repeat = false; + + /** + * @var RepeatablePassInterface[] + */ private $passes; /** * Constructor. * - * @param array $passes An array of RepeatablePassInterface objects - * @throws InvalidArgumentException if a pass is not a RepeatablePassInterface instance + * @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects + * + * @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface */ public function __construct(array $passes) { @@ -71,7 +79,7 @@ public function setRepeat() /** * Returns the passes * - * @return array An array of RepeatablePassInterface objects + * @return RepeatablePassInterface[] An array of RepeatablePassInterface objects */ public function getPasses() { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php index 5d00ed682507..1964184955dc 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php @@ -97,6 +97,8 @@ private function updateReferences($container, $currentId, $newId) * @param array $arguments An array of Arguments * @param string $currentId The alias identifier * @param string $newId The identifier the alias points to + * + * @return array */ private function updateArgumentReferences(array $arguments, $currentId, $newId) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php index 53c6f52ddd3f..4fb5b0d3bf0c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php @@ -58,6 +58,8 @@ public function process(ContainerBuilder $container) * @param DefinitionDecorator $definition * * @return Definition + * + * @throws \RuntimeException When the definition is invalid */ private function resolveDefinition($id, DefinitionDecorator $definition) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php index 996199cf1b73..0674ad4fefe1 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php @@ -71,6 +71,10 @@ public function process(ContainerBuilder $container) * * @param array $arguments An array of Reference objects * @param Boolean $inMethodCall + * + * @return array + * + * @throws \RuntimeException When the config is invalid */ private function processArguments(array $arguments, $inMethodCall = false) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php index f6e4c8562522..0d9ed164e6ad 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php @@ -25,6 +25,8 @@ class ResolveParameterPlaceHoldersPass implements CompilerPassInterface * Processes the ContainerBuilder to resolve parameter placeholders. * * @param ContainerBuilder $container + * + * @throws ParameterNotFoundException When an invalid parameter is referenced */ public function process(ContainerBuilder $container) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php index b241bf87fe4a..fbd33eeee16f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php @@ -23,6 +23,9 @@ */ class ServiceReferenceGraph { + /** + * @var ServiceReferenceGraphNode[] + */ private $nodes; /** @@ -37,6 +40,8 @@ public function __construct() * Checks if the graph has a specific node. * * @param string $id Id to check + * + * @return Boolean */ public function hasNode($id) { @@ -64,7 +69,7 @@ public function getNode($id) /** * Returns all nodes. * - * @return array An array of all ServiceReferenceGraphNode objects + * @return ServiceReferenceGraphNode[] An array of all ServiceReferenceGraphNode objects */ public function getNodes() { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php index 88e1f26ecde0..15e54209da76 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php @@ -61,7 +61,11 @@ */ class Container implements IntrospectableContainerInterface { + /** + * @var ParameterBagInterface + */ protected $parameterBag; + protected $services; protected $scopes; protected $scopeChildren; @@ -180,6 +184,9 @@ public function setParameter($name, $value) * @param object $service The service instance * @param string $scope The scope of the service * + * @throws \RuntimeException When trying to set a service in an inactive scope + * @throws \InvalidArgumentException When trying to set a service in the prototype scope + * * @api */ public function set($id, $service, $scope = self::SCOPE_CONTAINER) @@ -229,6 +236,8 @@ public function has($id) * @return object The associated service * * @throws InvalidArgumentException if the service is not defined + * @throws ServiceCircularReferenceException When a circular reference is detected + * @throws ServiceNotFoundException When the service is not defined * * @see Reference * @@ -253,6 +262,11 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE $service = $this->$method(); } catch (\Exception $e) { unset($this->loading[$id]); + + if (isset($this->services[$id])) { + unset($this->services[$id]); + } + throw $e; } @@ -301,6 +315,9 @@ public function getServiceIds() * * @param string $name * + * @throws RuntimeException When the parent scope is inactive + * @throws InvalidArgumentException When the scope does not exist + * * @api */ public function enterScope($name) @@ -384,6 +401,8 @@ public function leaveScope($name) * * @param ScopeInterface $scope * + * @throws \InvalidArgumentException When the scope is invalid + * * @api */ public function addScope(ScopeInterface $scope) diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php index 5bf7ead9fb45..30514cc55dfc 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -31,12 +31,36 @@ */ class ContainerBuilder extends Container implements TaggedContainerInterface { - private $extensions = array(); - private $extensionsByNs = array(); - private $definitions = array(); - private $aliases = array(); - private $resources = array(); + /** + * @var ExtensionInterface[] + */ + private $extensions = array(); + + /** + * @var ExtensionInterface[] + */ + private $extensionsByNs = array(); + + /** + * @var Definition[] + */ + private $definitions = array(); + + /** + * @var Alias[] + */ + private $aliases = array(); + + /** + * @var ResourceInterface[] + */ + private $resources = array(); + private $extensionConfigs = array(); + + /** + * @var Compiler + */ private $compiler; /** @@ -62,6 +86,8 @@ public function registerExtension(ExtensionInterface $extension) * * @return ExtensionInterface An extension instance * + * @throws \LogicException if the extension is not registered + * * @api */ public function getExtension($name) @@ -80,7 +106,7 @@ public function getExtension($name) /** * Returns all registered extensions. * - * @return array An array of ExtensionInterface + * @return ExtensionInterface[] An array of ExtensionInterface * * @api */ @@ -131,6 +157,15 @@ public function addResource(ResourceInterface $resource) return $this; } + /** + * Sets the resources for this configuration. + * + * @param ResourceInterface[] $resources An array of resources + * + * @return ContainerBuilder The current instance + * + * @api + */ public function setResources(array $resources) { $this->resources = $resources; @@ -143,6 +178,8 @@ public function setResources(array $resources) * * @param object $object An object instance * + * @return ContainerBuilder The current instance + * * @api */ public function addObjectResource($object) @@ -151,6 +188,8 @@ public function addObjectResource($object) do { $this->addResource(new FileResource($parent->getFileName())); } while ($parent = $parent->getParentClass()); + + return $this; } /** @@ -162,6 +201,8 @@ public function addObjectResource($object) * @return ContainerBuilder The current instance * @throws BadMethodCallException When this ContainerBuilder is frozen * + * @throws \LogicException if the container is frozen + * * @api */ public function loadFromExtension($extension, array $values = array()) @@ -183,6 +224,8 @@ public function loadFromExtension($extension, array $values = array()) * @param CompilerPassInterface $pass A compiler pass * @param string $type The type of compiler pass * + * @return ContainerBuilder The current instance + * * @api */ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) @@ -194,6 +237,8 @@ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig: $this->compiler->addPass($pass, $type); $this->addObjectResource($pass); + + return $this; } /** @@ -480,7 +525,7 @@ public function addAliases(array $aliases) /** * Sets the service aliases. * - * @param array $aliases An array of service definitions + * @param array $aliases An array of aliases * * @api */ @@ -493,8 +538,11 @@ public function setAliases(array $aliases) /** * Sets an alias for an existing service. * - * @param string $alias The alias to create - * @param mixed $id The service to alias + * @param string $alias The alias to create + * @param string|Alias $id The service to alias + * + * @throws \InvalidArgumentException if the id is not a string or an Alias + * @throws \InvalidArgumentException if the alias is for itself * * @api */ @@ -546,7 +594,7 @@ public function hasAlias($id) /** * Gets all defined aliases. * - * @return array An array of aliases + * @return Alias[] An array of aliases * * @api */ @@ -612,7 +660,7 @@ public function addDefinitions(array $definitions) /** * Sets the service definitions. * - * @param array $definitions An array of service definitions + * @param Definition[] $definitions An array of service definitions * * @api */ @@ -625,7 +673,7 @@ public function setDefinitions(array $definitions) /** * Gets all service definitions. * - * @return array An array of Definition instances + * @return Definition[] An array of Definition instances * * @api */ @@ -640,6 +688,8 @@ public function getDefinitions() * @param string $id The service identifier * @param Definition $definition A Definition instance * + * @return Definition the service definition + * * @throws BadMethodCallException When this ContainerBuilder is frozen * * @api @@ -721,9 +771,10 @@ public function findDefinition($id) * @param Definition $definition A service definition instance * @param string $id The service identifier * - * @return object The service described by the service definition + * @return object The service described by the service definition * - * @throws RuntimeException When factory specification is incomplete or scope is inactive + * @throws RuntimeException When the scope is inactive + * @throws RuntimeException When the factory definition is incomplete * @throws InvalidArgumentException When configure callable is not callable */ private function createService(Definition $definition, $id) @@ -788,10 +839,8 @@ private function createService(Definition $definition, $id) } if ($callable = $definition->getConfigurator()) { - if (is_array($callable) && is_object($callable[0]) && $callable[0] instanceof Reference) { - $callable[0] = $this->get((string) $callable[0]); - } elseif (is_array($callable)) { - $callable[0] = $parameterBag->resolveValue($callable[0]); + if (is_array($callable)) { + $callable[0] = $callable[0] instanceof Reference ? $this->get((string) $callable[0]) : $parameterBag->resolveValue($callable[0]); } if (!is_callable($callable)) { @@ -817,9 +866,9 @@ public function resolveServices($value) foreach ($value as &$v) { $v = $this->resolveServices($v); } - } elseif (is_object($value) && $value instanceof Reference) { + } elseif ($value instanceof Reference) { $value = $this->get((string) $value, $value->getInvalidBehavior()); - } elseif (is_object($value) && $value instanceof Definition) { + } elseif ($value instanceof Definition) { $value = $this->createService($value, null); } @@ -847,6 +896,21 @@ public function findTaggedServiceIds($name) return $tags; } + /** + * Returns all tags the defined services use. + * + * @return array An array of tags + */ + public function findTags() + { + $tags = array(); + foreach ($this->getDefinitions() as $id => $definition) { + $tags = array_merge(array_keys($definition->getTags()), $tags); + } + + return array_unique($tags); + } + /** * Returns the Service Conditionals. * @@ -862,7 +926,7 @@ public static function getServiceConditionals($value) foreach ($value as $v) { $services = array_unique(array_merge($services, self::getServiceConditionals($v))); } - } elseif (is_object($value) && $value instanceof Reference && $value->getInvalidBehavior() === ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { + } elseif ($value instanceof Reference && $value->getInvalidBehavior() === ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { $services[] = (string) $value; } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerInterface.php index d5e07a06a864..1951ae7b939c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerInterface.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerInterface.php @@ -12,6 +12,8 @@ namespace Symfony\Component\DependencyInjection; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; +use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; /** * ContainerInterface is the interface implemented by service container classes. @@ -49,6 +51,8 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER); * @return object The associated service * * @throws InvalidArgumentException if the service is not defined + * @throws ServiceCircularReferenceException When a circular reference is detected + * @throws ServiceNotFoundException When the service is not defined * * @see Reference * diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php index e7265f2a7015..3fb5938d9c85 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php @@ -241,6 +241,8 @@ public function addArgument($argument) * * @return Definition The current instance * + * @throws \OutOfBoundsException When the replaced argument does not exist + * * @api */ public function replaceArgument($index, $argument) @@ -273,6 +275,8 @@ public function getArguments() * * @return mixed The argument value * + * @throws \OutOfBoundsException When the argument does not exist + * * @api */ public function getArgument($index) @@ -369,7 +373,7 @@ public function hasMethodCall($method) /** * Gets the methods to call after service initialization. * - * @return array An array of method calls + * @return array An array of method calls * * @api */ @@ -628,7 +632,7 @@ public function isAbstract() /** * Sets a configurator to call after the service is fully initialized. * - * @param mixed $callable A PHP callable + * @param callable $callable A PHP callable * * @return Definition The current instance * @@ -644,7 +648,7 @@ public function setConfigurator($callable) /** * Gets the configurator to call after the service is fully initialized. * - * @return mixed The PHP callable to call + * @return callable The PHP callable to call * * @api */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php index 0306f75b8edb..3ac561a4426d 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -29,7 +29,7 @@ class DefinitionDecorator extends Definition /** * Constructor. * - * @param Definition $parent The Definition instance to decorate. + * @param string $parent The id of Definition instance to decorate. * * @api */ @@ -44,7 +44,7 @@ public function __construct($parent) /** * Returns the Definition being decorated. * - * @return Definition + * @return string * * @api */ @@ -159,6 +159,8 @@ public function setPublic($boolean) * * @return mixed The argument value * + * @throws \OutOfBoundsException When the argument does not exist + * * @api */ public function getArgument($index) diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php index debdc527091e..00b212a1b4d1 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php @@ -130,7 +130,7 @@ private function findEdges($id, $arguments, $required, $name) { $edges = array(); foreach ($arguments as $argument) { - if (is_object($argument) && $argument instanceof Parameter) { + if ($argument instanceof Parameter) { $argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null; } elseif (is_string($argument) && preg_match('/^%([^%]+)%$/', $argument, $match)) { $argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 4a29d234484c..36ad24a15988 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -186,6 +186,9 @@ private function addServiceInclude($id, $definition) * @param Definition $definition * * @return string + * + * @throws \RuntimeException When the factory definition is incomplete + * @throws ServiceCircularReferenceException When a circular reference is detected */ private function addServiceInlinedDefinitions($id, $definition) { @@ -449,7 +452,7 @@ private function addServiceConfigurator($id, $definition, $variableName = 'insta } if (is_array($callable)) { - if (is_object($callable[0]) && $callable[0] instanceof Reference) { + if ($callable[0] instanceof Reference) { return sprintf(" %s->%s(\$%s);\n", $this->getServiceCall((string) $callable[0]), $callable[1], $variableName); } @@ -877,9 +880,9 @@ private function wrapServiceConditionals($value, $code) /** * Builds service calls from arguments * - * @param array $arguments - * @param string &$calls By reference - * @param string &$behavior By reference + * @param array $arguments + * @param array &$calls By reference + * @param array &$behavior By reference */ private function getServiceCallsFromArguments(array $arguments, array &$calls, array &$behavior) { @@ -994,7 +997,7 @@ private function dumpValue($value, $interpolate = true) } return sprintf('array(%s)', implode(', ', $code)); - } elseif (is_object($value) && $value instanceof Definition) { + } elseif ($value instanceof Definition) { if (null !== $this->definitionVariables && $this->definitionVariables->contains($value)) { return $this->dumpValue($this->definitionVariables->offsetGet($value), $interpolate); } @@ -1026,15 +1029,15 @@ private function dumpValue($value, $interpolate = true) } return sprintf("new \\%s(%s)", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments)); - } elseif (is_object($value) && $value instanceof Variable) { + } elseif ($value instanceof Variable) { return '$'.$value; - } elseif (is_object($value) && $value instanceof Reference) { + } elseif ($value instanceof Reference) { if (null !== $this->referenceVariables && isset($this->referenceVariables[$id = (string) $value])) { return $this->dumpValue($this->referenceVariables[$id], $interpolate); } return $this->getServiceCall((string) $value, $value); - } elseif (is_object($value) && $value instanceof Parameter) { + } elseif ($value instanceof Parameter) { return $this->dumpParameter($value); } elseif (true === $interpolate && is_string($value)) { if (preg_match('/^%([^%]+)%$/', $value, $match)) { @@ -1049,9 +1052,6 @@ private function dumpValue($value, $interpolate = true) $code = str_replace('%%', '%', preg_replace_callback('/(?<!%)(%)([^%]+)\1/', $replaceParameters, var_export($value, true))); - // optimize string - $code = preg_replace(array("/^''\./", "/\.''$/", "/(\w+)(?:'\.')/", "/(.+)(?:\.''\.)/"), array('', '', '$1', '$1.'), $code); - return $code; } } elseif (is_object($value) || is_resource($value)) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index d8791ce19680..38025ff3eac8 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -63,7 +63,7 @@ public function dump(array $options = array()) /** * Adds parameters. * - * @param DOMElement $parent + * @param \DOMElement $parent */ private function addParameters(\DOMElement $parent) { @@ -84,8 +84,8 @@ private function addParameters(\DOMElement $parent) /** * Adds method calls. * - * @param array $methodcalls - * @param DOMElement $parent + * @param array $methodcalls + * @param \DOMElement $parent */ private function addMethodCalls(array $methodcalls, \DOMElement $parent) { @@ -102,9 +102,9 @@ private function addMethodCalls(array $methodcalls, \DOMElement $parent) /** * Adds a service. * - * @param Definition $definition - * @param string $id - * @param DOMElement $parent + * @param Definition $definition + * @param string $id + * @param \DOMElement $parent */ private function addService($definition, $id, \DOMElement $parent) { @@ -158,7 +158,7 @@ private function addService($definition, $id, \DOMElement $parent) if ($callable = $definition->getConfigurator()) { $configurator = $this->document->createElement('configurator'); if (is_array($callable)) { - $configurator->setAttribute((is_object($callable[0]) && $callable[0] instanceof Reference ? 'service' : 'class'), $callable[0]); + $configurator->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]); $configurator->setAttribute('method', $callable[1]); } else { $configurator->setAttribute('function', $callable); @@ -172,9 +172,9 @@ private function addService($definition, $id, \DOMElement $parent) /** * Adds a service alias. * - * @param string $alias - * @param string $id - * @param DOMElement $parent + * @param string $alias + * @param string $id + * @param \DOMElement $parent */ private function addServiceAlias($alias, $id, \DOMElement $parent) { @@ -190,7 +190,7 @@ private function addServiceAlias($alias, $id, \DOMElement $parent) /** * Adds services. * - * @param DOMElement $parent + * @param \DOMElement $parent */ private function addServices(\DOMElement $parent) { @@ -213,10 +213,10 @@ private function addServices(\DOMElement $parent) /** * Converts parameters. * - * @param array $parameters - * @param string $type - * @param DOMElement $parent - * @param string $keyAttribute + * @param array $parameters + * @param string $type + * @param \DOMElement $parent + * @param string $keyAttribute */ private function convertParameters($parameters, $type, \DOMElement $parent, $keyAttribute = 'key') { @@ -230,7 +230,7 @@ private function convertParameters($parameters, $type, \DOMElement $parent, $key if (is_array($value)) { $element->setAttribute('type', 'collection'); $this->convertParameters($value, $type, $element, 'key'); - } elseif (is_object($value) && $value instanceof Reference) { + } elseif ($value instanceof Reference) { $element->setAttribute('type', 'service'); $element->setAttribute('id', (string) $value); $behaviour = $value->getInvalidBehavior(); @@ -239,7 +239,7 @@ private function convertParameters($parameters, $type, \DOMElement $parent, $key } elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { $element->setAttribute('on-invalid', 'ignore'); } - } elseif (is_object($value) && $value instanceof Definition) { + } elseif ($value instanceof Definition) { $element->setAttribute('type', 'service'); $this->addService($value, null, $element); } else { @@ -280,6 +280,10 @@ private function escape($arguments) * Converts php types to xml types. * * @param mixed $value Value to convert + * + * @return string + * + * @throws RuntimeException When trying to dump object or resource */ public static function phpToXml($value) { @@ -290,7 +294,7 @@ public static function phpToXml($value) return 'true'; case false === $value: return 'false'; - case is_object($value) && $value instanceof Parameter: + case $value instanceof Parameter: return '%'.$value.'%'; case is_object($value) || is_resource($value): throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 9717a2593754..82d68008e0ee 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -12,7 +12,9 @@ namespace Symfony\Component\DependencyInjection\Dumper; use Symfony\Component\Yaml\Dumper as YmlDumper; +use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Exception\RuntimeException; @@ -118,7 +120,7 @@ private function addService($id, $definition) if ($callable = $definition->getConfigurator()) { if (is_array($callable)) { - if (is_object($callable[0]) && $callable[0] instanceof Reference) { + if ($callable[0] instanceof Reference) { $callable = array($this->getServiceCall((string) $callable[0], $callable[0]), $callable[1]); } else { $callable = array($callable[0], $callable[1]); @@ -135,7 +137,7 @@ private function addService($id, $definition) * Adds a service alias * * @param string $alias - * @param string $id + * @param Alias $id * * @return string */ @@ -196,6 +198,8 @@ private function addParameters() * * @param mixed $value * + * @return mixed + * * @throws RuntimeException When trying to dump object or resource */ private function dumpValue($value) @@ -207,9 +211,9 @@ private function dumpValue($value) } return $code; - } elseif (is_object($value) && $value instanceof Reference) { + } elseif ($value instanceof Reference) { return $this->getServiceCall((string) $value, $value); - } elseif (is_object($value) && $value instanceof Parameter) { + } elseif ($value instanceof Parameter) { return $this->getParameterCall((string) $value); } elseif (is_object($value) || is_resource($value)) { throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/FileLoader.php index 0699ab981775..ad437b5138d4 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -13,7 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\Loader\FileLoader as BaseFileLoader; -use Symfony\Component\Config\FileLocator; +use Symfony\Component\Config\FileLocatorInterface; /** * FileLoader is the abstract class used by all built-in loaders that are file based. @@ -28,9 +28,9 @@ abstract class FileLoader extends BaseFileLoader * Constructor. * * @param ContainerBuilder $container A ContainerBuilder instance - * @param FileLocator $locator A FileLocator instance + * @param FileLocatorInterface $locator A FileLocator instance */ - public function __construct(ContainerBuilder $container, FileLocator $locator) + public function __construct(ContainerBuilder $container, FileLocatorInterface $locator) { $this->container = $container; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 5329195cdb8a..6f2c8eba1ada 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -11,13 +11,13 @@ namespace Symfony\Component\DependencyInjection\Loader; +use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\SimpleXMLElement; -use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; @@ -200,9 +200,11 @@ private function parseDefinition($id, $service, $file) * * @param string $file Path to a file * - * @throws InvalidArgumentException When loading of XML file returns error + * @return SimpleXMLElement + * + * @throws \InvalidArgumentException When loading of XML file returns error */ - private function parseFile($file) + protected function parseFile($file) { $internalErrors = libxml_use_internal_errors(true); $disableEntities = libxml_disable_entity_loader(true); @@ -213,7 +215,7 @@ private function parseFile($file) if (!$dom->loadXML(file_get_contents($file), LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) { libxml_disable_entity_loader($disableEntities); - throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors($internalErrors))); + throw new InvalidArgumentException(implode("\n", $this->getXmlErrors($internalErrors))); } $dom->normalizeDocument(); @@ -222,7 +224,7 @@ private function parseFile($file) foreach ($dom->childNodes as $child) { if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { - throw new \InvalidArgumentException('Document types are not allowed.'); + throw new InvalidArgumentException('Document types are not allowed.'); } } @@ -286,8 +288,8 @@ private function processAnonymousServices(SimpleXMLElement $xml, $file) /** * Validates an XML document. * - * @param DOMDocument $dom - * @param string $file + * @param \DOMDocument $dom + * @param string $file */ private function validate(\DOMDocument $dom, $file) { @@ -302,7 +304,7 @@ private function validate(\DOMDocument $dom, $file) * @param string $file * * @throws RuntimeException When extension references a non-existent XSD file - * @throws InvalidArgumentException When XML doesn't validate its XSD schema + * @throws InvalidArgumentException When xml doesn't validate its xsd schema */ private function validateSchema(\DOMDocument $dom, $file) { @@ -404,6 +406,8 @@ private function validateExtensions(\DOMDocument $dom, $file) /** * Returns an array of XML errors. * + * @param Boolean $internalErrors + * * @return array */ private function getXmlErrors($internalErrors) diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 63f3893ab617..71de4ac6592f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -119,6 +119,8 @@ private function parseDefinitions($content, $file) * @param string $id * @param array $service * @param string $file + * + * @throws InvalidArgumentException When tags are invalid */ private function parseDefinition($id, $service, $file) { @@ -231,7 +233,7 @@ private function parseDefinition($id, $service, $file) * * @return array The file content */ - private function loadFile($file) + protected function loadFile($file) { return $this->validate(Yaml::parse($file), $file); } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 908e2a146fa2..70f3956e3c9c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -84,7 +84,7 @@ public function all() * * @return mixed The parameter value * - * @throws ParameterNotFoundException if the parameter is not defined + * @throws ParameterNotFoundException if the parameter is not defined * * @api */ @@ -129,13 +129,13 @@ public function has($name) /** * Removes a parameter. * - * @param string $key The key + * @param string $name The parameter name * * @api */ - public function remove($key) + public function remove($name) { - unset($this->parameters[$key]); + unset($this->parameters[strtolower($name)]); } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md index 5cb62cf1c489..ab6759524040 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md @@ -68,9 +68,6 @@ Resources You can run the unit tests with the following command: - phpunit - -If you also want to run the unit tests that depend on other Symfony -Components, install dev dependencies before running PHPUnit: - - php composer.phar install --dev + $ cd path/to/Symfony/Component/DependencyInjection/ + $ composer.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index 1be51061446b..95b395399141 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -98,7 +98,7 @@ public function testGetServiceIds() $this->assertEquals(array('service_container', 'foo', 'bar'), $sc->getServiceIds(), '->getServiceIds() returns all defined service ids'); $sc = new ProjectServiceContainer(); - $this->assertEquals(array('scoped', 'scoped_foo', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'service_container'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods'); + $this->assertEquals(array('scoped', 'scoped_foo', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'service_container'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods'); } /** @@ -367,6 +367,27 @@ public function testGetThrowsException() } } + public function testGetThrowsExceptionOnServiceConfiguration() + { + $c = new ProjectServiceContainer(); + + try { + $c->get('throws_exception_on_service_configuration'); + $this->fail('The container can not contain invalid service!'); + } catch (\Exception $e) { + $this->assertEquals('Something was terribly wrong while trying to configure the service!', $e->getMessage()); + } + $this->assertFalse($c->initialized('throws_exception_on_service_configuration')); + + try { + $c->get('throws_exception_on_service_configuration'); + $this->fail('The container can not contain invalid service!'); + } catch (\Exception $e) { + $this->assertEquals('Something was terribly wrong while trying to configure the service!', $e->getMessage()); + } + $this->assertFalse($c->initialized('throws_exception_on_service_configuration')); + } + public function getInvalidParentScopes() { return array( @@ -447,4 +468,11 @@ protected function getThrowExceptionService() { throw new \Exception('Something went terribly wrong!'); } + + protected function getThrowsExceptionOnServiceConfigurationService() + { + $this->services['throws_exception_on_service_configuration'] = $instance = new \stdClass(); + + throw new \Exception('Something was terribly wrong while trying to configure the service!'); + } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index c1513b63ea40..a0d2ece432ff 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -65,7 +65,7 @@ protected function getFooService() { $a = $this->get('foo.baz'); - $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo'), 'bar' => $this->getParameter('foo')), true, $this); + $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'bar' => $this->getParameter('foo')), true, $this); $instance->setBar($this->get('bar')); $instance->initialize(); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php index 46fb35837152..968ae9bcf5f4 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php @@ -54,6 +54,8 @@ public function testRemove() )); $bag->remove('foo'); $this->assertEquals(array('bar' => 'bar'), $bag->all(), '->remove() removes a parameter'); + $bag->remove('BAR'); + $this->assertEquals(array(), $bag->all(), '->remove() converts key to lowercase before removing'); } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/bootstrap.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/bootstrap.php deleted file mode 100644 index fd3118fc361c..000000000000 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/bootstrap.php +++ /dev/null @@ -1,22 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\DependencyInjection')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\DependencyInjection')).'.php')) { - require_once $file; - } - } -}); - -if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) { - require_once $loader; -} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json index 81811c39a25b..d951f3041d29 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json @@ -19,21 +19,21 @@ "php": ">=5.3.3" }, "require-dev": { - "symfony/yaml": "2.1.*", - "symfony/config": "2.1.*" + "symfony/yaml": "2.2.*", + "symfony/config": "2.2.*" }, "suggest": { - "symfony/yaml": "self.version", - "symfony/config": "self.version" + "symfony/yaml": "2.2.*", + "symfony/config": "2.2.*" }, "autoload": { - "psr-0": { "Symfony\\Component\\DependencyInjection": "" } + "psr-0": { "Symfony\\Component\\DependencyInjection\\": "" } }, "target-dir": "Symfony/Component/DependencyInjection", "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist index 554d1046b52c..53f5f99d6002 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="Tests/bootstrap.php" + bootstrap="vendor/autoload.php" > <testsuites> <testsuite name="Symfony DependencyInjection Component Test Suite"> diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitattributes b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore index d1502b087b4d..44de97a36a6d 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore @@ -1,2 +1,4 @@ vendor/ composer.lock +phpunit.xml + diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php index fc2c0d4eac69..42f09eaa5118 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php @@ -74,11 +74,11 @@ public function stopPropagation() /** * Stores the EventDispatcher that dispatches this Event * - * @param EventDispatcher $dispatcher + * @param EventDispatcherInterface $dispatcher * * @api */ - public function setDispatcher(EventDispatcher $dispatcher) + public function setDispatcher(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; } @@ -86,7 +86,7 @@ public function setDispatcher(EventDispatcher $dispatcher) /** * Returns the EventDispatcher that dispatches this Event * - * @return EventDispatcher + * @return EventDispatcherInterface * * @api */ diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md index a2bcfca1e354..11f6b1888e39 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md @@ -20,9 +20,6 @@ Resources You can run the unit tests with the following command: - phpunit - -If you also want to run the unit tests that depend on other Symfony -Components, install dev dependencies before running PHPUnit: - - php composer.phar install --dev + $ cd path/to/Symfony/Component/EventDispatcher/ + $ composer.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/bootstrap.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/bootstrap.php deleted file mode 100644 index 033180fd3fb2..000000000000 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/bootstrap.php +++ /dev/null @@ -1,22 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\EventDispatcher')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\EventDispatcher')).'.php')) { - require_once $file; - } - } -}); - -if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) { - require_once $loader; -} diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json index 93abadeaca77..1a90992fd186 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json @@ -19,20 +19,20 @@ "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": "2.1.*" + "symfony/dependency-injection": "2.2.*" }, "suggest": { - "symfony/dependency-injection": "self.version", - "symfony/http-kernel": "self.version" + "symfony/dependency-injection": "2.2.*", + "symfony/http-kernel": "2.2.*" }, "autoload": { - "psr-0": { "Symfony\\Component\\EventDispatcher": "" } + "psr-0": { "Symfony\\Component\\EventDispatcher\\": "" } }, "target-dir": "Symfony/Component/EventDispatcher", "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } } } diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist index c5571353a650..0c3de4f7b214 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="Tests/bootstrap.php" + bootstrap="vendor/autoload.php" > <testsuites> <testsuite name="Symfony EventDispatcher Component Test Suite"> diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitattributes b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore new file mode 100644 index 000000000000..44de97a36a6d --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore @@ -0,0 +1,4 @@ +vendor/ +composer.lock +phpunit.xml + diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php new file mode 100644 index 000000000000..48c10c153f56 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php @@ -0,0 +1,172 @@ +<?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\Component\HttpFoundation; + +/** + * Represents an Accept-* header. + * + * An accept header is compound with a list of items, + * sorted by descending quality. + * + * @author Jean-François Simon <contact@jfsimon.fr> + */ +class AcceptHeader +{ + /** + * @var AcceptHeaderItem[] + */ + private $items = array(); + + /** + * @var bool + */ + private $sorted = true; + + /** + * Constructor. + * + * @param AcceptHeaderItem[] $items + */ + public function __construct(array $items) + { + foreach ($items as $item) { + $this->add($item); + } + } + + /** + * Builds an AcceptHeader instance from a string. + * + * @param string $headerValue + * + * @return AcceptHeader + */ + public static function fromString($headerValue) + { + $index = 0; + + return new self(array_map(function ($itemValue) use (&$index) { + $item = AcceptHeaderItem::fromString($itemValue); + $item->setIndex($index++); + + return $item; + }, preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/', $headerValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE))); + } + + /** + * Returns header value's string representation. + * + * @return string + */ + public function __toString() + { + return implode(',', $this->items); + } + + /** + * Tests if header has given value. + * + * @param string $value + * + * @return Boolean + */ + public function has($value) + { + return isset($this->items[$value]); + } + + /** + * Returns given value's item, if exists. + * + * @param string $value + * + * @return AcceptHeaderItem|null + */ + public function get($value) + { + return isset($this->items[$value]) ? $this->items[$value] : null; + } + + /** + * Adds an item. + * + * @param AcceptHeaderItem $item + * + * @return AcceptHeader + */ + public function add(AcceptHeaderItem $item) + { + $this->items[$item->getValue()] = $item; + $this->sorted = false; + + return $this; + } + + /** + * Returns all items. + * + * @return AcceptHeaderItem[] + */ + public function all() + { + $this->sort(); + + return $this->items; + } + + /** + * Filters items on their value using given regex. + * + * @param string $pattern + * + * @return AcceptHeader + */ + public function filter($pattern) + { + return new self(array_filter($this->items, function (AcceptHeaderItem $item) use ($pattern) { + return preg_match($pattern, $item->getValue()); + })); + } + + /** + * Returns first item. + * + * @return AcceptHeaderItem|null + */ + public function first() + { + $this->sort(); + + return !empty($this->items) ? reset($this->items) : null; + } + + /** + * Sorts items by descending quality + */ + private function sort() + { + if (!$this->sorted) { + uasort($this->items, function ($a, $b) { + $qA = $a->getQuality(); + $qB = $b->getQuality(); + + if ($qA === $qB) { + return $a->getIndex() > $b->getIndex() ? 1 : -1; + } + + return $qA > $qB ? -1 : 1; + }); + + $this->sorted = true; + } + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php new file mode 100644 index 000000000000..9d4c3132d32e --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php @@ -0,0 +1,226 @@ +<?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\Component\HttpFoundation; + +/** + * Represents an Accept-* header item. + * + * @author Jean-François Simon <contact@jfsimon.fr> + */ +class AcceptHeaderItem +{ + /** + * @var string + */ + private $value; + + /** + * @var float + */ + private $quality = 1.0; + + /** + * @var int + */ + private $index = 0; + + /** + * @var array + */ + private $attributes = array(); + + /** + * Constructor. + * + * @param string $value + * @param array $attributes + */ + public function __construct($value, array $attributes = array()) + { + $this->value = $value; + foreach ($attributes as $name => $value) { + $this->setAttribute($name, $value); + } + } + + /** + * Builds an AcceptHeaderInstance instance from a string. + * + * @param string $itemValue + * + * @return AcceptHeaderItem + */ + public static function fromString($itemValue) + { + $bits = preg_split('/\s*(?:;*("[^"]+");*|;*(\'[^\']+\');*|;+)\s*/', $itemValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); + $value = array_shift($bits); + $attributes = array(); + + $lastNullAttribute = null; + foreach ($bits as $bit) { + if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ($start === '"' || $start === '\'')) { + $attributes[$lastNullAttribute] = substr($bit, 1, -1); + } elseif ('=' === $end) { + $lastNullAttribute = $bit = substr($bit, 0, -1); + $attributes[$bit] = null; + } else { + $parts = explode('=', $bit); + $attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : ''; + } + } + + return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'') ? substr($value, 1, -1) : $value, $attributes); + } + + /** + * Returns header value's string representation. + * + * @return string + */ + public function __toString() + { + $string = $this->value.($this->quality < 1 ? ';q='.$this->quality : ''); + if (count($this->attributes) > 0) { + $string .= ';'.implode(';', array_map(function($name, $value) { + return sprintf(preg_match('/[,;=]/', $value) ? '%s="%s"' : '%s=%s', $name, $value); + }, array_keys($this->attributes), $this->attributes)); + } + + return $string; + } + + /** + * Set the item value. + * + * @param string $value + * + * @return AcceptHeaderItem + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Returns the item value. + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set the item quality. + * + * @param float $quality + * + * @return AcceptHeaderItem + */ + public function setQuality($quality) + { + $this->quality = $quality; + + return $this; + } + + /** + * Returns the item quality. + * + * @return float + */ + public function getQuality() + { + return $this->quality; + } + + /** + * Set the item index. + * + * @param int $index + * + * @return AcceptHeaderItem + */ + public function setIndex($index) + { + $this->index = $index; + + return $this; + } + + /** + * Returns the item index. + * + * @return int + */ + public function getIndex() + { + return $this->index; + } + + /** + * Tests if an attribute exists. + * + * @param string $name + * + * @return Boolean + */ + public function hasAttribute($name) + { + return isset($this->attributes[$name]); + } + + /** + * Returns an attribute by its name. + * + * @param string $name + * @param mixed $default + * + * @return mixed + */ + public function getAttribute($name, $default = null) + { + return isset($this->attributes[$name]) ? $this->attributes[$name] : $default; + } + + /** + * Returns all attributes. + * + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Set an attribute. + * + * @param string $name + * @param string $value + * + * @return AcceptHeaderItem + */ + public function setAttribute($name, $value) + { + if ('q' === $name) { + $this->quality = (float) $value; + } else { + $this->attributes[$name] = (string) $value; + } + + return $this; + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php new file mode 100644 index 000000000000..080a4408552e --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -0,0 +1,259 @@ +<?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\Component\HttpFoundation; + +use Symfony\Component\HttpFoundation\File\File; +use Symfony\Component\HttpFoundation\File\Exception\FileException; + +/** + * BinaryFileResponse represents an HTTP response delivering a file. + * + * @author Niklas Fiekas <niklas.fiekas@tu-clausthal.de> + * @author stealth35 <stealth35-php@live.fr> + * @author Igor Wiedler <igor@wiedler.ch> + * @author Jordan Alliot <jordan.alliot@gmail.com> + * @author Sergey Linnik <linniksa@gmail.com> + */ +class BinaryFileResponse extends Response +{ + protected static $trustXSendfileTypeHeader = false; + + protected $file; + protected $offset; + protected $maxlen; + + /** + * Constructor. + * + * @param SplFileInfo|string $file The file to stream + * @param integer $status The response status code + * @param array $headers An array of response headers + * @param boolean $public Files are public by default + * @param null|string $contentDisposition The type of Content-Disposition to set automatically with the filename + * @param boolean $autoEtag Whether the ETag header should be automatically set + * @param boolean $autoLastModified Whether the Last-Modified header should be automatically set + */ + public function __construct($file, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) + { + parent::__construct(null, $status, $headers); + + $this->setFile($file, $contentDisposition, $autoEtag, $autoLastModified); + + if ($public) { + $this->setPublic(); + } + } + + /** + * {@inheritdoc} + */ + public static function create($file = null, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) + { + return new static($file, $status, $headers, $public, $contentDisposition, $autoEtag, $autoLastModified); + } + + /** + * Sets the file to stream. + * + * @param SplFileInfo|string $file The file to stream + */ + public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) + { + $file = new File((string) $file); + + if (!$file->isReadable()) { + throw new FileException('File must be readable.'); + } + + $this->file = $file; + + if ($autoEtag) { + $this->setAutoEtag(); + } + + if ($autoLastModified) { + $this->setAutoLastModified(); + } + + if ($contentDisposition) { + $this->setContentDisposition($contentDisposition); + } + + return $this; + } + + /** + * Gets the file. + * + * @return File The file to stream + */ + public function getFile() + { + return $this->file; + } + + /** + * Automatically sets the Last-Modified header according the file modification date. + */ + public function setAutoLastModified() + { + $this->setLastModified(\DateTime::createFromFormat('U', $this->file->getMTime())); + + return $this; + } + + /** + * Automatically sets the ETag header according to the checksum of the file. + */ + public function setAutoEtag() + { + $this->setEtag(sha1_file($this->file->getPathname())); + + return $this; + } + + /** + * Sets the Content-Disposition header with the given filename. + * + * @param string $disposition ResponseHeaderBag::DISPOSITION_INLINE or ResponseHeaderBag::DISPOSITION_ATTACHMENT + * @param string $filename Optionally use this filename instead of the real name of the file + * @param string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename + */ + public function setContentDisposition($disposition, $filename = '', $filenameFallback = '') + { + if ($filename === '') { + $filename = $this->file->getFilename(); + } + + $dispositionHeader = $this->headers->makeDisposition($disposition, $filename, $filenameFallback); + $this->headers->set('Content-Disposition', $dispositionHeader); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function prepare(Request $request) + { + $this->headers->set('Content-Length', $this->file->getSize()); + $this->headers->set('Accept-Ranges', 'bytes'); + $this->headers->set('Content-Transfer-Encoding', 'binary'); + + if (!$this->headers->has('Content-Type')) { + $this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream'); + } + + if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { + $this->setProtocolVersion('1.1'); + } + + $this->offset = 0; + $this->maxlen = -1; + + if (self::$trustXSendfileTypeHeader && $request->headers->has('X-Sendfile-Type')) { + // Use X-Sendfile, do not send any content. + $type = $request->headers->get('X-Sendfile-Type'); + $path = $this->file->getRealPath(); + if (strtolower($type) == 'x-accel-redirect') { + // Do X-Accel-Mapping substitutions. + foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { + $mapping = explode('=', $mapping, 2); + + if (2 == count($mapping)) { + $location = trim($mapping[0]); + $pathPrefix = trim($mapping[1]); + + if (substr($path, 0, strlen($pathPrefix)) == $pathPrefix) { + $path = $location . substr($path, strlen($pathPrefix)); + break; + } + } + } + } + $this->headers->set($type, $path); + $this->maxlen = 0; + } elseif ($request->headers->has('Range')) { + // Process the range headers. + if (!$request->headers->has('If-Range') || $this->getEtag() == $request->headers->get('If-Range')) { + $range = $request->headers->get('Range'); + + list($start, $end) = array_map('intval', explode('-', substr($range, 6), 2)) + array(0); + + if ('' !== $end) { + $this->maxlen = $end - $start; + } else { + $end = $this->file->getSize() - 1; + } + + $this->offset = $start; + + $this->setStatusCode(206); + $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $this->file->getSize())); + } + } + } + + /** + * Sends the file. + */ + public function sendContent() + { + if (!$this->isSuccessful()) { + parent::sendContent(); + + return; + } + + if (0 === $this->maxlen) { + return; + } + + $out = fopen('php://output', 'wb'); + $file = fopen($this->file->getPathname(), 'rb'); + + stream_copy_to_stream($file, $out, $this->maxlen, $this->offset); + + fclose($out); + fclose($file); + } + + /** + * {@inheritdoc} + * + * @throws \LogicException when the content is not null + */ + public function setContent($content) + { + if (null !== $content) { + throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.'); + } + } + + /** + * {@inheritdoc} + * + * @return false + */ + public function getContent() + { + return false; + } + + /** + * Trust X-Sendfile-Type header. + */ + public static function trustXSendfileTypeHeader() + { + self::$trustXSendfileTypeHeader = true; + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md index 4a00207e6700..4b7d0c64ace5 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +2.2.0 +----- + + * added Request::getRealMethod() to get the "real" HTTP method (getMethod() returns the "intended" HTTP method) + * disabled _method request parameter support by default (call Request::enableHttpMethodParameterOverride() to enable it) + * Request::splitHttpAcceptHeader() method is deprecated and will be removed in 2.3 + 2.1.0 ----- diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php index 188f0c3b1d4f..d3d20f583a6f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php @@ -115,7 +115,7 @@ public function move($directory, $name = null) throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); } - $target = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : basename($name)); + $target = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); if (!@rename($this->getPathname(), $target)) { $error = error_get_last(); @@ -126,4 +126,20 @@ public function move($directory, $name = null) return new File($target); } + + /** + * Returns locale independent base name of the given path. + * + * @param string $name The new file name + * + * @return string containing + */ + protected function getName($name) + { + $originalName = str_replace('\\', '/', $name); + $pos = strrpos($originalName, '/'); + $originalName = false === $pos ? $originalName : substr($originalName, $pos + 1); + + return $originalName; + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php index 6d6dda1bb1a4..4bf920ef0f32 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -94,7 +94,7 @@ public function __construct($path, $originalName, $mimeType = null, $size = null throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path'))); } - $this->originalName = basename($originalName); + $this->originalName = $this->getName($originalName); $this->mimeType = $mimeType ?: 'application/octet-stream'; $this->size = $size; $this->error = $error ?: UPLOAD_ERR_OK; @@ -118,6 +118,19 @@ public function getClientOriginalName() return $this->originalName; } + /** + * Returns the original file extension + * + * It is extracted from the original file name that was uploaded. + * Then is should not be considered as a safe value. + * + * @return string The extension + */ + public function getClientOriginalExtension() + { + return pathinfo($this->originalName, PATHINFO_EXTENSION); + } + /** * Returns the file mime type. * @@ -166,7 +179,7 @@ public function getError() /** * Returns whether the file was uploaded successfully. * - * @return Boolean True if no error occurred during uploading + * @return Boolean True if no error occurred during uploading * * @api */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php index bb579b64f9dc..f26899d007ba 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php @@ -223,7 +223,9 @@ public function remove($key) * @param string $key The parameter key * @param \DateTime $default The default value * - * @return \DateTime The filtered value + * @return null|\DateTime The filtered value + * + * @throws \RuntimeException When the HTTP header is not parseable * * @api */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md index bb6f02c443c5..ed49b4e15e41 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md @@ -31,7 +31,7 @@ the HTTP specification. Loading ------- -If you are using PHP 5.3.x you must add the following to your autoloader: +If you are not using Composer but are using PHP 5.3.x, you must add the following to your autoloader: // SessionHandlerInterface if (!interface_exists('SessionHandlerInterface')) { @@ -43,4 +43,6 @@ Resources You can run the unit tests with the following command: - phpunit + $ cd path/to/Symfony/Component/HttpFoundation/ + $ composer.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php index 848c3d118ab9..a0f02a49a3fd 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php @@ -30,8 +30,31 @@ */ class Request { + const HEADER_CLIENT_IP = 'client_ip'; + const HEADER_CLIENT_HOST = 'client_host'; + const HEADER_CLIENT_PROTO = 'client_proto'; + const HEADER_CLIENT_PORT = 'client_port'; + protected static $trustProxy = false; + protected static $trustedProxies = array(); + + /** + * Names for headers that can be trusted when + * using trusted proxies. + * + * The default names are non-standard, but widely used + * by popular reverse proxies (like Apache mod_proxy or Amazon EC2). + */ + protected static $trustedHeaders = array( + self::HEADER_CLIENT_IP => 'X_FORWARDED_FOR', + self::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST', + self::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO', + self::HEADER_CLIENT_PORT => 'X_FORWARDED_PORT', + ); + + protected static $httpMethodParameterOverride = false; + /** * @var \Symfony\Component\HttpFoundation\ParameterBag * @@ -217,7 +240,7 @@ public static function createFromGlobals() { $request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER); - if (0 === strpos($request->server->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') + if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH')) ) { parse_str($request->getContent(), $data); @@ -286,7 +309,7 @@ public static function create($uri, $method = 'GET', $parameters = array(), $coo } if (!isset($components['path'])) { - $components['path'] = ''; + $components['path'] = '/'; } switch (strtoupper($method)) { @@ -439,16 +462,52 @@ public function overrideGlobals() /** * Trusts $_SERVER entries coming from proxies. * - * You should only call this method if your application - * is hosted behind a reverse proxy that you manage. - * - * @api + * @deprecated Deprecated since version 2.0, to be removed in 2.3. Use setTrustedProxies instead. */ public static function trustProxyData() { self::$trustProxy = true; } + /** + * Sets a list of trusted proxies. + * + * You should only list the reverse proxies that you manage directly. + * + * @param array $proxies A list of trusted proxies + * + * @api + */ + public static function setTrustedProxies(array $proxies) + { + self::$trustedProxies = $proxies; + self::$trustProxy = $proxies ? true : false; + } + + /** + * Sets the name for trusted headers. + * + * The following header keys are supported: + * + * * Request::HEADER_CLIENT_IP: defaults to X-Forwarded-For (see getClientIp()) + * * Request::HEADER_CLIENT_HOST: defaults to X-Forwarded-Host (see getClientHost()) + * * Request::HEADER_CLIENT_PORT: defaults to X-Forwarded-Port (see getClientPort()) + * * Request::HEADER_CLIENT_PROTO: defaults to X-Forwarded-Proto (see getScheme() and isSecure()) + * + * Setting an empty value allows to disable the trusted header for the given key. + * + * @param string $key The header key + * @param string $value The header name + */ + public static function setTrustedHeaderName($key, $value) + { + if (!array_key_exists($key, self::$trustedHeaders)) { + throw new \InvalidArgumentException(sprintf('Unable to set the trusted header name for key "%s".', $key)); + } + + self::$trustedHeaders[$key] = $value; + } + /** * Returns true if $_SERVER entries coming from proxies are trusted, * false otherwise. @@ -503,12 +562,25 @@ public static function normalizeQueryString($qs) return implode('&', $parts); } + /** + * Enables support for the _method request parameter to determine the intended HTTP method. + * + * Be warned that enabling this feature might lead to CSRF issues in your code. + * Check that you are using CSRF tokens when required. + * + * The HTTP method can only be overriden when the real HTTP method is POST. + */ + public static function enableHttpMethodParameterOverride() + { + self::$httpMethodParameterOverride = true; + } + /** * Gets a "parameter" value. * * This method is mainly useful for libraries that want to provide some flexibility. * - * Order of precedence: GET, PATH, POST, COOKIE + * Order of precedence: GET, PATH, POST * * Avoid using this method in controllers: * @@ -516,7 +588,7 @@ public static function normalizeQueryString($qs) * * prefer to get from a "named" source * * It is better to explicitly get request parameters from the appropriate - * public property instead (query, request, attributes, ...). + * public property instead (query, attributes, request). * * @param string $key the key * @param mixed $default the default value @@ -545,7 +617,7 @@ public function getSession() * Whether the request contains a Session which was started in one of the * previous requests. * - * @return boolean + * @return Boolean * * @api */ @@ -558,7 +630,11 @@ public function hasPreviousSession() /** * Whether the request contains a Session object. * - * @return boolean + * This method does not give any information about the state of the session object, + * like whether the session is started or not. It is just a way to check if this Request + * is associated with a Session instance. + * + * @return Boolean true when the Request contains a Session object, false otherwise * * @api */ @@ -582,31 +658,43 @@ public function setSession(SessionInterface $session) /** * Returns the client IP address. * + * This method can read the client IP address from the "X-Forwarded-For" header + * when trusted proxies were set via "setTrustedProxies()". The "X-Forwarded-For" + * header value is a comma+space separated list of IP addresses, the left-most + * being the original client, and each successive proxy that passed the request + * adding the IP address where it received the request from. + * + * If your reverse proxy uses a different header name than "X-Forwarded-For", + * ("Client-Ip" for instance), configure it via "setTrustedHeaderName()" with + * the "client-ip" key. + * * @return string The client IP address * + * @see http://en.wikipedia.org/wiki/X-Forwarded-For + * + * @deprecated The proxy argument is deprecated since version 2.0 and will be removed in 2.3. Use setTrustedProxies instead. + * * @api */ public function getClientIp() { - if (self::$trustProxy) { - if ($this->server->has('HTTP_CLIENT_IP')) { - return $this->server->get('HTTP_CLIENT_IP'); - } elseif ($this->server->has('HTTP_X_FORWARDED_FOR')) { - $clientIp = explode(',', $this->server->get('HTTP_X_FORWARDED_FOR')); - - foreach ($clientIp as $ipAddress) { - $cleanIpAddress = trim($ipAddress); + $ip = $this->server->get('REMOTE_ADDR'); - if (false !== filter_var($cleanIpAddress, FILTER_VALIDATE_IP)) { - return $cleanIpAddress; - } - } + if (!self::$trustProxy) { + return $ip; + } - return ''; - } + if (!self::$trustedHeaders[self::HEADER_CLIENT_IP] || !$this->headers->has(self::$trustedHeaders[self::HEADER_CLIENT_IP])) { + return $ip; } - return $this->server->get('REMOTE_ADDR'); + $clientIps = array_map('trim', explode(',', $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_IP]))); + $clientIps[] = $ip; + + $trustedProxies = self::$trustProxy && !self::$trustedProxies ? array($ip) : self::$trustedProxies; + $clientIps = array_diff($clientIps, $trustedProxies); + + return array_pop($clientIps); } /** @@ -705,14 +793,22 @@ public function getScheme() /** * Returns the port on which the request is made. * + * This method can read the client port from the "X-Forwarded-Port" header + * when trusted proxies were set via "setTrustedProxies()". + * + * The "X-Forwarded-Port" header must contain the client port. + * + * If your reverse proxy uses a different header name than "X-Forwarded-Port", + * configure it via "setTrustedHeaderName()" with the "client-port" key. + * * @return string * * @api */ public function getPort() { - if (self::$trustProxy && $this->headers->has('X-Forwarded-Port')) { - return $this->headers->get('X-Forwarded-Port'); + if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_PORT] && $port = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PORT])) { + return $port; } return $this->server->get('SERVER_PORT'); @@ -795,11 +891,14 @@ public function getRequestUri() /** * Gets the scheme and HTTP host. * + * If the URL was called with basic authentication, the user + * and the password are not added to the generated string. + * * @return string The scheme and HTTP host */ public function getSchemeAndHttpHost() { - return $this->getScheme().'://'.(('' != $auth = $this->getUserInfo()) ? $auth.'@' : '').$this->getHttpHost(); + return $this->getScheme().'://'.$this->getHttpHost(); } /** @@ -855,31 +954,46 @@ public function getQueryString() /** * Checks whether the request is secure or not. * + * This method can read the client port from the "X-Forwarded-Proto" header + * when trusted proxies were set via "setTrustedProxies()". + * + * The "X-Forwarded-Proto" header must contain the protocol: "https" or "http". + * + * If your reverse proxy uses a different header name than "X-Forwarded-Proto" + * ("SSL_HTTPS" for instance), configure it via "setTrustedHeaderName()" with + * the "client-proto" key. + * * @return Boolean * * @api */ public function isSecure() { - return ( - (strtolower($this->server->get('HTTPS')) == 'on' || $this->server->get('HTTPS') == 1) - || - (self::$trustProxy && strtolower($this->headers->get('SSL_HTTPS')) == 'on' || $this->headers->get('SSL_HTTPS') == 1) - || - (self::$trustProxy && strtolower($this->headers->get('X_FORWARDED_PROTO')) == 'https') - ); + if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) { + return in_array(strtolower($proto), array('https', 'on', '1')); + } + + return 'on' == strtolower($this->server->get('HTTPS')) || 1 == $this->server->get('HTTPS'); } /** * Returns the host name. * + * This method can read the client port from the "X-Forwarded-Host" header + * when trusted proxies were set via "setTrustedProxies()". + * + * The "X-Forwarded-Host" header must contain the client host name. + * + * If your reverse proxy uses a different header name than "X-Forwarded-Host", + * configure it via "setTrustedHeaderName()" with the "client-host" key. + * * @return string * * @api */ public function getHost() { - if (self::$trustProxy && $host = $this->headers->get('X_FORWARDED_HOST')) { + if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) { $elements = explode(',', $host); $host = trim($elements[count($elements) - 1]); @@ -912,26 +1026,51 @@ public function setMethod($method) } /** - * Gets the request method. + * Gets the request "intended" method. + * + * If the X-HTTP-Method-Override header is set, and if the method is a POST, + * then it is used to determine the "real" intended HTTP method. + * + * The _method request parameter can also be used to determine the HTTP method, + * but only if enableHttpMethodParameterOverride() has been called. * * The method is always an uppercased string. * * @return string The request method * * @api + * + * @see getRealMethod */ public function getMethod() { if (null === $this->method) { $this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET')); + if ('POST' === $this->method) { - $this->method = strtoupper($this->headers->get('X-HTTP-METHOD-OVERRIDE', $this->request->get('_method', $this->query->get('_method', 'POST')))); + if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) { + $this->method = strtoupper($method); + } elseif (self::$httpMethodParameterOverride) { + $this->method = strtoupper($this->request->get('_method', $this->query->get('_method', 'POST'))); + } } } return $this->method; } + /** + * Gets the "real" request method. + * + * @return string The request method + * + * @see getMethod + */ + public function getRealMethod() + { + return strtoupper($this->server->get('REQUEST_METHOD', 'GET')); + } + /** * Gets the mime type associated with the format. * @@ -1040,7 +1179,7 @@ public function setRequestFormat($format) */ public function getContentType() { - return $this->getFormat($this->server->get('CONTENT_TYPE')); + return $this->getFormat($this->headers->get('CONTENT_TYPE')); } /** @@ -1052,7 +1191,11 @@ public function getContentType() */ public function setDefaultLocale($locale) { - $this->setPhpDefaultLocale($this->defaultLocale = $locale); + $this->defaultLocale = $locale; + + if (null === $this->locale) { + $this->setPhpDefaultLocale($locale); + } } /** @@ -1184,9 +1327,9 @@ public function getLanguages() return $this->languages; } - $languages = $this->splitHttpAcceptHeader($this->headers->get('Accept-Language')); + $languages = AcceptHeader::fromString($this->headers->get('Accept-Language'))->all(); $this->languages = array(); - foreach ($languages as $lang => $q) { + foreach (array_keys($languages) as $lang) { if (strstr($lang, '-')) { $codes = explode('-', $lang); if ($codes[0] == 'i') { @@ -1226,7 +1369,7 @@ public function getCharsets() return $this->charsets; } - return $this->charsets = array_keys($this->splitHttpAcceptHeader($this->headers->get('Accept-Charset'))); + return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all()); } /** @@ -1242,7 +1385,7 @@ public function getAcceptableContentTypes() return $this->acceptableContentTypes; } - return $this->acceptableContentTypes = array_keys($this->splitHttpAcceptHeader($this->headers->get('Accept'))); + return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all()); } /** @@ -1266,32 +1409,21 @@ public function isXmlHttpRequest() * @param string $header Header to split * * @return array Array indexed by the values of the Accept-* header in preferred order + * + * @deprecated Deprecated since version 2.2, to be removed in 2.3. */ public function splitHttpAcceptHeader($header) { - if (!$header) { - return array(); - } - - $values = array(); - foreach (array_filter(explode(',', $header)) as $value) { - // Cut off any q-value that might come after a semi-colon - if (preg_match('/;\s*(q=.*$)/', $value, $match)) { - $q = (float) substr(trim($match[1]), 2); - $value = trim(substr($value, 0, -strlen($match[0]))); - } else { - $q = 1; - } - - if (0 < $q) { - $values[trim($value)] = $q; + $headers = array(); + foreach (AcceptHeader::fromString($header)->all() as $item) { + $key = $item->getValue(); + foreach ($item->getAttributes() as $name => $value) { + $key .= sprintf(';%s=%s', $name, $value); } + $headers[$key] = $item->getQuality(); } - arsort($values); - reset($values); - - return $values; + return $headers; } /* @@ -1306,8 +1438,11 @@ protected function prepareRequestUri() { $requestUri = ''; - if ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) { - // check this first so IIS will catch + if ($this->headers->has('X_ORIGINAL_URL') && false !== stripos(PHP_OS, 'WIN')) { + // IIS with Microsoft Rewrite Module + $requestUri = $this->headers->get('X_ORIGINAL_URL'); + } elseif ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) { + // IIS with ISAPI_Rewrite $requestUri = $this->headers->get('X_REWRITE_URL'); } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') { // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem) diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php index 2982952c0280..7371d17242ba 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -33,7 +33,7 @@ class RequestMatcher implements RequestMatcherInterface /** * @var array */ - private $methods; + private $methods = array(); /** * @var string @@ -41,19 +41,26 @@ class RequestMatcher implements RequestMatcherInterface private $ip; /** - * Attributes. - * * @var array */ - private $attributes; + private $attributes = array(); + /** + * @param string|null $path + * @param string|null $host + * @param string|string[]|null $methods + * @param string|null $ip + * @param array $attributes + */ public function __construct($path = null, $host = null, $methods = null, $ip = null, array $attributes = array()) { - $this->path = $path; - $this->host = $host; - $this->methods = $methods; - $this->ip = $ip; - $this->attributes = $attributes; + $this->matchPath($path); + $this->matchHost($host); + $this->matchMethod($methods); + $this->matchIp($ip); + foreach ($attributes as $k => $v) { + $this->matchAttribute($k, $v); + } } /** @@ -89,11 +96,11 @@ public function matchIp($ip) /** * Adds a check for the HTTP method. * - * @param string|array $method An HTTP method or an array of HTTP methods + * @param string|string[]|null $method An HTTP method or an array of HTTP methods */ public function matchMethod($method) { - $this->methods = array_map('strtoupper', is_array($method) ? $method : array($method)); + $this->methods = array_map('strtoupper', (array) $method); } /** @@ -114,7 +121,7 @@ public function matchAttribute($key, $regexp) */ public function matches(Request $request) { - if (null !== $this->methods && !in_array($request->getMethod(), $this->methods)) { + if ($this->methods && !in_array($request->getMethod(), $this->methods)) { return false; } @@ -132,7 +139,7 @@ public function matches(Request $request) } } - if (null !== $this->host && !preg_match('#'.str_replace('#', '\\#', $this->host).'#', $request->getHost())) { + if (null !== $this->host && !preg_match('#'.str_replace('#', '\\#', $this->host).'#i', $request->getHost())) { return false; } @@ -198,13 +205,13 @@ protected function checkIp4($requestIp, $ip) */ protected function checkIp6($requestIp, $ip) { - if (!defined('AF_INET6')) { + if (!((extension_loaded('sockets') && defined('AF_INET6')) || @inet_pton('::1'))) { throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".'); } if (false !== strpos($ip, '/')) { list($address, $netmask) = explode('/', $ip, 2); - + if ($netmask < 1 || $netmask > 128) { return false; } @@ -228,3 +235,4 @@ protected function checkIp6($requestIp, $ip) return true; } } + diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php index 1d2106e2a1d7..b6bbfc2d9374 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php @@ -50,6 +50,8 @@ public function close(); /** * Read session. * + * @param string $sessionId + * * @see http://php.net/sessionhandlerinterface.read * * @throws \RuntimeException On fatal error but not "record not found". diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php index dbc82d1b61bc..ac56f9b2df56 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php @@ -231,7 +231,7 @@ public function prepare(Request $request) $headers->remove('Content-Length'); } - if ('HEAD' === $request->getMethod()) { + if ($request->isMethod('HEAD')) { // cf. RFC2616 14.13 $length = $headers->get('Content-Length'); $this->setContent(null); @@ -240,6 +240,11 @@ public function prepare(Request $request) } } + // Fix protocol + if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { + $this->setProtocolVersion('1.1'); + } + return $this; } @@ -259,7 +264,7 @@ public function sendHeaders() header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)); // headers - foreach ($this->headers->all() as $name => $values) { + foreach ($this->headers->allPreserveCase() as $name => $values) { foreach ($values as $value) { header($name.': '.$value, false); } @@ -574,7 +579,7 @@ public function mustRevalidate() */ public function getDate() { - return $this->headers->getDate('Date'); + return $this->headers->getDate('Date', new \DateTime()); } /** @@ -1097,7 +1102,7 @@ public function isOk() } /** - * Is the reponse forbidden? + * Is the response forbidden? * * @return Boolean * diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index c27d8116083a..531e003fb7bf 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -36,6 +36,11 @@ class ResponseHeaderBag extends HeaderBag */ protected $cookies = array(); + /** + * @var array + */ + protected $headerNames = array(); + /** * Constructor. * @@ -48,7 +53,7 @@ public function __construct(array $headers = array()) parent::__construct($headers); if (!isset($this->headers['cache-control'])) { - $this->set('cache-control', ''); + $this->set('Cache-Control', ''); } } @@ -65,6 +70,16 @@ public function __toString() return parent::__toString().$cookies; } + /** + * Returns the headers, with original capitalizations. + * + * @return array An array of headers + */ + public function allPreserveCase() + { + return array_combine($this->headerNames, $this->headers); + } + /** * {@inheritdoc} * @@ -72,10 +87,12 @@ public function __toString() */ public function replace(array $headers = array()) { + $this->headerNames = array(); + parent::replace($headers); if (!isset($this->headers['cache-control'])) { - $this->set('cache-control', ''); + $this->set('Cache-Control', ''); } } @@ -88,10 +105,14 @@ public function set($key, $values, $replace = true) { parent::set($key, $values, $replace); + $uniqueKey = strtr(strtolower($key), '_', '-'); + $this->headerNames[$uniqueKey] = $key; + // ensure the cache-control header has sensible defaults - if (in_array(strtr(strtolower($key), '_', '-'), array('cache-control', 'etag', 'last-modified', 'expires'))) { + if (in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'))) { $computed = $this->computeCacheControlValue(); $this->headers['cache-control'] = array($computed); + $this->headerNames['cache-control'] = 'Cache-Control'; $this->computedCacheControl = $this->parseCacheControl($computed); } } @@ -105,7 +126,10 @@ public function remove($key) { parent::remove($key); - if ('cache-control' === strtr(strtolower($key), '_', '-')) { + $uniqueKey = strtr(strtolower($key), '_', '-'); + unset($this->headerNames[$uniqueKey]); + + if ('cache-control' === $uniqueKey) { $this->computedCacheControl = array(); } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php index 352321f55619..fcb41cc5ee0a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php @@ -23,7 +23,7 @@ class ServerBag extends ParameterBag /** * Gets the HTTP headers. * - * @return string + * @return array */ public function getHeaders() { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php index 9ae5a3dd63ac..a68dcfddda84 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php @@ -31,18 +31,18 @@ public function add($type, $message); /** * Registers a message for a given type. * - * @param string $type - * @param string $message + * @param string $type + * @param string|array $message */ public function set($type, $message); /** - * Gets flash message for a given type. + * Gets flash messages for a given type. * * @param string $type Message category type. - * @param array $default Default value if $type doee not exist. + * @param array $default Default value if $type does not exist. * - * @return string + * @return array */ public function peek($type, array $default = array()); @@ -57,9 +57,9 @@ public function peekAll(); * Gets and clears flash from the stack. * * @param string $type - * @param array $default Default value if $type doee not exist. + * @param array $default Default value if $type does not exist. * - * @return string + * @return array */ public function get($type, array $default = array()); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index e8293e4dde46..4a262aade344 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -36,6 +36,13 @@ class MongoDbSessionHandler implements \SessionHandlerInterface /** * Constructor. * + * List of available options: + * * database: The name of the database [required] + * * collection: The name of the collection [required] + * * id_field: The field name for storing the session id [default: _id] + * * data_field: The field name for storing the session data [default: data] + * * time_field: The field name for storing the timestamp [default: time] + * * @param \Mongo $mongo A "Mongo" instance * @param array $options An associative array of field options * @@ -50,9 +57,9 @@ public function __construct(\Mongo $mongo, array $options) $this->mongo = $mongo; $this->options = array_merge(array( - 'id_field' => 'sess_id', - 'data_field' => 'sess_data', - 'time_field' => 'sess_time', + 'id_field' => '_id', + 'data_field' => 'data', + 'time_field' => 'time', ), $options); } @@ -77,10 +84,9 @@ public function close() */ public function destroy($sessionId) { - $this->getCollection()->remove( - array($this->options['id_field'] => $sessionId), - array('justOne' => true) - ); + $this->getCollection()->remove(array( + $this->options['id_field'] => $sessionId + )); return true; } @@ -90,11 +96,21 @@ public function destroy($sessionId) */ public function gc($lifetime) { - $time = new \MongoTimestamp(time() - $lifetime); + /* Note: MongoDB 2.2+ supports TTL collections, which may be used in + * place of this method by indexing the "time_field" field with an + * "expireAfterSeconds" option. Regardless of whether TTL collections + * are used, consider indexing this field to make the remove query more + * efficient. + * + * See: http://docs.mongodb.org/manual/tutorial/expire-data/ + */ + $time = new \MongoDate(time() - $lifetime); $this->getCollection()->remove(array( $this->options['time_field'] => array('$lt' => $time), )); + + return true; } /** @@ -102,16 +118,13 @@ public function gc($lifetime) */ public function write($sessionId, $data) { - $data = array( - $this->options['id_field'] => $sessionId, - $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY), - $this->options['time_field'] => new \MongoTimestamp() - ); - $this->getCollection()->update( array($this->options['id_field'] => $sessionId), - array('$set' => $data), - array('upsert' => true) + array('$set' => array( + $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY), + $this->options['time_field'] => new \MongoDate(), + )), + array('upsert' => true, 'multiple' => false) ); return true; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index 9c4c5aa3d1ff..487dbc41e50e 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -168,7 +168,9 @@ public function write($id, $data) $encoded = base64_encode($data); try { - if ('mysql' === $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { + $driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); + + if ('mysql' === $driver) { // MySQL would report $stmt->rowCount() = 0 on UPDATE when the data is left unchanged // it could result in calling createNewSession() whereas the session already exists in // the DB which would fail as the id is unique @@ -180,6 +182,14 @@ public function write($id, $data) $stmt->bindParam(':data', $encoded, \PDO::PARAM_STR); $stmt->bindValue(':time', time(), \PDO::PARAM_INT); $stmt->execute(); + } elseif ('oci' === $driver) { + $stmt = $this->pdo->prepare("MERGE INTO $dbTable USING DUAL ON($dbIdCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($dbIdCol, $dbDataCol, $dbTimeCol) VALUES (:id, :data, sysdate) " . + "WHEN MATCHED THEN UPDATE SET $dbDataCol = :data WHERE $dbIdCol = :id"); + + $stmt->bindParam(':id', $id, \PDO::PARAM_STR); + $stmt->bindParam(':data', $encoded, \PDO::PARAM_STR); + $stmt->execute(); } else { $stmt = $this->pdo->prepare("UPDATE $dbTable SET $dbDataCol = :data, $dbTimeCol = :time WHERE $dbIdCol = :id"); $stmt->bindParam(':id', $id, \PDO::PARAM_STR); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 4a7d360fbb6c..f23ca3a7fd3f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -27,17 +27,17 @@ class NativeSessionStorage implements SessionStorageInterface /** * Array of SessionBagInterface * - * @var array + * @var SessionBagInterface[] */ protected $bags; /** - * @var boolean + * @var Boolean */ protected $started = false; /** - * @var boolean + * @var Boolean */ protected $closed = false; @@ -55,7 +55,7 @@ class NativeSessionStorage implements SessionStorageInterface * Constructor. * * Depending on how you want the storage driver to behave you probably - * want top override this constructor entirely. + * want to override this constructor entirely. * * List of options for $options array with their defaults. * @see http://php.net/session.configuration for options diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php index 5dcb1c315a9b..53bdbe64805e 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -76,10 +76,6 @@ public function setCallback($callback) */ public function prepare(Request $request) { - if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { - $this->setProtocolVersion('1.1'); - } - $this->headers->set('Cache-Control', 'no-cache'); return parent::prepare($request); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php new file mode 100644 index 000000000000..582fbdefe172 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php @@ -0,0 +1,112 @@ +<?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\Component\HttpFoundation\Tests; + +use Symfony\Component\HttpFoundation\AcceptHeaderItem; + +class AcceptHeaderItemTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideFromStringData + */ + public function testFromString($string, $value, array $attributes) + { + $item = AcceptHeaderItem::fromString($string); + $this->assertEquals($value, $item->getValue()); + $this->assertEquals($attributes, $item->getAttributes()); + } + + public function provideFromStringData() + { + return array( + array( + 'text/html', + 'text/html', array() + ), + array( + '"this;should,not=matter"', + 'this;should,not=matter', array() + ), + array( + "text/plain; charset=utf-8;param=\"this;should,not=matter\";\tfootnotes=true", + 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true') + ), + array( + '"this;should,not=matter";charset=utf-8', + 'this;should,not=matter', array('charset' => 'utf-8') + ), + ); + } + + /** + * @dataProvider provideToStringData + */ + public function testToString($value, array $attributes, $string) + { + $item = new AcceptHeaderItem($value, $attributes); + $this->assertEquals($string, (string) $item); + } + + public function provideToStringData() + { + return array( + array( + 'text/html', array(), + 'text/html' + ), + array( + 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'), + 'text/plain;charset=utf-8;param="this;should,not=matter";footnotes=true' + ), + ); + } + + public function testValue() + { + $item = new AcceptHeaderItem('value', array()); + $this->assertEquals('value', $item->getValue()); + + $item->setValue('new value'); + $this->assertEquals('new value', $item->getValue()); + + $item->setValue(1); + $this->assertEquals('1', $item->getValue()); + } + + public function testQuality() + { + $item = new AcceptHeaderItem('value', array()); + $this->assertEquals(1.0, $item->getQuality()); + + $item->setQuality(0.5); + $this->assertEquals(0.5, $item->getQuality()); + + $item->setAttribute('q', 0.75); + $this->assertEquals(0.75, $item->getQuality()); + $this->assertFalse($item->hasAttribute('q')); + } + + public function testAttribute() + { + $item = new AcceptHeaderItem('value', array()); + $this->assertEquals(array(), $item->getAttributes()); + $this->assertFalse($item->hasAttribute('test')); + $this->assertNull($item->getAttribute('test')); + $this->assertEquals('default', $item->getAttribute('test', 'default')); + + $item->setAttribute('test', 'value'); + $this->assertEquals(array('test' => 'value'), $item->getAttributes()); + $this->assertTrue($item->hasAttribute('test')); + $this->assertEquals('value', $item->getAttribute('test')); + $this->assertEquals('value', $item->getAttribute('test', 'default')); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php new file mode 100644 index 000000000000..9b3b58e21424 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php @@ -0,0 +1,102 @@ +<?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\Component\HttpFoundation\Tests; + +use Symfony\Component\HttpFoundation\AcceptHeader; +use Symfony\Component\HttpFoundation\AcceptHeaderItem; + +class AcceptHeaderTest extends \PHPUnit_Framework_TestCase +{ + public function testFirst() + { + $header = AcceptHeader::fromString('text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c'); + $this->assertSame('text/html', $header->first()->getValue()); + } + + /** + * @dataProvider provideFromStringData + */ + public function testFromString($string, array $items) + { + $header = AcceptHeader::fromString($string); + $parsed = array_values($header->all()); + // reset index since the fixtures don't have them set + foreach ($parsed as $item) { + $item->setIndex(0); + } + $this->assertEquals($items, $parsed); + } + + public function provideFromStringData() + { + return array( + array('', array()), + array('gzip', array(new AcceptHeaderItem('gzip'))), + array('gzip,deflate,sdch', array(new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch'))), + array("gzip, deflate\t,sdch", array(new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch'))), + array('"this;should,not=matter"', array(new AcceptHeaderItem('this;should,not=matter'))), + ); + } + + /** + * @dataProvider provideToStringData + */ + public function testToString(array $items, $string) + { + $header = new AcceptHeader($items); + $this->assertEquals($string, (string) $header); + } + + public function provideToStringData() + { + return array( + array(array(), ''), + array(array(new AcceptHeaderItem('gzip')), 'gzip'), + array(array(new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')), 'gzip,deflate,sdch'), + array(array(new AcceptHeaderItem('this;should,not=matter')), 'this;should,not=matter'), + ); + } + + /** + * @dataProvider provideFilterData + */ + public function testFilter($string, $filter, array $values) + { + $header = AcceptHeader::fromString($string)->filter($filter); + $this->assertEquals($values, array_keys($header->all())); + } + + public function provideFilterData() + { + return array( + array('fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4', '/fr.*/', array('fr-FR', 'fr')), + ); + } + + /** + * @dataProvider provideSortingData + */ + public function testSorting($string, array $values) + { + $header = AcceptHeader::fromString($string); + $this->assertEquals($values, array_keys($header->all())); + } + + public function provideSortingData() + { + return array( + 'quality has priority' => array('*;q=0.3,ISO-8859-1,utf-8;q=0.7', array('ISO-8859-1', 'utf-8', '*')), + 'order matters when q is equal' => array('*;q=0.3,ISO-8859-1;q=0.7,utf-8;q=0.7', array('ISO-8859-1', 'utf-8', '*')), + 'order matters when q is equal2' => array('*;q=0.3,utf-8;q=0.7,ISO-8859-1;q=0.7', array('utf-8', 'ISO-8859-1', '*')), + ); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php new file mode 100644 index 000000000000..23f93f7a763a --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -0,0 +1,124 @@ +<?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\Component\HttpFoundation\Tests; + +use Symfony\Component\HttpFoundation\BinaryFileResponse; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\ResponseHeaderBag; + +class BinaryFileResponseTest extends \PHPUnit_Framework_TestCase +{ + public function testConstruction() + { + $response = new BinaryFileResponse('README.md', 404, array('X-Header' => 'Foo'), true, null, true, true); + $this->assertEquals(404, $response->getStatusCode()); + $this->assertEquals('Foo', $response->headers->get('X-Header')); + $this->assertTrue($response->headers->has('ETag')); + $this->assertTrue($response->headers->has('Last-Modified')); + $this->assertFalse($response->headers->has('Content-Disposition')); + + $response = BinaryFileResponse::create('README.md', 404, array(), true, ResponseHeaderBag::DISPOSITION_INLINE); + $this->assertEquals(404, $response->getStatusCode()); + $this->assertFalse($response->headers->has('ETag')); + $this->assertEquals('inline; filename="README.md"', $response->headers->get('Content-Disposition')); + } + + /** + * @expectedException \LogicException + */ + public function testSetContent() + { + $response = new BinaryFileResponse('README.md'); + $response->setContent('foo'); + } + + public function testGetContent() + { + $response = new BinaryFileResponse('README.md'); + $this->assertFalse($response->getContent()); + } + + public function testRequests() + { + $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag(); + + // do a request to get the ETag + $request = Request::create('/'); + $response->prepare($request); + $etag = $response->headers->get('ETag'); + + // prepare a request for a range of the testing file + $request = Request::create('/'); + $request->headers->set('If-Range', $etag); + $request->headers->set('Range', 'bytes=1-4'); + + $this->expectOutputString('IF8'); + $response = clone $response; + $response->prepare($request); + $response->sendContent(); + + $this->assertEquals('binary', $response->headers->get('Content-Transfer-Encoding')); + } + + public function testXSendfile() + { + $request = Request::create('/'); + $request->headers->set('X-Sendfile-Type', 'X-Sendfile'); + + BinaryFileResponse::trustXSendfileTypeHeader(); + $response = BinaryFileResponse::create('README.md'); + $response->prepare($request); + + $this->expectOutputString(''); + $response->sendContent(); + + $this->assertContains('README.md', $response->headers->get('X-Sendfile')); + } + + /** + * @dataProvider getSampleXAccelMappings + */ + public function testXAccelMapping($realpath, $mapping, $virtual) + { + $request = Request::create('/'); + $request->headers->set('X-Sendfile-Type', 'X-Accel-Redirect'); + $request->headers->set('X-Accel-Mapping', $mapping); + + $file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File') + ->disableOriginalConstructor() + ->getMock(); + $file->expects($this->any()) + ->method('getRealPath') + ->will($this->returnValue($realpath)); + $file->expects($this->any()) + ->method('isReadable') + ->will($this->returnValue(true)); + + BinaryFileResponse::trustXSendFileTypeHeader(); + $response = new BinaryFileResponse('README.md'); + $reflection = new \ReflectionObject($response); + $property = $reflection->getProperty('file'); + $property->setAccessible(true); + $property->setValue($response, $file); + + $response->prepare($request); + $this->assertEquals($virtual, $response->headers->get('X-Accel-Redirect')); + } + + public function getSampleXAccelMappings() + { + return array( + array('/var/www/var/www/files/foo.txt', '/files/=/var/www/', '/files/var/www/files/foo.txt'), + array('/home/foo/bar.txt', '/files/=/var/www/,/baz/=/home/foo/', '/baz/bar.txt'), + ); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 6a9948d62ab2..721cc3cd9e77 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -79,6 +79,23 @@ public function testGetExpiresTime() $this->assertEquals(3600, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); } + public function testConstructorWithDateTime() + { + $expire = new \DateTime(); + $cookie = new Cookie('foo', 'bar', $expire); + + $this->assertEquals($expire->format('U'), $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); + } + + public function testGetExpiresTimeWithStringValue() + { + $value = "+1 day"; + $cookie = new Cookie('foo', 'bar', $value); + $expire = strtotime($value); + + $this->assertEquals($expire, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); + } + public function testGetDomain() { $cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com'); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php index 0744e83a778e..b64d5f512153 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php @@ -91,6 +91,41 @@ public function testMoveWithNewName() @unlink($targetPath); } + public function getFilenameFixtures() + { + return array( + array('original.gif', 'original.gif'), + array('..\\..\\original.gif', 'original.gif'), + array('../../original.gif', 'original.gif'), + array('файлfile.gif', 'файлfile.gif'), + array('..\\..\\файлfile.gif', 'файлfile.gif'), + array('../../файлfile.gif', 'файлfile.gif'), + ); + } + + /** + * @dataProvider getFilenameFixtures + */ + public function testMoveWithNonLatinName($filename, $sanitizedFilename) + { + $path = __DIR__.'/Fixtures/'.$sanitizedFilename; + $targetDir = __DIR__.'/Fixtures/directory/'; + $targetPath = $targetDir.$sanitizedFilename; + @unlink($path); + @unlink($targetPath); + copy(__DIR__.'/Fixtures/test.gif', $path); + + $file = new File($path); + $movedFile = $file->move($targetDir,$filename); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile); + + $this->assertTrue(file_exists($targetPath)); + $this->assertFalse(file_exists($path)); + $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); + + @unlink($targetPath); + } + public function testMoveToAnUnexistentDirectory() { $sourcePath = __DIR__.'/Fixtures/test.copy.gif'; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index b42a3fc89cb4..ae12aa0476f1 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php @@ -89,6 +89,20 @@ public function testGetClientOriginalName() $this->assertEquals('original.gif', $file->getClientOriginalName()); } + public function testGetClientOriginalExtension() + { + $file = new UploadedFile( + __DIR__.'/Fixtures/test.gif', + 'original.gif', + 'image/gif', + filesize(__DIR__.'/Fixtures/test.gif'), + null + ); + + $this->assertEquals('gif', $file->getClientOriginalExtension()); + } + + /** * @expectedException Symfony\Component\HttpFoundation\File\Exception\FileException */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php index bafccb2eba25..20d3603038ca 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php @@ -24,6 +24,49 @@ public function testConstructor() $this->assertTrue($bag->has('foo')); } + public function testToStringNull() + { + $bag = new HeaderBag(); + $this->assertEquals('', $bag->__toString()); + } + + public function testToStringNotNull() + { + $bag = new HeaderBag(array('foo' => 'bar')); + $this->assertEquals("Foo: bar\r\n", $bag->__toString()); + } + + public function testKeys() + { + $bag = new HeaderBag(array('foo' => 'bar')); + $keys = $bag->keys(); + $this->assertEquals("foo", $keys[0]); + } + + public function testGetDate() + { + $bag = new HeaderBag(array('foo' => 'Tue, 4 Sep 2012 20:00:00 +0200')); + $headerDate = $bag->getDate('foo'); + $this->assertInstanceOf('DateTime', $headerDate); + } + + /** + * @expectedException \RuntimeException + */ + public function testGetDateException() + { + $bag = new HeaderBag(array('foo' => 'Tue')); + $headerDate = $bag->getDate('foo'); + } + + public function testGetCacheControlHeader() + { + $bag = new HeaderBag(); + $bag->addCacheControlDirective('public', '#a'); + $this->assertTrue($bag->hasCacheControlDirective('public')); + $this->assertEquals('#a', $bag->getCacheControlDirective('public')); + } + /** * @covers Symfony\Component\HttpFoundation\HeaderBag::all */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index a89da9325a9a..8f1383fba9b8 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -13,11 +13,6 @@ use Symfony\Component\HttpFoundation\JsonResponse; -/** - * @covers Symfony\Component\HttpFoundation\JsonResponse::__construct - * @covers Symfony\Component\HttpFoundation\JsonResponse::setData - * @covers Symfony\Component\HttpFoundation\JsonResponse::setCallback - */ class JsonResponseTest extends \PHPUnit_Framework_TestCase { public function testConstructorEmptyCreatesJsonObject() @@ -89,6 +84,73 @@ public function testCreate() $this->assertEquals(204, $response->getStatusCode()); } + public function testStaticCreateEmptyJsonObject() + { + $response = JsonResponse::create(); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertSame('{}', $response->getContent()); + } + + public function testStaticCreateJsonArray() + { + $response = JsonResponse::create(array(0, 1, 2, 3)); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertSame('[0,1,2,3]', $response->getContent()); + } + + public function testStaticCreateJsonObject() + { + $response = JsonResponse::create(array('foo' => 'bar')); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertSame('{"foo":"bar"}', $response->getContent()); + } + + public function testStaticCreateWithSimpleTypes() + { + $response = JsonResponse::create('foo'); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertSame('"foo"', $response->getContent()); + + $response = JsonResponse::create(0); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertSame('0', $response->getContent()); + + $response = JsonResponse::create(0.1); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertSame('0.1', $response->getContent()); + + $response = JsonResponse::create(true); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertSame('true', $response->getContent()); + } + + public function testStaticCreateWithCustomStatus() + { + $response = JsonResponse::create(array(), 202); + $this->assertSame(202, $response->getStatusCode()); + } + + public function testStaticCreateAddsContentTypeHeader() + { + $response = JsonResponse::create(); + $this->assertSame('application/json', $response->headers->get('Content-Type')); + } + + public function testStaticCreateWithCustomHeaders() + { + $response = JsonResponse::create(array(), 200, array('ETag' => 'foo')); + $this->assertSame('application/json', $response->headers->get('Content-Type')); + $this->assertSame('foo', $response->headers->get('ETag')); + } + + public function testStaticCreateWithCustomContentType() + { + $headers = array('Content-Type' => 'application/vnd.acme.blog-v1+json'); + + $response = JsonResponse::create(array(), 200, $headers); + $this->assertSame('application/vnd.acme.blog-v1+json', $response->headers->get('Content-Type')); + } + public function testSetCallback() { $response = JsonResponse::create(array('foo' => 'bar'))->setCallback('callback'); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php index c3c0b16bfd5a..6cd42bf91dd0 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php @@ -32,6 +32,28 @@ public function testAll() $this->assertEquals(array('foo' => 'bar'), $bag->all(), '->all() gets all the input'); } + public function testKeys() + { + $bag = new ParameterBag(array('foo' => 'bar')); + $this->assertEquals(array('foo'), $bag->keys()); + } + + public function testAdd() + { + $bag = new ParameterBag(array('foo' => 'bar')); + $bag->add(array('bar' => 'bas')); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'bas'), $bag->all()); + } + + public function testRemove() + { + $bag = new ParameterBag(array('foo' => 'bar')); + $bag->add(array('bar' => 'bas')); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'bas'), $bag->all()); + $bag->remove('bar'); + $this->assertEquals(array('foo' => 'bar'), $bag->all()); + } + /** * @covers Symfony\Component\HttpFoundation\ParameterBag::replace */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php index b55c3b63d72c..330d9fee51fb 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php @@ -25,6 +25,22 @@ public function testGenerateMetaRedirect() )); } + /** + * @expectedException \InvalidArgumentException + */ + public function testRedirectResponseConstructorNullUrl() + { + $response = new RedirectResponse(null); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testRedirectResponseConstructorWrongStatusCode() + { + $response = new RedirectResponse('foo.bar', 404); + } + public function testGenerateLocationHeader() { $response = new RedirectResponse('foo.bar'); @@ -48,6 +64,15 @@ public function testSetTargetUrl() $this->assertEquals('baz.beep', $response->getTargetUrl()); } + /** + * @expectedException \InvalidArgumentException + */ + public function testSetTargetUrlNull() + { + $response = new RedirectResponse('foo.bar'); + $response->setTargetUrl(null); + } + public function testCreate() { $response = RedirectResponse::create('foo', 301); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php index 32ca1e5246f4..0e7b9eff662b 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php @@ -88,38 +88,59 @@ public function testAnIpv6WithOptionDisabledIpv6() } } - public function testMethod() + /** + * @dataProvider testMethodFixtures + */ + public function testMethod($requestMethod, $matcherMethod, $isMatch) { $matcher = new RequestMatcher(); + $matcher->matchMethod($matcherMethod); + $request = Request::create('', $requestMethod); + $this->assertSame($isMatch, $matcher->matches($request)); - $matcher->matchMethod('get'); - $request = Request::create('', 'get'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchMethod('post'); - $this->assertFalse($matcher->matches($request)); + $matcher = new RequestMatcher(null, null, $matcherMethod); + $request = Request::create('', $requestMethod); + $this->assertSame($isMatch, $matcher->matches($request)); + } - $matcher->matchMethod(array('get', 'post')); - $this->assertTrue($matcher->matches($request)); + public function testMethodFixtures() + { + return array( + array('get', 'get', true), + array('get', array('get', 'post'), true), + array('get', 'post', false), + array('get', 'GET', true), + array('get', array('GET', 'POST'), true), + array('get', 'POST', false), + ); } - public function testHost() + /** + * @dataProvider testHostFixture + */ + public function testHost($pattern, $isMatch) { $matcher = new RequestMatcher(); - $request = Request::create('', 'get', array(), array(), array(), array('HTTP_HOST' => 'foo.example.com')); - $matcher->matchHost('.*\.example\.com'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchHost('\.example\.com$'); - $this->assertTrue($matcher->matches($request)); + $matcher->matchHost($pattern); + $this->assertSame($isMatch, $matcher->matches($request)); - $matcher->matchHost('^.*\.example\.com$'); - $this->assertTrue($matcher->matches($request)); + $matcher= new RequestMatcher(null, $pattern); + $this->assertSame($isMatch, $matcher->matches($request)); + } - $matcher->matchMethod('.*\.sensio\.com'); - $this->assertFalse($matcher->matches($request)); + public function testHostFixture() + { + return array( + array('.*\.example\.com', true), + array('\.example\.com$', true), + array('^.*\.example\.com$', true), + array('.*\.sensio\.com', false), + array('.*\.example\.COM', true), + array('\.example\.COM$', true), + array('^.*\.example\.COM$', true), + array('.*\.sensio\.COM', false), ); } public function testPath() @@ -179,3 +200,4 @@ public function testAttributes() $this->assertFalse($matcher->matches($request)); } } + diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 1e447c52f02b..cb5720825566 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -45,6 +45,55 @@ public function testInitialize() $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its fourth argument'); } + public function testGetLocale() + { + $request = new Request(); + $request->setLocale('pl'); + $locale = $request->getLocale(); + $this->assertEquals('pl', $locale); + } + + public function testGetUser() + { + $request = Request::create('http://user_test:password_test@test.com/'); + $user = $request->getUser(); + + $this->assertEquals('user_test', $user); + } + + public function testGetPassword() + { + $request = Request::create('http://user_test:password_test@test.com/'); + $password = $request->getPassword(); + + $this->assertEquals('password_test', $password); + } + + public function testIsNoCache() + { + $request = new Request(); + $isNoCache = $request->isNoCache(); + + $this->assertFalse($isNoCache); + } + + public function testGetContentType() + { + $request = new Request(); + $contentType = $request->getContentType(); + + $this->assertNull($contentType); + } + + public function testSetDefaultLocale() + { + $request = new Request(); + $request->setDefaultLocale('pl'); + $locale = $request->getLocale(); + + $this->assertEquals('pl', $locale); + } + /** * @covers Symfony\Component\HttpFoundation\Request::create */ @@ -127,6 +176,14 @@ public function testCreate() $this->assertEquals('test.com', $request->getHttpHost()); $this->assertFalse($request->isSecure()); + $request = Request::create('http://test.com?test=1'); + $this->assertEquals('http://test.com/?test=1', $request->getUri()); + $this->assertEquals('/', $request->getPathInfo()); + $this->assertEquals('test=1', $request->getQueryString()); + $this->assertEquals(80, $request->getPort()); + $this->assertEquals('test.com', $request->getHttpHost()); + $this->assertFalse($request->isSecure()); + $request = Request::create('http://test.com:90/?test=1'); $this->assertEquals('http://test.com:90/?test=1', $request->getUri()); $this->assertEquals('/', $request->getPathInfo()); @@ -136,7 +193,7 @@ public function testCreate() $this->assertFalse($request->isSecure()); $request = Request::create('http://test:test@test.com'); - $this->assertEquals('http://test:test@test.com/', $request->getUri()); + $this->assertEquals('http://test.com/', $request->getUri()); $this->assertEquals('/', $request->getPathInfo()); $this->assertEquals('', $request->getQueryString()); $this->assertEquals(80, $request->getPort()); @@ -146,7 +203,7 @@ public function testCreate() $this->assertFalse($request->isSecure()); $request = Request::create('http://testnopass@test.com'); - $this->assertEquals('http://testnopass@test.com/', $request->getUri()); + $this->assertEquals('http://test.com/', $request->getUri()); $this->assertEquals('/', $request->getPathInfo()); $this->assertEquals('', $request->getQueryString()); $this->assertEquals(80, $request->getPort()); @@ -340,11 +397,11 @@ public function testGetUri() $server['PHP_AUTH_USER'] = 'fabien'; $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://fabien@hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri()); + $this->assertEquals('http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri()); $server['PHP_AUTH_PW'] = 'symfony'; $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://fabien:symfony@hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri()); + $this->assertEquals('http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri()); } /** @@ -450,11 +507,11 @@ public function testGetUriForPath() $server['PHP_AUTH_USER'] = 'fabien'; $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://fabien@servername/some/path', $request->getUriForPath('/some/path')); + $this->assertEquals('http://servername/some/path', $request->getUriForPath('/some/path')); $server['PHP_AUTH_PW'] = 'symfony'; $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://fabien:symfony@servername/some/path', $request->getUriForPath('/some/path')); + $this->assertEquals('http://servername/some/path', $request->getUriForPath('/some/path')); } /** @@ -491,15 +548,15 @@ public function testGetSchemeAndHttpHost() $server['PHP_AUTH_USER'] = 'fabien'; $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://fabien@servername:90', $request->getSchemeAndHttpHost()); + $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); $server['PHP_AUTH_USER'] = '0'; $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://0@servername:90', $request->getSchemeAndHttpHost()); + $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); $server['PHP_AUTH_PW'] = '0'; $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://0:0@servername:90', $request->getSchemeAndHttpHost()); + $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); } /** @@ -565,33 +622,14 @@ public function testGetHost() $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.exemple.com')); $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from Host Header'); - // Host header with port number. + // Host header with port number $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.exemple.com:8080')); $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from Host Header with port number'); - // Server values. + // Server values $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com')); $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from server name'); - $this->startTrustingProxyData(); - // X_FORWARDED_HOST. - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_X_FORWARDED_HOST' => 'www.exemple.com')); - $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from X_FORWARDED_HOST'); - - // X_FORWARDED_HOST - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_X_FORWARDED_HOST' => 'www.exemple.com, www.second.com')); - $this->assertEquals('www.second.com', $request->getHost(), '->getHost() value from X_FORWARDED_HOST use last value'); - - // X_FORWARDED_HOST with port number - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_X_FORWARDED_HOST' => 'www.exemple.com, www.second.com:8080')); - $this->assertEquals('www.second.com', $request->getHost(), '->getHost() value from X_FORWARDED_HOST with port number'); - - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.exemple.com', 'HTTP_X_FORWARDED_HOST' => 'www.forward.com')); - $this->assertEquals('www.forward.com', $request->getHost(), '->getHost() value from X_FORWARDED_HOST has priority over Host'); - - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com', 'HTTP_X_FORWARDED_HOST' => 'www.forward.com')); - $this->assertEquals('www.forward.com', $request->getHost(), '->getHost() value from X_FORWARDED_HOST has priority over SERVER_NAME '); - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com', 'HTTP_HOST' => 'www.host.com')); $this->assertEquals('www.host.com', $request->getHost(), '->getHost() value from Host header has priority over SERVER_NAME '); $this->stopTrustingProxyData(); @@ -618,13 +656,28 @@ public function testGetSetMethod() $request->setMethod('POST'); $request->request->set('_method', 'purge'); + $this->assertEquals('POST', $request->getMethod(), '->getMethod() does not return the method from _method if defined and POST but support not enabled'); + + $request = new Request(); + $request->setMethod('POST'); + $request->request->set('_method', 'purge'); + Request::enableHttpMethodParameterOverride(); $this->assertEquals('PURGE', $request->getMethod(), '->getMethod() returns the method from _method if defined and POST'); + $this->disableHttpMethodParameterOverride(); + + $request = new Request(); + $request->setMethod('POST'); + $request->query->set('_method', 'purge'); + $this->assertEquals('POST', $request->getMethod(), '->getMethod() does not return the method from _method if defined and POST but support not enabled'); + $request = new Request(); $request->setMethod('POST'); - $request->request->remove('_method'); $request->query->set('_method', 'purge'); + Request::enableHttpMethodParameterOverride(); $this->assertEquals('PURGE', $request->getMethod(), '->getMethod() returns the method from _method if defined and POST'); + $this->disableHttpMethodParameterOverride(); + $request = new Request(); $request->setMethod('POST'); $request->headers->set('X-HTTP-METHOD-OVERRIDE', 'delete'); $this->assertEquals('DELETE', $request->getMethod(), '->getMethod() returns the method from X-HTTP-Method-Override even though _method is set if defined and POST'); @@ -638,42 +691,40 @@ public function testGetSetMethod() /** * @dataProvider testGetClientIpProvider */ - public function testGetClientIp($expected, $proxy, $remoteAddr, $httpClientIp, $httpForwardedFor) + public function testGetClientIp($expected, $proxy, $remoteAddr, $httpForwardedFor, $trustedProxies) { $request = new Request(); - $this->assertEquals('', $request->getClientIp()); $server = array('REMOTE_ADDR' => $remoteAddr); - if (null !== $httpClientIp) { - $server['HTTP_CLIENT_IP'] = $httpClientIp; - } if (null !== $httpForwardedFor) { $server['HTTP_X_FORWARDED_FOR'] = $httpForwardedFor; } + if ($proxy || $trustedProxies) { + Request::setTrustedProxies(null === $trustedProxies ? array($remoteAddr) : $trustedProxies); + } + $request->initialize(array(), array(), array(), array(), array(), $server); if ($proxy) { $this->startTrustingProxyData(); } $this->assertEquals($expected, $request->getClientIp($proxy)); - if ($proxy) { - $this->stopTrustingProxyData(); - } + + Request::setTrustedProxies(array()); } public function testGetClientIpProvider() { return array( - array('88.88.88.88', false, '88.88.88.88', null, null), - array('127.0.0.1', false, '127.0.0.1', '88.88.88.88', null), - array('88.88.88.88', true, '127.0.0.1', '88.88.88.88', null), - array('127.0.0.1', false, '127.0.0.1', null, '88.88.88.88'), - array('88.88.88.88', true, '127.0.0.1', null, '88.88.88.88'), - array('::1', false, '::1', null, null), - array('2620:0:1cfe:face:b00c::3', true, '::1', '2620:0:1cfe:face:b00c::3', null), - array('2620:0:1cfe:face:b00c::3', true, '::1', null, '2620:0:1cfe:face:b00c::3, ::1'), - array('88.88.88.88', true, '123.45.67.89', null, '88.88.88.88, 87.65.43.21, 127.0.0.1'), - array('88.88.88.88', true, '123.45.67.89', null, 'unknown, 88.88.88.88'), + array('88.88.88.88', false, '88.88.88.88', null, null), + array('127.0.0.1', false, '127.0.0.1', null, null), + array('::1', false, '::1', null, null), + array('127.0.0.1', false, '127.0.0.1', '88.88.88.88', null), + array('88.88.88.88', true, '127.0.0.1', '88.88.88.88', null), + array('2620:0:1cfe:face:b00c::3', true, '::1', '2620:0:1cfe:face:b00c::3', null), + array('88.88.88.88', true, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', null), + array('87.65.43.21', true, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '88.88.88.88')), + array('87.65.43.21', false, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '88.88.88.88')), ); } @@ -719,6 +770,10 @@ public function provideOverloadedMethods() array('PUT'), array('DELETE'), array('PATCH'), + array('put'), + array('delete'), + array('patch'), + ); } @@ -727,6 +782,8 @@ public function provideOverloadedMethods() */ public function testCreateFromGlobals($method) { + $normalizedMethod = strtoupper($method); + $_GET['foo1'] = 'bar1'; $_POST['foo2'] = 'bar2'; $_COOKIE['foo3'] = 'bar3'; @@ -745,19 +802,23 @@ public function testCreateFromGlobals($method) $_SERVER['REQUEST_METHOD'] = $method; $_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; $request = RequestContentProxy::createFromGlobals(); - $this->assertEquals($method, $request->getMethod()); + $this->assertEquals($normalizedMethod, $request->getMethod()); $this->assertEquals('mycontent', $request->request->get('content')); unset($_SERVER['REQUEST_METHOD'], $_SERVER['CONTENT_TYPE']); + Request::createFromGlobals(); + Request::enableHttpMethodParameterOverride(); $_POST['_method'] = $method; $_POST['foo6'] = 'bar6'; - $_SERVER['REQUEST_METHOD'] = 'POST'; + $_SERVER['REQUEST_METHOD'] = 'PoSt'; $request = Request::createFromGlobals(); - $this->assertEquals($method, $request->getMethod()); + $this->assertEquals($normalizedMethod, $request->getMethod()); + $this->assertEquals('POST', $request->getRealMethod()); $this->assertEquals('bar6', $request->request->get('foo6')); unset($_POST['_method'], $_POST['foo6'], $_SERVER['REQUEST_METHOD']); + $this->disableHttpMethodParameterOverride(); } public function testOverrideGlobals() @@ -782,8 +843,9 @@ public function testOverrideGlobals() $this->startTrustingProxyData(); $request->headers->set('X_FORWARDED_PROTO', 'https'); + Request::setTrustedProxies(array('1.1.1.1')); $this->assertTrue($request->isSecure()); - $this->stopTrustingProxyData(); + Request::setTrustedProxies(array()); $request->overrideGlobals(); @@ -900,6 +962,27 @@ public function testIsXmlHttpRequest() $this->assertFalse($request->isXmlHttpRequest()); } + public function testIntlLocale() + { + if (!extension_loaded('intl')) { + $this->markTestSkipped('The intl extension is needed to run this test.'); + } + + $request = new Request(); + + $request->setDefaultLocale('fr'); + $this->assertEquals('fr', $request->getLocale()); + $this->assertEquals('fr', \Locale::getDefault()); + + $request->setLocale('en'); + $this->assertEquals('en', $request->getLocale()); + $this->assertEquals('en', \Locale::getDefault()); + + $request->setDefaultLocale('de'); + $this->assertEquals('en', $request->getLocale()); + $this->assertEquals('en', \Locale::getDefault()); + } + public function testGetCharsets() { $request = new Request(); @@ -913,7 +996,7 @@ public function testGetCharsets() $request = new Request(); $request->headers->set('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); - $this->assertEquals(array('ISO-8859-1', '*', 'utf-8'), $request->getCharsets()); + $this->assertEquals(array('ISO-8859-1', 'utf-8', '*'), $request->getCharsets()); } public function testGetAcceptableContentTypes() @@ -925,7 +1008,7 @@ public function testGetAcceptableContentTypes() $request = new Request(); $request->headers->set('Accept', 'application/vnd.wap.wmlscriptc, text/vnd.wap.wml, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html, multipart/mixed, */*'); - $this->assertEquals(array('multipart/mixed', '*/*', 'text/html', 'application/xhtml+xml', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml', 'application/vnd.wap.wmlscriptc'), $request->getAcceptableContentTypes()); + $this->assertEquals(array('application/vnd.wap.wmlscriptc', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml', 'application/xhtml+xml', 'text/html', 'multipart/mixed', '*/*'), $request->getAcceptableContentTypes()); } public function testGetLanguages() @@ -938,6 +1021,18 @@ public function testGetLanguages() $this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages()); $this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages()); + $request = new Request(); + $request->headers->set('Accept-language', 'zh, en-us; q=0.6, en; q=0.8'); + $this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages()); // Test out of order qvalues + + $request = new Request(); + $request->headers->set('Accept-language', 'zh, en, en-us'); + $this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages()); // Test equal weighting without qvalues + + $request = new Request(); + $request->headers->set('Accept-language', 'zh; q=0.6, en, en-us; q=0.6'); + $this->assertEquals(array('en', 'zh', 'en_US'), $request->getLanguages()); // Test equal weighting with qvalues + $request = new Request(); $request->headers->set('Accept-language', 'zh, i-cherokee; q=0.6'); $this->assertEquals(array('zh', 'cherokee'), $request->getLanguages()); @@ -956,25 +1051,26 @@ public function testGetRequestFormat() $this->assertEquals('foo', $request->getRequestFormat(null)); } - public function testForwardedSecure() + public function testHasSession() { $request = new Request(); - $request->headers->set('X-Forwarded-Proto', 'https'); - $request->headers->set('X-Forwarded-Port', 443); - $this->startTrustingProxyData(); - $this->assertTrue($request->isSecure()); - $this->assertEquals(443, $request->getPort()); - $this->stopTrustingProxyData(); + $this->assertFalse($request->hasSession()); + $request->setSession(new Session(new MockArraySessionStorage())); + $this->assertTrue($request->hasSession()); } - public function testHasSession() + public function testGetSession() { $request = new Request(); - $this->assertFalse($request->hasSession()); $request->setSession(new Session(new MockArraySessionStorage())); $this->assertTrue($request->hasSession()); + + $session = $request->getSession(); + $this->assertObjectHasAttribute('storage', $session); + $this->assertObjectHasAttribute('flashName', $session); + $this->assertObjectHasAttribute('attributeName', $session); } public function testHasPreviousSession() @@ -1014,21 +1110,13 @@ public function splitHttpAcceptHeaderData() array('text/html;q=0.8', array('text/html' => 0.8)), array('text/html;foo=bar;q=0.8 ', array('text/html;foo=bar' => 0.8)), array('text/html;charset=utf-8; q=0.8', array('text/html;charset=utf-8' => 0.8)), - array('text/html,application/xml;q=0.9,*/*;charset=utf-8; q=0.8', array('text/html' => 1, 'application/xml' => 0.9, '*/*;charset=utf-8' => 0.8)), - array('text/html,application/xhtml+xml;q=0.9,*/*;q=0.8; foo=bar', array('text/html' => 1, 'application/xhtml+xml' => 0.9, '*/*' => 0.8)), - array('text/html,application/xhtml+xml;charset=utf-8;q=0.9; foo=bar,*/*', array('text/html' => 1, '*/*' => 1, 'application/xhtml+xml;charset=utf-8' => 0.9)), - array('text/html,application/xhtml+xml', array('application/xhtml+xml' => 1, 'text/html' => 1)), + array('text/html,application/xml;q=0.9,*/*;charset=utf-8; q=0.8', array('text/html' => 1.0, 'application/xml' => 0.9, '*/*;charset=utf-8' => 0.8)), + array('text/html,application/xhtml+xml;q=0.9,*/*;q=0.8; foo=bar', array('text/html' => 1.0, 'application/xhtml+xml' => 0.9, '*/*;foo=bar' => 0.8)), + array('text/html,application/xhtml+xml;charset=utf-8;q=0.9; foo=bar,*/*', array('text/html' => 1.0, '*/*' => 1.0, 'application/xhtml+xml;charset=utf-8;foo=bar' => 0.9)), + array('text/html,application/xhtml+xml', array('text/html' => 1.0, 'application/xhtml+xml' => 1.0)), ); } - public function testIsProxyTrusted() - { - $this->startTrustingProxyData(); - $this->assertTrue(Request::isProxyTrusted()); - $this->stopTrustingProxyData(); - $this->assertFalse(Request::isProxyTrusted()); - } - public function testIsMethod() { $request = new Request(); @@ -1151,6 +1239,78 @@ private function stopTrustingProxyData() $property->setAccessible(true); $property->setValue(false); } + + private function disableHttpMethodParameterOverride() + { + $class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request'); + $property = $class->getProperty('httpMethodParameterOverride'); + $property->setAccessible(true); + $property->setValue(false); + } + + public function testTrustedProxies() + { + $request = Request::create('http://example.com/'); + $request->server->set('REMOTE_ADDR', '3.3.3.3'); + $request->headers->set('X_FORWARDED_FOR', '1.1.1.1, 2.2.2.2'); + $request->headers->set('X_FORWARDED_HOST', 'foo.example.com, real.example.com:8080'); + $request->headers->set('X_FORWARDED_PROTO', 'https'); + $request->headers->set('X_FORWARDED_PORT', 443); + $request->headers->set('X_MY_FOR', '3.3.3.3, 4.4.4.4'); + $request->headers->set('X_MY_HOST', 'my.example.com'); + $request->headers->set('X_MY_PROTO', 'http'); + $request->headers->set('X_MY_PORT', 81); + + // no trusted proxies + $this->assertEquals('3.3.3.3', $request->getClientIp()); + $this->assertEquals('example.com', $request->getHost()); + $this->assertEquals(80, $request->getPort()); + $this->assertFalse($request->isSecure()); + + // trusted proxy via deprecated trustProxyData() + Request::trustProxyData(); + $this->assertEquals('2.2.2.2', $request->getClientIp()); + $this->assertEquals('real.example.com', $request->getHost()); + $this->assertEquals(443, $request->getPort()); + $this->assertTrue($request->isSecure()); + + // disabling proxy trusting + Request::setTrustedProxies(array()); + $this->assertEquals('3.3.3.3', $request->getClientIp()); + $this->assertEquals('example.com', $request->getHost()); + $this->assertEquals(80, $request->getPort()); + $this->assertFalse($request->isSecure()); + + // trusted proxy via setTrustedProxies() + Request::setTrustedProxies(array('3.3.3.3', '2.2.2.2')); + $this->assertEquals('1.1.1.1', $request->getClientIp()); + $this->assertEquals('real.example.com', $request->getHost()); + $this->assertEquals(443, $request->getPort()); + $this->assertTrue($request->isSecure()); + + // custom header names + Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X_MY_FOR'); + Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'X_MY_HOST'); + Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, 'X_MY_PORT'); + Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'X_MY_PROTO'); + $this->assertEquals('4.4.4.4', $request->getClientIp()); + $this->assertEquals('my.example.com', $request->getHost()); + $this->assertEquals(81, $request->getPort()); + $this->assertFalse($request->isSecure()); + + // disabling via empty header names + Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, null); + Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, null); + Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, null); + Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, null); + $this->assertEquals('3.3.3.3', $request->getClientIp()); + $this->assertEquals('example.com', $request->getHost()); + $this->assertEquals(80, $request->getPort()); + $this->assertFalse($request->isSecure()); + + // reset + Request::setTrustedProxies(array()); + } } class RequestContentProxy extends Request diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index 0e8a67dfa5f7..fd163d197d20 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -16,6 +16,51 @@ class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase { + /** + * @covers Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase + * @dataProvider provideAllPreserveCase + */ + public function testAllPreserveCase($headers, $expected) + { + $bag = new ResponseHeaderBag($headers); + + $this->assertEquals($expected, $bag->allPreserveCase(), '->allPreserveCase() gets all input keys in original case'); + } + + public function provideAllPreserveCase() + { + return array( + array( + array('fOo' => 'BAR'), + array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache')) + ), + array( + array('ETag' => 'xyzzy'), + array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')) + ), + array( + array('Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ=='), + array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache')) + ), + array( + array('P3P' => 'CP="CAO PSA OUR"'), + array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache')) + ), + array( + array('WWW-Authenticate' => 'Basic realm="WallyWorld"'), + array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache')) + ), + array( + array('X-UA-Compatible' => 'IE=edge,chrome=1'), + array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache')) + ), + array( + array('X-XSS-Protection' => '1; mode=block'), + array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache')) + ), + ); + } + public function testCacheControlHeader() { $bag = new ResponseHeaderBag(array()); @@ -76,6 +121,29 @@ public function testToStringIncludesCookieHeaders() $this->assertContains("Set-Cookie: foo=deleted; expires=".gmdate("D, d-M-Y H:i:s T", time() - 31536001)."; httponly", explode("\r\n", $bag->__toString())); } + public function testReplace() + { + $bag = new ResponseHeaderBag(array()); + $this->assertEquals('no-cache', $bag->get('Cache-Control')); + $this->assertTrue($bag->hasCacheControlDirective('no-cache')); + + $bag->replace(array('Cache-Control' => 'public')); + $this->assertEquals('public', $bag->get('Cache-Control')); + $this->assertTrue($bag->hasCacheControlDirective('public')); + } + + public function testReplaceWithRemove() + { + $bag = new ResponseHeaderBag(array()); + $this->assertEquals('no-cache', $bag->get('Cache-Control')); + $this->assertTrue($bag->hasCacheControlDirective('no-cache')); + + $bag->remove('Cache-Control'); + $bag->replace(array()); + $this->assertEquals('no-cache', $bag->get('Cache-Control')); + $this->assertTrue($bag->hasCacheControlDirective('no-cache')); + } + public function testCookiesWithSameNames() { $bag = new ResponseHeaderBag(); @@ -119,6 +187,34 @@ public function testRemoveCookie() $this->assertFalse(isset($cookies['foo.bar'])); } + public function testRemoveCookieWithNullRemove() + { + $bag = new ResponseHeaderBag(); + $bag->setCookie(new Cookie('foo', 'bar', 0)); + $bag->setCookie(new Cookie('bar', 'foo', 0)); + + $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); + $this->assertTrue(isset($cookies['']['/'])); + + $bag->removeCookie('foo', null); + $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); + $this->assertFalse(isset($cookies['']['/']['foo'])); + + $bag->removeCookie('bar', null); + $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); + $this->assertFalse(isset($cookies['']['/']['bar'])); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testGetCookiesWithInvalidArgument() + { + $bag = new ResponseHeaderBag(); + + $cookies = $bag->getCookies('invalid_argument'); + } + /** * @expectedException \InvalidArgumentException */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index cbbdd29aa093..c14dc4b83d51 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -25,6 +25,99 @@ public function testCreate() $this->assertEquals('bar', $response->headers->get('foo')); } + public function testToString() + { + $response = new Response(); + $response = explode("\r\n", $response); + $this->assertEquals("HTTP/1.0 200 OK", $response[0]); + $this->assertEquals("Cache-Control: no-cache", $response[1]); + } + + public function testClone() + { + $response = new Response(); + $responseClone = clone $response; + $this->assertEquals($response, $responseClone); + } + + public function testSendHeaders() + { + $response = new Response(); + $headers = $response->sendHeaders(); + $this->assertObjectHasAttribute('headers', $headers); + $this->assertObjectHasAttribute('content', $headers); + $this->assertObjectHasAttribute('version', $headers); + $this->assertObjectHasAttribute('statusCode', $headers); + $this->assertObjectHasAttribute('statusText', $headers); + $this->assertObjectHasAttribute('charset', $headers); + } + + public function testSend() + { + $response = new Response(); + $responseSend = $response->send(); + $this->assertObjectHasAttribute('headers', $responseSend); + $this->assertObjectHasAttribute('content', $responseSend); + $this->assertObjectHasAttribute('version', $responseSend); + $this->assertObjectHasAttribute('statusCode', $responseSend); + $this->assertObjectHasAttribute('statusText', $responseSend); + $this->assertObjectHasAttribute('charset', $responseSend); + } + + public function testGetCharset() + { + $response = new Response(); + $charsetOrigin = 'UTF-8'; + $response->setCharset($charsetOrigin); + $charset = $response->getCharset(); + $this->assertEquals($charsetOrigin, $charset); + } + + public function testIsCacheable() + { + $response = new Response(); + $this->assertFalse($response->isCacheable()); + } + + public function testIsCacheableWithSetTtl() + { + $response = new Response(); + $response->setTtl(10); + $this->assertTrue($response->isCacheable()); + } + + public function testMustRevalidate() + { + $response = new Response(); + $this->assertFalse($response->mustRevalidate()); + } + + public function testSetNotModified() + { + $response = new Response(); + $modified = $response->setNotModified(); + $this->assertObjectHasAttribute('headers', $modified); + $this->assertObjectHasAttribute('content', $modified); + $this->assertObjectHasAttribute('version', $modified); + $this->assertObjectHasAttribute('statusCode', $modified); + $this->assertObjectHasAttribute('statusText', $modified); + $this->assertObjectHasAttribute('charset', $modified); + $this->assertEquals(304, $modified->getStatusCode()); + } + + public function testIsSuccessful() + { + $response = new Response(); + $this->assertTrue($response->isSuccessful()); + } + + public function testIsNotModified() + { + $response = new Response(); + $modified = $response->isNotModified(new Request()); + $this->assertFalse($modified); + } + public function testIsValidateable() { $response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); @@ -50,6 +143,10 @@ public function testGetDate() $now = $this->createDateTimeNow(); $response->headers->set('Date', $now->format(DATE_RFC2822)); $this->assertEquals(0, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified'); + + $response = new Response('', 200); + $response->headers->remove('Date'); + $this->assertInstanceOf('\DateTime', $response->getDate()); } public function testGetMaxAge() diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php index 432499e945d6..622d65bc3f12 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\Tests; +namespace Symfony\Component\HttpFoundation\Tests\Session\Attribute; use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index 7bdc127fdb8d..2568b3c7f356 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php @@ -54,6 +54,29 @@ public function testStart() $this->assertNotEquals('', $this->session->getId()); } + public function testIsStarted() + { + $this->assertFalse($this->session->isStarted()); + $this->session->start(); + $this->assertTrue($this->session->isStarted()); + } + + public function testSetId() + { + $this->assertEquals('', $this->session->getId()); + $this->session->setId('0123456789abcdef'); + $this->session->start(); + $this->assertEquals('0123456789abcdef', $this->session->getId()); + } + + public function testSetName() + { + $this->assertEquals('MOCKSESSID', $this->session->getName()); + $this->session->setName('session.test.com'); + $this->session->start(); + $this->assertEquals('session.test.com', $this->session->getName()); + } + public function testGet() { // tests defaults diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index c9eb0b38d694..409296ef1d49 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -18,35 +18,32 @@ */ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase { - private static $mongo; - - public static function setUpBeforeClass() - { - if (class_exists('\Mongo')) { - try { - self::$mongo = new \Mongo(); - } catch (\Exception $e) { - } - } - } + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $mongo; + private $storage; + public $options; protected function setUp() { - if (null === self::$mongo) { - $this->markTestSkipped('MongoDbSessionHandler requires the php "mongo" extension and a mongodb server on localhost'); + if (!class_exists('\Mongo')) { + $this->markTestSkipped('MongoDbSessionHandler requires the mongo extension.'); } - $this->options = array('database' => 'sf2-test', 'collection' => 'session-test'); - $this->options = array('database' => 'sf2-test', 'collection' => 'session-test'); + $this->mongo = $this->getMockBuilder('Mongo') + ->disableOriginalConstructor() + ->getMock(); - $this->storage = new MongoDbSessionHandler(self::$mongo, $this->options); - } + $this->options = array( + 'id_field' => '_id', + 'data_field' => 'data', + 'time_field' => 'time', + 'database' => 'sf2-test', + 'collection' => 'session-test' + ); - protected function tearDown() - { - if (null !== self::$mongo) { - self::$mongo->dropDB($this->options['database']); - } + $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); } public function testOpenMethodAlwaysReturnTrue() @@ -61,39 +58,132 @@ public function testCloseMethodAlwaysReturnTrue() public function testWrite() { + $database = $this->getMockBuilder('MongoDB') + ->disableOriginalConstructor() + ->getMock(); + + $collection = $this->getMockBuilder('MongoCollection') + ->disableOriginalConstructor() + ->getMock(); + + $this->mongo->expects($this->once()) + ->method('selectDB') + ->with($this->options['database']) + ->will($this->returnValue($database)); + + $database->expects($this->once()) + ->method('selectCollection') + ->with($this->options['collection']) + ->will($this->returnValue($collection)); + + $that = $this; + $data = array(); + + $collection->expects($this->once()) + ->method('update') + ->will($this->returnCallback(function($criteria, $updateData, $options) use ($that, &$data) { + $that->assertEquals(array($that->options['id_field'] => 'foo'), $criteria); + $that->assertEquals(array('upsert' => true, 'multiple' => false), $options); + + $data = $updateData['$set']; + })); + $this->assertTrue($this->storage->write('foo', 'bar')); - $this->assertEquals('bar', $this->storage->read('foo')); + + $this->assertEquals('bar', $data[$this->options['data_field']]->bin); + $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); } public function testReplaceSessionData() { + $database = $this->getMockBuilder('MongoDB') + ->disableOriginalConstructor() + ->getMock(); + + $collection = $this->getMockBuilder('MongoCollection') + ->disableOriginalConstructor() + ->getMock(); + + $this->mongo->expects($this->once()) + ->method('selectDB') + ->with($this->options['database']) + ->will($this->returnValue($database)); + + $database->expects($this->once()) + ->method('selectCollection') + ->with($this->options['collection']) + ->will($this->returnValue($collection)); + + $data = array(); + + $collection->expects($this->exactly(2)) + ->method('update') + ->will($this->returnCallback(function($criteria, $updateData, $options) use (&$data) { + $data = $updateData; + })); + $this->storage->write('foo', 'bar'); $this->storage->write('foo', 'foobar'); - $coll = self::$mongo->selectDB($this->options['database'])->selectCollection($this->options['collection']); - - $this->assertEquals('foobar', $this->storage->read('foo')); - $this->assertEquals(1, $coll->find(array('sess_id' => 'foo'))->count()); + $this->assertEquals('foobar', $data['$set'][$this->options['data_field']]->bin); } public function testDestroy() { - $this->storage->write('foo', 'bar'); - $this->storage->destroy('foo'); + $database = $this->getMockBuilder('MongoDB') + ->disableOriginalConstructor() + ->getMock(); - $this->assertEquals('', $this->storage->read('foo')); - } + $collection = $this->getMockBuilder('MongoCollection') + ->disableOriginalConstructor() + ->getMock(); - public function testGc() - { - $this->storage->write('foo', 'bar'); - $this->storage->write('bar', 'foo'); + $this->mongo->expects($this->once()) + ->method('selectDB') + ->with($this->options['database']) + ->will($this->returnValue($database)); - $coll = self::$mongo->selectDB($this->options['database'])->selectCollection($this->options['collection']); + $database->expects($this->once()) + ->method('selectCollection') + ->with($this->options['collection']) + ->will($this->returnValue($collection)); - $this->assertEquals(2, $coll->count()); - $this->storage->gc(-1); - $this->assertEquals(0, $coll->count()); + $collection->expects($this->once()) + ->method('remove') + ->with(array($this->options['id_field'] => 'foo')); + $this->assertTrue($this->storage->destroy('foo')); + } + + public function testGc() + { + $database = $this->getMockBuilder('MongoDB') + ->disableOriginalConstructor() + ->getMock(); + + $collection = $this->getMockBuilder('MongoCollection') + ->disableOriginalConstructor() + ->getMock(); + + $this->mongo->expects($this->once()) + ->method('selectDB') + ->with($this->options['database']) + ->will($this->returnValue($database)); + + $database->expects($this->once()) + ->method('selectCollection') + ->with($this->options['collection']) + ->will($this->returnValue($collection)); + + $that = $this; + + $collection->expects($this->once()) + ->method('remove') + ->will($this->returnCallback(function($criteria) use($that) { + $that->assertInstanceOf('MongoDate', $criteria[$that->options['time_field']]['$lt']); + $that->assertGreaterThanOrEqual(time() - -1, $criteria[$that->options['time_field']]['$lt']->sec); + })); + + $this->assertTrue($this->storage->gc(-1)); } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php index 39f268b4b54c..ef70281ce08d 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php @@ -82,6 +82,14 @@ public function testGetStorageKey() $this->assertEquals('_sf2_meta', $this->bag->getStorageKey()); } + public function testGetLifetime() + { + $bag = new MetadataBag(); + $array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 1000); + $bag->initialize($array); + $this->assertEquals(1000, $bag->getLifetime()); + } + public function testGetCreated() { $this->assertEquals(1234567, $this->bag->getCreated()); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 4b88a237a007..b99941aa2c08 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -29,6 +29,8 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase { /** + * @param array $options + * * @return NativeSessionStorage */ protected function getStorage(array $options = array()) diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php index f52badf6a4f2..0dfe65160093 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php @@ -76,10 +76,19 @@ public function testSendContent() */ public function testSendContentWithNonCallable() { - $response = new StreamedResponse('foobar'); + $response = new StreamedResponse(null); $response->sendContent(); } + /** + * @expectedException \LogicException + */ + public function testSetCallbackNonCallable() + { + $response = new StreamedResponse(null); + $response->setCallback(null); + } + /** * @expectedException \LogicException */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/bootstrap.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/bootstrap.php deleted file mode 100644 index f7fc8c9809aa..000000000000 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/bootstrap.php +++ /dev/null @@ -1,22 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (ltrim('SessionHandlerInterface', '/') === $class) { - require_once __DIR__.'/../Resources/stubs/SessionHandlerInterface.php'; - } - - if (0 !== strpos(ltrim($class, '/'), 'Symfony\Component\HttpFoundation')) { - return; - } - - require_once __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\HttpFoundation')).'.php'; -}); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json index 91c23c24870f..09b8725308d8 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json @@ -19,16 +19,14 @@ "php": ">=5.3.3" }, "autoload": { - "psr-0": { - "Symfony\\Component\\HttpFoundation": "", - "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" - } + "psr-0": { "Symfony\\Component\\HttpFoundation\\": "" }, + "classmap": [ "Symfony/Component/HttpFoundation/Resources/stubs" ] }, "target-dir": "Symfony/Component/HttpFoundation", "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist index 2a760f290c73..df11f72c0ff3 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="Tests/bootstrap.php" + bootstrap="vendor/autoload.php" > <testsuites> <testsuite name="Symfony HttpFoundation Component Test Suite"> diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitattributes b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore index d1502b087b4d..44de97a36a6d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore @@ -1,2 +1,4 @@ vendor/ composer.lock +phpunit.xml + diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md index c27de87eca5d..75b5d9321a7f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md @@ -1,6 +1,18 @@ CHANGELOG ========= +2.2.0 +----- + + * [BC BREAK] renamed TimeDataCollector::getTotalTime() to + TimeDataCollector::getDuration() + * updated the MemoryDataCollector to include the memory used in the + kernel.terminate event listeners + * moved the Stopwatch classes to a new component + * added TraceableControllerResolver + * added TraceableEventDispatcher (removed ContainerAwareTraceableEventDispatcher) + * added support for WinCache opcode cache in ConfigDataCollector + 2.1.0 ----- diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php index f5dcd9a376b2..2b1a2b0f4c9d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php @@ -179,6 +179,11 @@ protected function filterResponse($response) $headers['Set-Cookie'] = $cookies; } - return new DomResponse($response->getContent(), $response->getStatusCode(), $headers); + // this is needed to support StreamedResponse + ob_start(); + $response->sendContent(); + $content = ob_get_clean(); + + return new DomResponse($content, $response->getStatusCode(), $headers); } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php new file mode 100644 index 000000000000..f8de31cf078c --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php @@ -0,0 +1,66 @@ +<?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\Component\HttpKernel\Controller; + +use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Component\HttpFoundation\Request; + +/** + * TraceableControllerResolver. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class TraceableControllerResolver implements ControllerResolverInterface +{ + private $resolver; + private $stopwatch; + + /** + * Constructor. + * + * @param ControllerResolverInterface $resolver A ControllerResolverInterface instance + * @param Stopwatch $stopwatch A Stopwatch instance + */ + public function __construct(ControllerResolverInterface $resolver, Stopwatch $stopwatch) + { + $this->resolver = $resolver; + $this->stopwatch = $stopwatch; + } + + /** + * {@inheritdoc} + */ + public function getController(Request $request) + { + $e = $this->stopwatch->start('controller.get_callable'); + + $ret = $this->resolver->getController($request); + + $e->stop(); + + return $ret; + } + + /** + * {@inheritdoc} + */ + public function getArguments(Request $request, $controller) + { + $e = $this->stopwatch->start('controller.get_arguments'); + + $ret = $this->resolver->getArguments($request, $controller); + + $e->stop(); + + return $ret; + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 81ede39ced0e..97797a48f23b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -42,17 +42,18 @@ public function setKernel(KernelInterface $kernel) public function collect(Request $request, Response $response, \Exception $exception = null) { $this->data = array( - 'token' => $response->headers->get('X-Debug-Token'), - 'symfony_version' => Kernel::VERSION, - 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', - 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', - 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', - 'php_version' => PHP_VERSION, - 'xdebug_enabled' => extension_loaded('xdebug'), - 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), - 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), - 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'), - 'bundles' => array(), + 'token' => $response->headers->get('X-Debug-Token'), + 'symfony_version' => Kernel::VERSION, + 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', + 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', + 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', + 'php_version' => PHP_VERSION, + 'xdebug_enabled' => extension_loaded('xdebug'), + 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), + 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), + 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'), + 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'), + 'bundles' => array(), ); if (isset($this->kernel)) { @@ -162,6 +163,16 @@ public function hasXCache() return $this->data['xcache_enabled']; } + /** + * Returns true if WinCache is enabled. + * + * @return Boolean true if WinCache is enabled, false otherwise + */ + public function hasWinCache() + { + return $this->data['wincache_enabled']; + } + /** * Returns true if any accelerator is enabled. * @@ -169,7 +180,7 @@ public function hasXCache() */ public function hasAccelerator() { - return $this->hasApc() || $this->hasEAccelerator() || $this->hasXCache(); + return $this->hasApc() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache(); } public function getBundles() diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php index 98eabdb516b6..7d9c28943b72 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php @@ -31,4 +31,45 @@ public function unserialize($data) { $this->data = unserialize($data); } + + /** + * Converts a PHP variable to a string. + * + * @param mixed $var A PHP variable + * + * @return string The string representation of the variable + */ + protected function varToString($var) + { + if (is_object($var)) { + return sprintf('Object(%s)', get_class($var)); + } + + if (is_array($var)) { + $a = array(); + foreach ($var as $k => $v) { + $a[] = sprintf('%s => %s', $k, $this->varToString($v)); + } + + return sprintf("Array(%s)", implode(', ', $a)); + } + + if (is_resource($var)) { + return sprintf('Resource(%s)', get_resource_type($var)); + } + + if (null === $var) { + return 'null'; + } + + if (false === $var) { + return 'false'; + } + + if (true === $var) { + return 'true'; + } + + return (string) $var; + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php index 406f1df02fa3..cd7f7870177c 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php @@ -14,7 +14,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * EventDataCollector. @@ -23,26 +22,29 @@ */ class EventDataCollector extends DataCollector { - private $dispatcher; - - public function setEventDispatcher(EventDispatcherInterface $dispatcher) - { - if ($dispatcher instanceof TraceableEventDispatcherInterface) { - $this->dispatcher = $dispatcher; - } - } - /** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { $this->data = array( - 'called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getCalledListeners() : array(), - 'not_called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getNotCalledListeners() : array(), + 'called_listeners' => array(), + 'not_called_listeners' => array(), ); } + /** + * Sets the called listeners. + * + * @param array $listeners An array of called listeners + * + * @see TraceableEventDispatcherInterface + */ + public function setCalledListeners(array $listeners) + { + $this->data['called_listeners'] = $listeners; + } + /** * Gets the called listeners. * @@ -55,6 +57,18 @@ public function getCalledListeners() return $this->data['called_listeners']; } + /** + * Sets the not called listeners. + * + * @param array $listeners An array of not called listeners + * + * @see TraceableEventDispatcherInterface + */ + public function setNotCalledListeners(array $listeners) + { + $this->data['not_called_listeners'] = $listeners; + } + /** * Gets the not called listeners. * diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php index 20ff597bb554..10a010bc622e 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php @@ -14,7 +14,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\FlattenException; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; /** * ExceptionDataCollector. diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php index c41ca314dabb..649c88d7643d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php @@ -21,14 +21,17 @@ */ class MemoryDataCollector extends DataCollector { + public function __construct() + { + $this->data = array('memory' => 0); + } + /** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { - $this->data = array( - 'memory' => memory_get_peak_usage(true), - ); + $this->updateMemoryUsage(); } /** @@ -41,6 +44,14 @@ public function getMemory() return $this->data['memory']; } + /** + * Updates the memory usage data. + */ + public function updateMemoryUsage() + { + $this->data['memory'] = memory_get_peak_usage(true); + } + /** * {@inheritdoc} */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index b410c23325a4..6294845c722a 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -11,7 +11,6 @@ namespace Symfony\Component\HttpKernel\DataCollector; -use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\HeaderBag; use Symfony\Component\HttpFoundation\Request; @@ -51,14 +50,7 @@ public function collect(Request $request, Response $response, \Exception $except $attributes = array(); foreach ($request->attributes->all() as $key => $value) { - if (is_object($value)) { - $attributes[$key] = sprintf('Object(%s)', get_class($value)); - if (is_callable(array($value, '__toString'))) { - $attributes[$key] .= sprintf(' = %s', (string) $value); - } - } else { - $attributes[$key] = $value; - } + $attributes[$key] = $this->varToString($value); } $content = null; @@ -100,18 +92,31 @@ public function collect(Request $request, Response $response, \Exception $except 'flashes' => $flashes, 'path_info' => $request->getPathInfo(), 'controller' => 'n/a', + 'locale' => $request->getLocale(), ); if (isset($this->controllers[$request])) { $controller = $this->controllers[$request]; if (is_array($controller)) { - $r = new \ReflectionMethod($controller[0], $controller[1]); - $this->data['controller'] = array( - 'class' => get_class($controller[0]), - 'method' => $controller[1], - 'file' => $r->getFilename(), - 'line' => $r->getStartLine(), - ); + try { + $r = new \ReflectionMethod($controller[0], $controller[1]); + $this->data['controller'] = array( + 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], + 'method' => $controller[1], + 'file' => $r->getFilename(), + 'line' => $r->getStartLine(), + ); + } catch (\ReflectionException $re) { + if (is_callable($controller)) { + // using __call or __callStatic + $this->data['controller'] = array( + 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], + 'method' => $controller[1], + 'file' => 'n/a', + 'line' => 'n/a', + ); + } + } } elseif ($controller instanceof \Closure) { $this->data['controller'] = 'Closure'; } else { @@ -196,6 +201,11 @@ public function getFormat() return $this->data['format']; } + public function getLocale() + { + return $this->data['locale']; + } + /** * Gets the route name. * diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index 0d5ac81971f4..5fd237849903 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -70,11 +70,11 @@ public function getEvents() * * @return float The elapsed time */ - public function getTotalTime() + public function getDuration() { $lastEvent = $this->data['events']['__section__']; - return $lastEvent->getOrigin() + $lastEvent->getTotalTime() - $this->getStartTime(); + return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime(); } /** diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php deleted file mode 100644 index bba6ea7b5573..000000000000 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php +++ /dev/null @@ -1,318 +0,0 @@ -<?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\Component\HttpKernel\Debug; - -use Symfony\Component\HttpKernel\Debug\Stopwatch; -use Symfony\Component\HttpKernel\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Profiler\Profile; -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; - -/** - * Extends the ContainerAwareEventDispatcher to add some debugging tools. - * - * @author Fabien Potencier <fabien@symfony.com> - */ -class ContainerAwareTraceableEventDispatcher extends ContainerAwareEventDispatcher implements TraceableEventDispatcherInterface -{ - private $logger; - private $called; - private $stopwatch; - private $priorities; - private $profiler; - - /** - * Constructor. - * - * @param ContainerInterface $container A ContainerInterface instance - * @param Stopwatch $stopwatch A Stopwatch instance - * @param LoggerInterface $logger A LoggerInterface instance - */ - public function __construct(ContainerInterface $container, Stopwatch $stopwatch, LoggerInterface $logger = null) - { - parent::__construct($container); - - $this->stopwatch = $stopwatch; - $this->logger = $logger; - $this->called = array(); - } - - /** - * {@inheritdoc} - */ - public function dispatch($eventName, Event $event = null) - { - switch ($eventName) { - case 'kernel.request': - $this->stopwatch->openSection(); - break; - case 'kernel.view': - case 'kernel.response': - // stop only if a controller has been executed - try { - $this->stopwatch->stop('controller'); - } catch (\LogicException $e) { - } - break; - case 'kernel.terminate': - $token = $event->getResponse()->headers->get('X-Debug-Token'); - $this->stopwatch->openSection($token); - break; - } - - $e1 = $this->stopwatch->start($eventName, 'section'); - - parent::dispatch($eventName, $event); - - $e1->stop(); - - switch ($eventName) { - case 'kernel.controller': - $this->stopwatch->start('controller', 'section'); - break; - case 'kernel.response': - $token = $event->getResponse()->headers->get('X-Debug-Token'); - $this->stopwatch->stopSection($token); - if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { - // The profiles can only be updated once they have been created - // that is after the 'kernel.response' event of the main request - $this->updateProfiles($token, true); - } - break; - case 'kernel.terminate': - $this->stopwatch->stopSection($token); - // The children profiles have been updated by the previous 'kernel.response' - // event. Only the root profile need to be updated with the 'kernel.terminate' - // timing informations. - $this->updateProfiles($token, false); - break; - } - - return $event; - } - - /** - * {@inheritDoc} - * - * @throws \RuntimeException if the listener method is not callable - */ - public function addListener($eventName, $listener, $priority = 0) - { - if (!is_callable($listener)) { - throw new \RuntimeException(sprintf('The given callback (%s) for event "%s" is not callable.', $this->getListenerAsString($listener), $eventName)); - } - - $this->priorities[$eventName.'_'.$this->getListenerAsString($listener)] = $priority; - - parent::addListener($eventName, $listener, $priority); - } - - /** - * {@inheritDoc} - */ - protected function doDispatch($listeners, $eventName, Event $event) - { - foreach ($listeners as $listener) { - $info = $this->getListenerInfo($listener, $eventName); - - if (null !== $this->logger) { - $this->logger->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty'])); - } - - $this->called[$eventName.'.'.$info['pretty']] = $info; - - $e2 = $this->stopwatch->start(isset($info['class']) ? substr($info['class'], strrpos($info['class'], '\\') + 1) : $info['type'], 'event_listener'); - - call_user_func($listener, $event); - - $e2->stop(); - - if ($event->isPropagationStopped()) { - if (null !== $this->logger) { - $this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName)); - - $skippedListeners = $this->getListeners($eventName); - $skipped = false; - - foreach ($skippedListeners as $skippedListener) { - if ($skipped) { - $info = $this->getListenerInfo($skippedListener, $eventName); - $this->logger->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName)); - } - - if ($skippedListener === $listener) { - $skipped = true; - } - } - } - - break; - } - } - } - - /** - * {@inheritDoc} - */ - protected function lazyLoad($eventName) - { - $e = $this->stopwatch->start($eventName.'.loading', 'event_listener_loading'); - - parent::lazyLoad($eventName); - - $e->stop(); - } - - /** - * {@inheritDoc} - */ - public function getCalledListeners() - { - return $this->called; - } - - /** - * {@inheritDoc} - */ - public function getNotCalledListeners() - { - $notCalled = array(); - - foreach ($this->getListeners() as $name => $listeners) { - foreach ($listeners as $listener) { - $info = $this->getListenerInfo($listener, $name); - if (!isset($this->called[$name.'.'.$info['pretty']])) { - $notCalled[$name.'.'.$info['pretty']] = $info; - } - } - } - - return $notCalled; - } - - /** - * Returns information about the listener - * - * @param object $listener The listener - * @param string $eventName The event name - * - * @return array Informations about the listener - */ - private function getListenerInfo($listener, $eventName) - { - $info = array( - 'event' => $eventName, - 'priority' => $this->priorities[$eventName.'_'.$this->getListenerAsString($listener)], - ); - if ($listener instanceof \Closure) { - $info += array( - 'type' => 'Closure', - 'pretty' => 'closure' - ); - } elseif (is_string($listener)) { - try { - $r = new \ReflectionFunction($listener); - $file = $r->getFileName(); - $line = $r->getStartLine(); - } catch (\ReflectionException $e) { - $file = null; - $line = null; - } - $info += array( - 'type' => 'Function', - 'function' => $listener, - 'file' => $file, - 'line' => $line, - 'pretty' => $listener, - ); - } elseif (is_array($listener) || (is_object($listener) && is_callable($listener))) { - if (!is_array($listener)) { - $listener = array($listener, '__invoke'); - } - $class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0]; - try { - $r = new \ReflectionMethod($class, $listener[1]); - $file = $r->getFileName(); - $line = $r->getStartLine(); - } catch (\ReflectionException $e) { - $file = null; - $line = null; - } - $info += array( - 'type' => 'Method', - 'class' => $class, - 'method' => $listener[1], - 'file' => $file, - 'line' => $line, - 'pretty' => $class.'::'.$listener[1], - ); - } - - return $info; - } - - /** - * Updates the stopwatch data in the profile hierarchy. - * - * @param string $token Profile token - * @param Boolean $updateChildren Whether to update the children altogether - */ - private function updateProfiles($token, $updateChildren) - { - if (!$this->getContainer()->has('profiler')) { - return; - } - - $this->profiler = $this->getContainer()->get('profiler'); - - if (!$profile = $this->profiler->loadProfile($token)) { - return; - } - - $this->saveStopwatchInfoInProfile($profile, $updateChildren); - } - - /** - * Update the profiles with the timing info and saves them. - * - * @param Profile $profile The root profile - * @param Boolean $updateChildren Whether to update the children altogether - */ - private function saveStopwatchInfoInProfile(Profile $profile, $updateChildren) - { - $profile->getCollector('time')->setEvents($this->stopwatch->getSectionEvents($profile->getToken())); - $this->profiler->saveProfile($profile); - - if ($updateChildren) { - foreach ($profile->getChildren() as $child) { - $this->saveStopwatchInfoInProfile($child, true); - } - } - } - - private function getListenerAsString($listener) - { - if (is_string($listener)) { - return '[string] '.$listener; - } elseif (is_array($listener)) { - return '[array] '.(is_object($listener[0]) ? get_class($listener[0]) : $listener[0]).'::'.$listener[1]; - } elseif (is_object($listener)) { - return '[object] '.get_class($listener); - } - - return '[?] '.var_export($listener, true); - } -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php index c0133d49f41b..88ef3d7615fc 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php @@ -43,6 +43,8 @@ public function __construct($debug = true, $charset = 'UTF-8') /** * Register the exception handler. * + * @param Boolean $debug + * * @return ExceptionHandler The registered exception handler */ public static function register($debug = true) @@ -73,112 +75,116 @@ public function handle(\Exception $exception) */ public function createResponse($exception) { - $content = ''; - $title = ''; - try { - if (!$exception instanceof FlattenException) { - $exception = FlattenException::create($exception); - } - - switch ($exception->getStatusCode()) { - case 404: - $title = 'Sorry, the page you are looking for could not be found.'; - break; - default: - $title = 'Whoops, looks like something went wrong.'; - } - - if ($this->debug) { - $content = $this->getContent($exception); - } - } catch (\Exception $e) { - // something nasty happened and we cannot throw an exception here anymore - if ($this->debug) { - $title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage()); - } else { - $title = 'Whoops, looks like something went wrong.'; - } + if (!$exception instanceof FlattenException) { + $exception = FlattenException::create($exception); } - return new Response($this->decorate($content, $title), $exception->getStatusCode(), $exception->getHeaders()); + return new Response($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders()); } - private function getContent($exception) + /** + * Gets the HTML content associated with the given exception. + * + * @param FlattenException $exception A FlattenException instance + * + * @return string The content as a string + */ + public function getContent(FlattenException $exception) { - $message = nl2br($exception->getMessage()); - $class = $this->abbrClass($exception->getClass()); - $count = count($exception->getAllPrevious()); + $title = ''; + switch ($exception->getStatusCode()) { + case 404: + $title = 'Sorry, the page you are looking for could not be found.'; + break; + default: + $title = 'Whoops, looks like something went wrong.'; + } + $content = ''; - foreach ($exception->toArray() as $position => $e) { - $ind = $count - $position + 1; - $total = $count + 1; - $class = $this->abbrClass($e['class']); - $message = nl2br($e['message']); - $content .= sprintf(<<<EOF -<div class="block_exception clear_fix"> - <h2><span>%d/%d</span> %s: %s</h2> -</div> -<div class="block"> - <ol class="traces list_exception"> + if ($this->debug) { + try { + $message = nl2br($exception->getMessage()); + $class = $this->abbrClass($exception->getClass()); + $count = count($exception->getAllPrevious()); + $content = ''; + foreach ($exception->toArray() as $position => $e) { + $ind = $count - $position + 1; + $total = $count + 1; + $class = $this->abbrClass($e['class']); + $message = nl2br($e['message']); + $content .= sprintf(<<<EOF + <div class="block_exception clear_fix"> + <h2><span>%d/%d</span> %s: %s</h2> + </div> + <div class="block"> + <ol class="traces list_exception"> EOF - , $ind, $total, $class, $message); - foreach ($e['trace'] as $i => $trace) { - $content .= ' <li>'; - if ($trace['function']) { - $content .= sprintf('at %s%s%s(%s)', $this->abbrClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); - } - if (isset($trace['file']) && isset($trace['line'])) { - if ($linkFormat = ini_get('xdebug.file_link_format')) { - $link = str_replace(array('%f', '%l'), array($trace['file'], $trace['line']), $linkFormat); - $content .= sprintf(' in <a href="%s" title="Go to source">%s line %s</a>', $link, $trace['file'], $trace['line']); - } else { - $content .= sprintf(' in %s line %s', $trace['file'], $trace['line']); + , $ind, $total, $class, $message); + foreach ($e['trace'] as $i => $trace) { + $content .= ' <li>'; + if ($trace['function']) { + $content .= sprintf('at %s%s%s(%s)', $this->abbrClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); + } + if (isset($trace['file']) && isset($trace['line'])) { + if ($linkFormat = ini_get('xdebug.file_link_format')) { + $link = str_replace(array('%f', '%l'), array($trace['file'], $trace['line']), $linkFormat); + $content .= sprintf(' in <a href="%s" title="Go to source">%s line %s</a>', $link, $trace['file'], $trace['line']); + } else { + $content .= sprintf(' in %s line %s', $trace['file'], $trace['line']); + } + } + $content .= "</li>\n"; } + + $content .= " </ol>\n</div>\n"; + } + } catch (\Exception $e) { + // something nasty happened and we cannot throw an exception anymore + if ($this->debug) { + $title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage()); + } else { + $title = 'Whoops, looks like something went wrong.'; } - $content .= "</li>\n"; } - - $content .= " </ol>\n</div>\n"; } - return $content; + return <<<EOF + <div id="sf-resetcontent" class="sf-reset"> + <h1>$title</h1> + $content + </div> +EOF; } - private function decorate($content, $title) + /** + * Gets the stylesheet associated with the given exception. + * + * @param FlattenException $exception A FlattenException instance + * + * @return string The stylesheet as a string + */ + public function getStylesheet(FlattenException $exception) { return <<<EOF -<!DOCTYPE html> -<html> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> - <meta name="robots" content="noindex,nofollow" /> - <title>{$title}</title> - <style> - /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */ - html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} - - html { background: #eee; padding: 10px } - body { font: 11px Verdana, Arial, sans-serif; color: #333 } - img { border: 0; } - .clear { clear:both; height:0; font-size:0; line-height:0; } - .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; } - .clear_fix { display:inline-block; } - * html .clear_fix { height:1%; } - .clear_fix { display:block; } - #content { width:970px; margin:0 auto; } - .sf-exceptionreset, .sf-exceptionreset .block { margin: auto } - .sf-exceptionreset abbr { border-bottom: 1px dotted #000; cursor: help; } - .sf-exceptionreset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px } - .sf-exceptionreset strong { font-weight:bold; } - .sf-exceptionreset a { color:#6c6159; } - .sf-exceptionreset a img { border:none; } - .sf-exceptionreset a:hover { text-decoration:underline; } - .sf-exceptionreset em { font-style:italic; } - .sf-exceptionreset h1, .sf-exceptionreset h2 { font: 20px Georgia, "Times New Roman", Times, serif } - .sf-exceptionreset h2 span { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; } - .sf-exceptionreset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; } - .sf-exceptionreset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px; + .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 } + .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; } + .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; } + .sf-reset .clear_fix { display:inline-block; } + .sf-reset * html .clear_fix { height:1%; } + .sf-reset .clear_fix { display:block; } + .sf-reset, .sf-reset .block { margin: auto } + .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; } + .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px } + .sf-reset strong { font-weight:bold; } + .sf-reset a { color:#6c6159; } + .sf-reset a img { border:none; } + .sf-reset a:hover { text-decoration:underline; } + .sf-reset em { font-style:italic; } + .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif } + .sf-reset h2 span { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; } + .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; } + .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px; -webkit-border-bottom-right-radius: 16px; -webkit-border-bottom-left-radius: 16px; -moz-border-radius-bottomright: 16px; @@ -189,7 +195,7 @@ private function decorate($content, $title) border-right:1px solid #ccc; border-left:1px solid #ccc; } - .sf-exceptionreset .block_exception { background-color:#ddd; color: #333; padding:20px; + .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px; -webkit-border-top-left-radius: 16px; -webkit-border-top-right-radius: 16px; -moz-border-radius-topleft: 16px; @@ -200,22 +206,38 @@ private function decorate($content, $title) border-right:1px solid #ccc; border-left:1px solid #ccc; } - .sf-exceptionreset li a { background:none; color:#868686; text-decoration:none; } - .sf-exceptionreset li a:hover { background:none; color:#313131; text-decoration:underline; } - .sf-exceptionreset ol { padding: 10px 0; } - .sf-exceptionreset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px; + .sf-reset li a { background:none; color:#868686; text-decoration:none; } + .sf-reset li a:hover { background:none; color:#313131; text-decoration:underline; } + .sf-reset ol { padding: 10px 0; } + .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px; -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; border: 1px solid #ccc; } +EOF; + } + + private function decorate($content, $css) + { + return <<<EOF +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <meta name="robots" content="noindex,nofollow" /> + <style> + /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */ + html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} + + html { background: #eee; padding: 10px } + img { border: 0; } + #sf-resetcontent { width:970px; margin:0 auto; } + $css </style> </head> <body> - <div id="content" class="sf-exceptionreset"> - <h1>$title</h1> -$content - </div> + $content </body> </html> EOF; @@ -235,7 +257,7 @@ private function abbrClass($class) * * @return string */ - public function formatArgs(array $args) + private function formatArgs(array $args) { $result = array(); foreach ($args as $key => $item) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/Stopwatch.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/Stopwatch.php deleted file mode 100644 index 7f2673d386cc..000000000000 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/Stopwatch.php +++ /dev/null @@ -1,251 +0,0 @@ -<?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\Component\HttpKernel\Debug; - -/** - * Stopwatch provides a way to profile code. - * - * @author Fabien Potencier <fabien@symfony.com> - */ -class Stopwatch -{ - private $sections; - private $activeSections; - - public function __construct() - { - $this->sections = $this->activeSections = array('__root__' => new Section('__root__')); - } - - /** - * Creates a new section or re-opens an existing section. - * - * @param string|null $id The id of the session to re-open, null to create a new one - * - * @throws \LogicException When the section to re-open is not reachable - */ - public function openSection($id = null) - { - $current = end($this->activeSections); - - if (null !== $id && null === $current->get($id)) { - throw new \LogicException(sprintf('The section "%s" has been started at an other level and can not be opened.', $id)); - } - - $this->start('__section__.child', 'section'); - $this->activeSections[] = $current->open($id); - $this->start('__section__'); - } - - /** - * Stops the last started section. - * - * The id parameter is used to retrieve the events from this section. - * - * @see getSectionEvents - * - * @param string $id The identifier of the section - */ - public function stopSection($id) - { - $this->stop('__section__'); - - if (1 == count($this->activeSections)) { - throw new \LogicException('There is no started section to stop.'); - } - - $this->sections[$id] = array_pop($this->activeSections)->setId($id); - $this->stop('__section__.child'); - } - - /** - * Starts an event. - * - * @param string $name The event name - * @param string $category The event category - * - * @return StopwatchEvent A StopwatchEvent instance - */ - public function start($name, $category = null) - { - return end($this->activeSections)->startEvent($name, $category); - } - - /** - * Stops an event. - * - * @param string $name The event name - * - * @return StopwatchEvent A StopwatchEvent instance - */ - public function stop($name) - { - return end($this->activeSections)->stopEvent($name); - } - - /** - * Stops then restarts an event. - * - * @param string $name The event name - * - * @return StopwatchEvent A StopwatchEvent instance - */ - public function lap($name) - { - return end($this->activeSections)->stopEvent($name)->start(); - } - - /** - * Gets all events for a given section. - * - * @param string $id A section identifier - * - * @return StopwatchEvent[] An array of StopwatchEvent instances - */ - public function getSectionEvents($id) - { - return isset($this->sections[$id]) ? $this->sections[$id]->getEvents() : array(); - } -} - -class Section -{ - private $events = array(); - private $origin; - private $id; - private $children = array(); - - /** - * Constructor. - * - * @param float|null $origin Set the origin of the events in this section, use null to set their origin to their start time - */ - public function __construct($origin = null) - { - $this->origin = is_numeric($origin) ? $origin : null; - } - - /** - * Returns the child section. - * - * @param string $id The child section identifier - * - * @return Section|null The child section or null when none found - */ - public function get($id) - { - foreach ($this->children as $child) { - if ($id === $child->getId()) { - return $child; - } - } - - return null; - } - - /** - * Creates or re-opens a child section. - * - * @param string|null $id null to create a new section, the identifier to re-open an existing one. - * - * @return Section A child section - */ - public function open($id) - { - if (null === $session = $this->get($id)) { - $session = $this->children[] = new self(microtime(true) * 1000); - } - - return $session; - } - - /** - * @return string The identifier of the section - */ - public function getId() - { - return $this->id; - } - - /** - * Sets the session identifier. - * - * @param string $id The session identifier - * - * @return Section The current section - */ - public function setId($id) - { - $this->id = $id; - - return $this; - } - - /** - * Starts an event. - * - * @param string $name The event name - * @param string $category The event category - * - * @return StopwatchEvent The event - */ - public function startEvent($name, $category) - { - if (!isset($this->events[$name])) { - $this->events[$name] = new StopwatchEvent($this->origin ?: microtime(true) * 1000, $category); - } - - return $this->events[$name]->start(); - } - - /** - * Stops an event. - * - * @param string $name The event name - * - * @return StopwatchEvent The event - * - * @throws \LogicException When the event has not been started - */ - public function stopEvent($name) - { - if (!isset($this->events[$name])) { - throw new \LogicException(sprintf('Event "%s" is not started.', $name)); - } - - return $this->events[$name]->stop(); - } - - /** - * Stops then restarts an event. - * - * @param string $name The event name - * - * @return StopwatchEvent The event - * - * @throws \LogicException When the event has not been started - */ - public function lap($name) - { - return $this->stop($name)->start(); - } - - /** - * Returns the events from this section. - * - * @return StopwatchEvent[] An array of StopwatchEvent instances - */ - public function getEvents() - { - return $this->events; - } -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php deleted file mode 100644 index 200c465bacfa..000000000000 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php +++ /dev/null @@ -1,182 +0,0 @@ -<?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\Component\HttpKernel\Debug; - -/** - * Represents an Event managed by Stopwatch. - * - * @author Fabien Potencier <fabien@symfony.com> - */ -class StopwatchEvent -{ - private $periods; - private $origin; - private $category; - private $started; - - /** - * Constructor. - * - * @param float $origin The origin time in milliseconds - * @param string $category The event category - * - * @throws \InvalidArgumentException When the raw time is not valid - */ - public function __construct($origin, $category = null) - { - $this->origin = $this->formatTime($origin); - $this->category = is_string($category) ? $category : 'default'; - $this->started = array(); - $this->periods = array(); - } - - /** - * Gets the category. - * - * @return string The category - */ - public function getCategory() - { - return $this->category; - } - - /** - * Gets the origin. - * - * @return integer The origin in milliseconds - */ - public function getOrigin() - { - return $this->origin; - } - - /** - * Starts a new event period. - * - * @return StopwatchEvent The event - */ - public function start() - { - $this->started[] = $this->getNow(); - - return $this; - } - - /** - * Stops the last started event period. - * - * @return StopwatchEvent The event - */ - public function stop() - { - if (!count($this->started)) { - throw new \LogicException('stop() called but start() has not been called before.'); - } - - $this->periods[] = array(array_pop($this->started), $this->getNow()); - - return $this; - } - - /** - * Stops the current period and then starts a new one. - * - * @return StopwatchEvent The event - */ - public function lap() - { - return $this->stop()->start(); - } - - /** - * Stops all non already stopped periods. - */ - public function ensureStopped() - { - while (count($this->started)) { - $this->stop(); - } - } - - /** - * Gets all event periods. - * - * @return array An array of periods - */ - public function getPeriods() - { - return $this->periods; - } - - /** - * Gets the relative time of the start of the first period. - * - * @return integer The time (in milliseconds) - */ - public function getStartTime() - { - return isset($this->periods[0]) ? $this->periods[0][0] : 0; - } - - /** - * Gets the relative time of the end of the last period. - * - * @return integer The time (in milliseconds) - */ - public function getEndTime() - { - return ($count = count($this->periods)) ? $this->periods[$count - 1][1] : 0; - } - - /** - * Gets the total time of all periods. - * - * @return integer The time (in milliseconds) - */ - public function getTotalTime() - { - $total = 0; - foreach ($this->periods as $period) { - $total += $period[1] - $period[0]; - } - - return $this->formatTime($total); - } - - /** - * Return the current time relative to origin. - * - * @return float Time in ms - */ - protected function getNow() - { - return $this->formatTime(microtime(true) * 1000 - $this->origin); - } - - /** - * Formats a time. - * - * @param numerical $time A raw time - * - * @return float The formatted time - * - * @throws \InvalidArgumentException When the raw time is not valid - */ - private function formatTime($time) - { - if (!is_numeric($time)) { - throw new \InvalidArgumentException('The time must be a numerical value'); - } - - return round($time, 1); - } -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php new file mode 100644 index 000000000000..e4aab5ba4d00 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php @@ -0,0 +1,452 @@ +<?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\Component\HttpKernel\Debug; + +use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Component\HttpKernel\Log\LoggerInterface; +use Symfony\Component\HttpKernel\Profiler\Profile; +use Symfony\Component\HttpKernel\Profiler\Profiler; +use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; + +/** + * Collects some data about event listeners. + * + * This event dispatcher delegates the dispatching to another one. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEventDispatcherInterface +{ + private $logger; + private $called; + private $stopwatch; + private $profiler; + private $dispatcher; + private $wrappedListeners; + private $firstCalledEvent; + private $id; + + /** + * Constructor. + * + * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance + * @param Stopwatch $stopwatch A Stopwatch instance + * @param LoggerInterface $logger A LoggerInterface instance + */ + public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null) + { + $this->dispatcher = $dispatcher; + $this->stopwatch = $stopwatch; + $this->logger = $logger; + $this->called = array(); + $this->wrappedListeners = array(); + $this->firstCalledEvent = array(); + } + + /** + * Sets the profiler. + * + * @param Profiler|null $profiler A Profiler instance + */ + public function setProfiler(Profiler $profiler = null) + { + $this->profiler = $profiler; + } + + /** + * {@inheritDoc} + */ + public function addListener($eventName, $listener, $priority = 0) + { + $this->dispatcher->addListener($eventName, $listener, $priority); + } + + /** + * {@inheritdoc} + */ + public function addSubscriber(EventSubscriberInterface $subscriber) + { + $this->dispatcher->addSubscriber($subscriber); + } + + /** + * {@inheritdoc} + */ + public function removeListener($eventName, $listener) + { + return $this->dispatcher->removeListener($eventName, $listener); + } + + /** + * {@inheritdoc} + */ + public function removeSubscriber(EventSubscriberInterface $subscriber) + { + return $this->dispatcher->removeSubscriber($subscriber); + } + + /** + * {@inheritdoc} + */ + public function getListeners($eventName = null) + { + return $this->dispatcher->getListeners($eventName); + } + + /** + * {@inheritdoc} + */ + public function hasListeners($eventName = null) + { + return $this->dispatcher->hasListeners($eventName); + } + + /** + * {@inheritdoc} + */ + public function dispatch($eventName, Event $event = null) + { + if (null === $event) { + $event = new Event(); + } + + $this->id = spl_object_hash($event); + + $this->preDispatch($eventName, $event); + + $e = $this->stopwatch->start($eventName, 'section'); + + $this->firstCalledEvent[$eventName] = $this->stopwatch->start($eventName.'.loading', 'event_listener_loading'); + + $this->dispatcher->dispatch($eventName, $event); + + // reset the id as another event might have been dispatched during the dispatching of this event + $this->id = spl_object_hash($event); + + unset($this->firstCalledEvent[$eventName]); + + $e->stop(); + + $this->postDispatch($eventName, $event); + + return $event; + } + + /** + * {@inheritDoc} + */ + public function getCalledListeners() + { + return $this->called; + } + + /** + * {@inheritDoc} + */ + public function getNotCalledListeners() + { + $notCalled = array(); + + foreach ($this->getListeners() as $name => $listeners) { + foreach ($listeners as $listener) { + $info = $this->getListenerInfo($listener, $name); + if (!isset($this->called[$name.'.'.$info['pretty']])) { + $notCalled[$name.'.'.$info['pretty']] = $info; + } + } + } + + return $notCalled; + } + + /** + * Proxies all method calls to the original event dispatcher. + * + * @param string $method The method name + * @param array $arguments The method arguments + */ + public function __call($method, $arguments) + { + return call_user_func_array(array($this->dispatcher, $method), $arguments); + } + + /** + * This is a private method and must not be used. + * + * This method is public because it is used in a closure. + * Whenever Symfony will require PHP 5.4, this could be changed + * to a proper private method. + */ + public function logSkippedListeners($eventName, Event $event, $listener) + { + if (null === $this->logger) { + return; + } + + $info = $this->getListenerInfo($listener, $eventName); + + $this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName)); + + $skippedListeners = $this->getListeners($eventName); + $skipped = false; + + foreach ($skippedListeners as $skippedListener) { + $skippedListener = $this->unwrapListener($skippedListener); + + if ($skipped) { + $info = $this->getListenerInfo($skippedListener, $eventName); + $this->logger->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName)); + } + + if ($skippedListener === $listener) { + $skipped = true; + } + } + } + + /** + * This is a private method. + * + * This method is public because it is used in a closure. + * Whenever Symfony will require PHP 5.4, this could be changed + * to a proper private method. + */ + public function preListenerCall($eventName, $listener) + { + // is it the first called listener? + if (isset($this->firstCalledEvent[$eventName])) { + $this->firstCalledEvent[$eventName]->stop(); + + unset($this->firstCalledEvent[$eventName]); + } + + $info = $this->getListenerInfo($listener, $eventName); + + if (null !== $this->logger) { + $this->logger->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty'])); + } + + $this->called[$eventName.'.'.$info['pretty']] = $info; + + return $this->stopwatch->start(isset($info['class']) ? $info['class'] : $info['type'], 'event_listener'); + } + + /** + * Returns information about the listener + * + * @param object $listener The listener + * @param string $eventName The event name + * + * @return array Informations about the listener + */ + private function getListenerInfo($listener, $eventName) + { + $listener = $this->unwrapListener($listener); + + $info = array( + 'event' => $eventName, + ); + if ($listener instanceof \Closure) { + $info += array( + 'type' => 'Closure', + 'pretty' => 'closure' + ); + } elseif (is_string($listener)) { + try { + $r = new \ReflectionFunction($listener); + $file = $r->getFileName(); + $line = $r->getStartLine(); + } catch (\ReflectionException $e) { + $file = null; + $line = null; + } + $info += array( + 'type' => 'Function', + 'function' => $listener, + 'file' => $file, + 'line' => $line, + 'pretty' => $listener, + ); + } elseif (is_array($listener) || (is_object($listener) && is_callable($listener))) { + if (!is_array($listener)) { + $listener = array($listener, '__invoke'); + } + $class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0]; + try { + $r = new \ReflectionMethod($class, $listener[1]); + $file = $r->getFileName(); + $line = $r->getStartLine(); + } catch (\ReflectionException $e) { + $file = null; + $line = null; + } + $info += array( + 'type' => 'Method', + 'class' => $class, + 'method' => $listener[1], + 'file' => $file, + 'line' => $line, + 'pretty' => $class.'::'.$listener[1], + ); + } + + return $info; + } + + /** + * Updates the stopwatch data in the profile hierarchy. + * + * @param string $token Profile token + * @param Boolean $updateChildren Whether to update the children altogether + */ + private function updateProfiles($token, $updateChildren) + { + if (!$this->profiler || !$profile = $this->profiler->loadProfile($token)) { + return; + } + + $this->saveInfoInProfile($profile, $updateChildren); + } + + /** + * Update the profiles with the timing and events information and saves them. + * + * @param Profile $profile The root profile + * @param Boolean $updateChildren Whether to update the children altogether + */ + private function saveInfoInProfile(Profile $profile, $updateChildren) + { + try { + $collector = $profile->getCollector('memory'); + $collector->updateMemoryUsage(); + } catch (\InvalidArgumentException $e) { + } + + try { + $collector = $profile->getCollector('time'); + $collector->setEvents($this->stopwatch->getSectionEvents($profile->getToken())); + } catch (\InvalidArgumentException $e) { + } + + try { + $collector = $profile->getCollector('events'); + $collector->setCalledListeners($this->getCalledListeners()); + $collector->setNotCalledListeners($this->getNotCalledListeners()); + } catch (\InvalidArgumentException $e) { + } + + $this->profiler->saveProfile($profile); + + if ($updateChildren) { + foreach ($profile->getChildren() as $child) { + $this->saveInfoInProfile($child, true); + } + } + } + + private function preDispatch($eventName, Event $event) + { + // wrap all listeners before they are called + $this->wrappedListeners[$this->id] = new \SplObjectStorage(); + + $listeners = $this->dispatcher->getListeners($eventName); + + foreach ($listeners as $listener) { + $this->dispatcher->removeListener($eventName, $listener); + $wrapped = $this->wrapListener($eventName, $listener); + $this->wrappedListeners[$this->id][$wrapped] = $listener; + $this->dispatcher->addListener($eventName, $wrapped); + } + + switch ($eventName) { + case 'kernel.request': + $this->stopwatch->openSection(); + break; + case 'kernel.view': + case 'kernel.response': + // stop only if a controller has been executed + try { + $this->stopwatch->stop('controller'); + } catch (\LogicException $e) { + } + break; + case 'kernel.terminate': + $token = $event->getResponse()->headers->get('X-Debug-Token'); + $this->stopwatch->openSection($token); + break; + } + } + + private function postDispatch($eventName, Event $event) + { + switch ($eventName) { + case 'kernel.controller': + $this->stopwatch->start('controller', 'section'); + break; + case 'kernel.response': + $token = $event->getResponse()->headers->get('X-Debug-Token'); + $this->stopwatch->stopSection($token); + if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { + // The profiles can only be updated once they have been created + // that is after the 'kernel.response' event of the main request + $this->updateProfiles($token, true); + } + break; + case 'kernel.terminate': + $token = $event->getResponse()->headers->get('X-Debug-Token'); + $this->stopwatch->stopSection($token); + // The children profiles have been updated by the previous 'kernel.response' + // event. Only the root profile need to be updated with the 'kernel.terminate' + // timing informations. + $this->updateProfiles($token, false); + break; + } + + foreach ($this->wrappedListeners[$this->id] as $wrapped) { + $this->dispatcher->removeListener($eventName, $wrapped); + $this->dispatcher->addListener($eventName, $this->wrappedListeners[$this->id][$wrapped]); + } + + unset($this->wrappedListeners[$this->id]); + } + + private function wrapListener($eventName, $listener) + { + $self = $this; + + return function (Event $event) use ($self, $eventName, $listener) { + $e = $self->preListenerCall($eventName, $listener); + + call_user_func($listener, $event); + + $e->stop(); + + if ($event->isPropagationStopped()) { + $self->logSkippedListeners($eventName, $event, $listener); + } + }; + } + + private function unwrapListener($listener) + { + // get the original listener + if (is_object($listener) && isset($this->wrappedListeners[$this->id][$listener])) { + return $this->wrappedListeners[$this->id][$listener]; + } + + return $listener; + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php index 196bd67e7182..8de76a5f8b81 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php @@ -30,7 +30,7 @@ class FilterResponseEvent extends KernelEvent { /** * The current response object - * @var Symfony\Component\HttpFoundation\Response + * @var Response */ private $response; @@ -44,7 +44,7 @@ public function __construct(HttpKernelInterface $kernel, Request $request, $requ /** * Returns the current response object * - * @return Symfony\Component\HttpFoundation\Response + * @return Response * * @api */ @@ -56,7 +56,7 @@ public function getResponse() /** * Sets a new response object * - * @param Symfony\Component\HttpFoundation\Response $response + * @param Response $response * * @api */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php index c8c2f00625f3..f71ccae2325d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php @@ -28,14 +28,14 @@ class GetResponseEvent extends KernelEvent { /** * The response object - * @var Symfony\Component\HttpFoundation\Response + * @var Response */ private $response; /** * Returns the response object * - * @return Symfony\Component\HttpFoundation\Response + * @return Response * * @api */ @@ -47,7 +47,7 @@ public function getResponse() /** * Sets a response and stops event propagation * - * @param Symfony\Component\HttpFoundation\Response $response + * @param Response $response * * @api */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php index bcabcf32d5ea..a71f504d996e 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php @@ -29,6 +29,7 @@ class GetResponseForControllerResultEvent extends GetResponseEvent { /** * The return value of the controller + * * @var mixed */ private $controllerResult; @@ -41,7 +42,7 @@ public function __construct(HttpKernelInterface $kernel, Request $request, $requ } /** - * Returns the return value of the controller + * Returns the return value of the controller. * * @return mixed The controller return value * @@ -51,4 +52,16 @@ public function getControllerResult() { return $this->controllerResult; } + + /** + * Assigns the return value of the controller. + * + * @param array The controller return value + * + * @api + */ + public function setControllerResult(array $controllerResult) + { + $this->controllerResult = $controllerResult; + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php index 2e1790a3c2c6..e57eed4d16f2 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php @@ -26,13 +26,13 @@ class KernelEvent extends Event { /** * The kernel in which this event was thrown - * @var Symfony\Component\HttpKernel\HttpKernelInterface + * @var HttpKernelInterface */ private $kernel; /** * The request the kernel is currently processing - * @var Symfony\Component\HttpFoundation\Request + * @var Request */ private $request; @@ -53,7 +53,7 @@ public function __construct(HttpKernelInterface $kernel, Request $request, $requ /** * Returns the kernel in which this event was thrown * - * @return Symfony\Component\HttpKernel\HttpKernelInterface + * @return HttpKernelInterface * * @api */ @@ -65,7 +65,7 @@ public function getKernel() /** * Returns the request the kernel is currently processing * - * @return Symfony\Component\HttpFoundation\Request + * @return Request * * @api */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php index 7778df84acb3..714102bed8d5 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php @@ -22,9 +22,9 @@ class AccessDeniedHttpException extends HttpException /** * Constructor. * - * @param string $message The internal exception message - * @param Exception $previous The previous exception - * @param integer $code The internal exception code + * @param string $message The internal exception message + * @param \Exception $previous The previous exception + * @param integer $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php new file mode 100644 index 000000000000..753839cd874b --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php @@ -0,0 +1,32 @@ +<?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\Component\HttpKernel\Exception; + +/** + * BadRequestHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class BadRequestHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(400, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php new file mode 100644 index 000000000000..95f1db093f8f --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php @@ -0,0 +1,32 @@ +<?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\Component\HttpKernel\Exception; + +/** + * ConflictHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class ConflictHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(409, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php index b2ffb9fcfbb2..eb5e5715fa80 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php @@ -221,6 +221,9 @@ private function flattenArgs($args, $level = 0) $result[$key] = array('boolean', $value); } elseif (is_resource($value)) { $result[$key] = array('resource', get_resource_type($value)); + } elseif ($value instanceof \__PHP_Incomplete_Class) { + // Special case of object, is_object will return false + $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value)); } else { $result[$key] = array('string', (string) $value); } @@ -228,4 +231,11 @@ private function flattenArgs($args, $level = 0) return $result; } + + private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) + { + $array = new \ArrayObject($value); + + return $array['__PHP_Incomplete_Class_Name']; + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php new file mode 100644 index 000000000000..5099944e18e3 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php @@ -0,0 +1,32 @@ +<?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\Component\HttpKernel\Exception; + +/** + * GoneHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class GoneHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(410, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php new file mode 100644 index 000000000000..ab54b9a77a60 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php @@ -0,0 +1,32 @@ +<?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\Component\HttpKernel\Exception; + +/** + * LengthRequiredHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class LengthRequiredHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(411, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php index cdfcc8ab7b40..3a81586a62b6 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php @@ -21,10 +21,10 @@ class MethodNotAllowedHttpException extends HttpException /** * Constructor. * - * @param array $allow An array of allowed methods - * @param string $message The internal exception message - * @param Exception $previous The previous exception - * @param integer $code The internal exception code + * @param array $allow An array of allowed methods + * @param string $message The internal exception message + * @param \Exception $previous The previous exception + * @param integer $code The internal exception code */ public function __construct(array $allow, $message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php new file mode 100644 index 000000000000..19fc4430aac0 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php @@ -0,0 +1,32 @@ +<?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\Component\HttpKernel\Exception; + +/** + * NotAcceptableHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class NotAcceptableHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(406, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php index c99502d7fe41..547976c3f1b1 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php @@ -21,9 +21,9 @@ class NotFoundHttpException extends HttpException /** * Constructor. * - * @param string $message The internal exception message - * @param Exception $previous The previous exception - * @param integer $code The internal exception code + * @param string $message The internal exception message + * @param \Exception $previous The previous exception + * @param integer $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php new file mode 100644 index 000000000000..02d992d6c4cb --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php @@ -0,0 +1,32 @@ +<?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\Component\HttpKernel\Exception; + +/** + * PreconditionFailedHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class PreconditionFailedHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(412, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php new file mode 100644 index 000000000000..e0ffe2d03fa2 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php @@ -0,0 +1,33 @@ +<?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\Component\HttpKernel\Exception; + +/** + * PreconditionRequiredHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + * @see http://tools.ietf.org/html/rfc6585 + */ +class PreconditionRequiredHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(428, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php new file mode 100644 index 000000000000..031b85d685e6 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php @@ -0,0 +1,38 @@ +<?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\Component\HttpKernel\Exception; + +/** + * ServiceUnavailableHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class ServiceUnavailableHttpException extends HttpException +{ + /** + * Constructor. + * + * @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($retryAfter = null, $message = null, \Exception $previous = null, $code = 0) + { + $headers = array(); + if ($retryAfter) { + $headers = array('Retry-After' => $retryAfter); + } + + parent::__construct(503, $message, $previous, $headers, $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php new file mode 100644 index 000000000000..7a7c10f521a9 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php @@ -0,0 +1,39 @@ +<?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\Component\HttpKernel\Exception; + +/** + * TooManyRequestsHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + * @see http://tools.ietf.org/html/rfc6585 + */ +class TooManyRequestsHttpException extends HttpException +{ + /** + * Constructor. + * + * @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($retryAfter = null, $message = null, \Exception $previous = null, $code = 0) + { + $headers = array(); + if ($retryAfter) { + $headers = array('Retry-After' => $retryAfter); + } + + parent::__construct(429, $message, $previous, $headers, $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php new file mode 100644 index 000000000000..d3b86c6ceb34 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php @@ -0,0 +1,35 @@ +<?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\Component\HttpKernel\Exception; + +/** + * UnauthorizedHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class UnauthorizedHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $challenge WWW-Authenticate challenge string + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($challenge, $message = null, \Exception $previous = null, $code = 0) + { + $headers = array('WWW-Authenticate' => $challenge); + + parent::__construct(401, $message, $previous, $headers, $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php new file mode 100644 index 000000000000..d92c0f2f44be --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php @@ -0,0 +1,32 @@ +<?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\Component\HttpKernel\Exception; + +/** + * UnsupportedMediaTypeHttpException. + * + * @author Ben Ramsey <ben@benramsey.com> + */ +class UnsupportedMediaTypeHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param Exception $previous The previous exception + * @param integer $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(415, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index ec66dcd5fcbe..649f4ffe69ad 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -515,7 +515,7 @@ protected function lock(Request $request, Response $entry) // wait for the lock to be released $wait = 0; - while (is_file($lock) && $wait < 5000000) { + while ($this->store->isLocked($request) && $wait < 5000000) { usleep(50000); $wait += 50000; } @@ -580,7 +580,7 @@ protected function store(Request $request, Response $response) */ private function restoreResponseBody(Request $request, Response $response) { - if ('HEAD' === $request->getMethod() || 304 === $response->getStatusCode()) { + if ($request->isMethod('HEAD') || 304 === $response->getStatusCode()) { $response->setContent(null); $response->headers->remove('X-Body-Eval'); $response->headers->remove('X-Body-File'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php index b60c647e743b..b0662db99d06 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -24,7 +24,7 @@ */ class Store implements StoreInterface { - private $root; + protected $root; private $keyCache; private $locks; @@ -71,25 +71,39 @@ public function cleanup() */ public function lock(Request $request) { - if (false !== $lock = @fopen($path = $this->getPath($this->getCacheKey($request).'.lck'), 'x')) { + $path = $this->getPath($this->getCacheKey($request).'.lck'); + if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) { + return false; + } + + $lock = @fopen($path, 'x'); + if (false !== $lock) { fclose($lock); $this->locks[] = $path; return true; } - - return $path; + return !file_exists($path) ?: $path; } /** * Releases the lock for the given Request. * * @param Request $request A Request instance + * + * @return Boolean False if the lock file does not exist or cannot be unlocked, true otherwise */ public function unlock(Request $request) { - return @unlink($this->getPath($this->getCacheKey($request).'.lck')); + $file = $this->getPath($this->getCacheKey($request).'.lck'); + + return is_file($file) ? @unlink($file) : false; + } + + public function isLocked(Request $request) + { + return is_file($this->getPath($this->getCacheKey($request).'.lck')); } /** @@ -150,7 +164,7 @@ public function write(Request $request, Response $response) // write the response body to the entity store if this is the original response if (!$response->headers->has('X-Content-Digest')) { - $digest = 'en'.sha1($response->getContent()); + $digest = $this->generateContentDigest($response); if (false === $this->save($digest, $response->getContent())) { throw new \RuntimeException('Unable to store the entity.'); @@ -188,6 +202,18 @@ public function write(Request $request, Response $response) return $key; } + /** + * Returns content digest for $response. + * + * @param Response $response + * + * @return string + */ + protected function generateContentDigest(Response $response) + { + return 'en'.sha1($response->getContent()); + } + /** * Invalidates all cache entries that match the request. * diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php index dd8c8869798d..29a54d872544 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php @@ -66,9 +66,20 @@ public function lock(Request $request); * Releases the lock for the given Request. * * @param Request $request A Request instance + * + * @return Boolean False if the lock file does not exist or cannot be unlocked, true otherwise */ public function unlock(Request $request); + /** + * Returns whether or not a lock exists. + * + * @param Request $request A Request instance + * + * @return Boolean true if lock exists, false otherwise + */ + public function isLocked(Request $request); + /** * Purges data for the given URL. * diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php index d601e4b76cb4..046d0c8a6ade 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php @@ -46,7 +46,11 @@ */ abstract class Kernel implements KernelInterface, TerminableInterface { + /** + * @var BundleInterface[] + */ protected $bundles; + protected $bundleMap; protected $container; protected $rootDir; @@ -58,12 +62,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $classes; protected $errorReportingLevel; - const VERSION = '2.1.0-RC2'; + const VERSION = '2.2.0-DEV'; const VERSION_ID = '20100'; const MAJOR_VERSION = '2'; - const MINOR_VERSION = '1'; + const MINOR_VERSION = '2'; const RELEASE_VERSION = '0'; - const EXTRA_VERSION = 'RC2'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. @@ -157,9 +161,7 @@ public function terminate(Request $request, Response $response) } /** - * Shutdowns the kernel. - * - * This method is mainly useful when doing functional testing. + * {@inheritdoc} * * @api */ @@ -204,10 +206,8 @@ protected function getHttpKernel() } /** - * Gets the registered bundle instances. - * - * @return array An array of registered bundle instances - * + * {@inheritdoc} + * * @api */ public function getBundles() @@ -216,11 +216,7 @@ public function getBundles() } /** - * Checks if a given class name belongs to an active bundle. - * - * @param string $class A class name - * - * @return Boolean true if the class belongs to an active bundle, false otherwise + * {@inheritdoc} * * @api */ @@ -236,21 +232,14 @@ public function isClassInActiveBundle($class) } /** - * Returns a bundle and optionally its descendants by its name. - * - * @param string $name Bundle name - * @param Boolean $first Whether to return the first bundle only or together with its descendants - * - * @return BundleInterface|Array A BundleInterface instance or an array of BundleInterface instances if $first is false - * - * @throws \InvalidArgumentException when the bundle is not enabled + * {@inheritdoc} * * @api */ public function getBundle($name, $first = true) { if (!isset($this->bundleMap[$name])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() function of your %s.php file?', $name, get_class($this))); + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, get_class($this))); } if (true === $first) { @@ -346,9 +335,7 @@ public function locateResource($name, $dir = null, $first = true) } /** - * Gets the name of the kernel - * - * @return string The kernel name + * {@inheritdoc} * * @api */ @@ -362,9 +349,7 @@ public function getName() } /** - * Gets the environment. - * - * @return string The current environment + * {@inheritdoc} * * @api */ @@ -374,9 +359,7 @@ public function getEnvironment() } /** - * Checks if debug mode is enabled. - * - * @return Boolean true if debug mode is enabled, false otherwise + * {@inheritdoc} * * @api */ @@ -386,9 +369,7 @@ public function isDebug() } /** - * Gets the application root dir. - * - * @return string The application root dir + * {@inheritdoc} * * @api */ @@ -403,9 +384,7 @@ public function getRootDir() } /** - * Gets the current container. - * - * @return ContainerInterface A ContainerInterface instance + * {@inheritdoc} * * @api */ @@ -436,9 +415,7 @@ public function setClassCache(array $classes) } /** - * Gets the request start time (not available if debug is disabled). - * - * @return integer The request start timestamp + * {@inheritdoc} * * @api */ @@ -448,9 +425,7 @@ public function getStartTime() } /** - * Gets the cache directory. - * - * @return string The cache directory + * {@inheritdoc} * * @api */ @@ -460,9 +435,7 @@ public function getCacheDir() } /** - * Gets the log directory. - * - * @return string The log directory + * {@inheritdoc} * * @api */ @@ -472,9 +445,7 @@ public function getLogDir() } /** - * Gets the charset of the application. - * - * @return string The charset + * {@inheritdoc} * * @api */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php index 4010a3020e21..dd37b60e0325 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php @@ -30,7 +30,7 @@ interface KernelInterface extends HttpKernelInterface, \Serializable /** * Returns an array of bundles to registers. * - * @return array An array of bundle instances. + * @return BundleInterface[] An array of bundle instances. * * @api */ @@ -64,7 +64,7 @@ public function shutdown(); /** * Gets the registered bundle instances. * - * @return array An array of registered bundle instances + * @return BundleInterface[] An array of registered bundle instances * * @api */ @@ -87,7 +87,7 @@ public function isClassInActiveBundle($class); * @param string $name Bundle name * @param Boolean $first Whether to return the first bundle only or together with its descendants * - * @return BundleInterface|Array A BundleInterface instance or an array of BundleInterface instances if $first is false + * @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false * * @throws \InvalidArgumentException when the bundle is not enabled * diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index 94052f8b1f53..4505ba218f3f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -34,7 +34,7 @@ class FileProfilerStorage implements ProfilerStorageInterface public function __construct($dsn) { if (0 !== strpos($dsn, 'file:')) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $this->dsn)); + throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $dsn)); } $this->folder = substr($dsn, 5); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php index 0dcad22df50d..90db3dfbb137 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php @@ -32,14 +32,7 @@ public function __construct($dsn, $username = '', $password = '', $lifetime = 86 } /** - * Finds profiler tokens for the given criteria. - * - * @param string $ip The IP - * @param string $url The URL - * @param string $limit The maximum number of tokens to return - * @param string $method The request method - * - * @return array An array of tokens + * {@inheritdoc} */ public function find($ip, $url, $limit, $method) { @@ -54,7 +47,7 @@ public function find($ip, $url, $limit, $method) } /** - * Purges all data from the database. + * {@inheritdoc} */ public function purge() { @@ -62,13 +55,7 @@ public function purge() } /** - * Reads data associated with the given token. - * - * The method returns false if the token does not exists in the storage. - * - * @param string $token A token - * - * @return Profile The profile associated with token + * {@inheritdoc} */ public function read($token) { @@ -82,11 +69,7 @@ public function read($token) } /** - * Saves a Profile. - * - * @param Profile $profile A Profile instance - * - * @return Boolean Write operation successful + * {@inheritdoc} */ public function write(Profile $profile) { @@ -95,7 +78,7 @@ public function write(Profile $profile) $record = array( '_id' => $profile->getToken(), 'parent' => $profile->getParentToken(), - 'data' => serialize($profile->getCollectors()), + 'data' => base64_encode(serialize($profile->getCollectors())), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), @@ -128,6 +111,7 @@ protected function getMongo() /** * @param array $data + * * @return Profile */ protected function createProfileFromData(array $data) @@ -148,7 +132,8 @@ protected function createProfileFromData(array $data) /** * @param string $token - * @return array + * + * @return Profile[] An array of Profile instances */ protected function readChildren($token) { @@ -171,6 +156,7 @@ protected function cleanup() * @param string $ip * @param string $url * @param string $method + * * @return array */ private function buildQuery($ip, $url, $method) @@ -194,6 +180,7 @@ private function buildQuery($ip, $url, $method) /** * @param array $data + * * @return array */ private function getData(array $data) @@ -211,6 +198,7 @@ private function getData(array $data) /** * @param array $data + * * @return Profile */ private function getProfile(array $data) @@ -220,7 +208,7 @@ private function getProfile(array $data) $profile->setMethod($data['method']); $profile->setUrl($data['url']); $profile->setTime($data['time']); - $profile->setCollectors(unserialize($data['data'])); + $profile->setCollectors(unserialize(base64_decode($data['data']))); return $profile; } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php index b7bc61769025..36dcab8ecc69 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php @@ -216,7 +216,7 @@ protected function createProfileFromData($token, $data, $parent = null) * @param string $token The parent token * @param string $parent The parent instance * - * @return array An array of Profile instance + * @return Profile[] An array of Profile instance */ protected function readChildren($token, $parent) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php index bed24f1d1095..e00ba71d3682 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php @@ -21,13 +21,26 @@ class Profile { private $token; - private $collectors; + + /** + * @var DataCollectorInterface[] + */ + private $collectors = array(); + private $ip; private $method; private $url; private $time; + + /** + * @var Profile + */ private $parent; - private $children; + + /** + * @var Profile[] + */ + private $children = array(); /** * Constructor. @@ -37,8 +50,6 @@ class Profile public function __construct($token) { $this->token = $token; - $this->collectors = array(); - $this->children = array(); } /** @@ -101,6 +112,11 @@ public function getIp() return $this->ip; } + /** + * Sets the IP. + * + * @param string $ip + */ public function setIp($ip) { $this->ip = $ip; @@ -154,13 +170,18 @@ public function setTime($time) /** * Finds children profilers. * - * @return array An array of Profile + * @return Profile[] An array of Profile */ public function getChildren() { return $this->children; } + /** + * Sets children profiler. + * + * @param Profile[] $children An array of Profile + */ public function setChildren(array $children) { $this->children = array(); @@ -180,6 +201,15 @@ public function addChild(Profile $child) $child->setParent($this); } + /** + * Gets a Collector by name. + * + * @param string $name A collector name + * + * @return DataCollectorInterface A DataCollectorInterface instance + * + * @throws \InvalidArgumentException if the collector does not exist + */ public function getCollector($name) { if (!isset($this->collectors[$name])) { @@ -189,11 +219,21 @@ public function getCollector($name) return $this->collectors[$name]; } + /** + * Gets the Collectors associated with this profile. + * + * @return DataCollectorInterface[] + */ public function getCollectors() { return $this->collectors; } + /** + * Sets the Collectors associated with this profile. + * + * @param DataCollectorInterface[] $collectors + */ public function setCollectors(array $collectors) { $this->collectors = array(); @@ -202,11 +242,23 @@ public function setCollectors(array $collectors) } } + /** + * Adds a Collector. + * + * @param DataCollectorInterface $collector A DataCollectorInterface instance + */ public function addCollector(DataCollectorInterface $collector) { $this->collectors[$collector->getName()] = $collector; } + /** + * Returns true if a Collector for the given name exists. + * + * @param string $name A collector name + * + * @return Boolean + */ public function hasCollector($name) { return isset($this->collectors[$name]); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php index f2fc8a937a59..aa336a8b04bd 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -24,10 +24,25 @@ */ class Profiler { + /** + * @var ProfilerStorageInterface + */ private $storage; - private $collectors; + + /** + * @var DataCollectorInterface[] + */ + private $collectors = array(); + + /** + * @var LoggerInterface + */ private $logger; - private $enabled; + + /** + * @var Boolean + */ + private $enabled = true; /** * Constructor. @@ -39,8 +54,6 @@ public function __construct(ProfilerStorageInterface $storage, LoggerInterface $ { $this->storage = $storage; $this->logger = $logger; - $this->collectors = array(); - $this->enabled = true; } /** @@ -51,6 +64,14 @@ public function disable() $this->enabled = false; } + /** + * Enables the profiler. + */ + public function enable() + { + $this->enabled = true; + } + /** * Loads the Profile for the given Response. * @@ -168,7 +189,7 @@ public function collect(Request $request, Response $response, \Exception $except $profile = new Profile(uniqid()); $profile->setTime(time()); $profile->setUrl($request->getUri()); - $profile->setIp($request->server->get('REMOTE_ADDR')); + $profile->setIp($request->getClientIp()); $profile->setMethod($request->getMethod()); $response->headers->set('X-Debug-Token', $profile->getToken()); @@ -196,7 +217,7 @@ public function all() /** * Sets the Collectors associated with this profiler. * - * @param array $collectors An array of collectors + * @param DataCollectorInterface[] $collectors An array of collectors */ public function set(array $collectors = array()) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md index c44d53085820..e0f3c987c477 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md @@ -84,9 +84,6 @@ Resources You can run the unit tests with the following command: - phpunit - -If you also want to run the unit tests that depend on other Symfony -Components, install dev dependencies before running PHPUnit: - - php composer.phar install --dev + $ cd path/to/Symfony/Component/HttpKernel/ + $ composer.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php index c1fc6619f934..4e273069da2f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient; @@ -86,6 +87,22 @@ public function testFilterResponseConvertsCookies() $this->assertEquals($expected, $domResponse->getHeader('Set-Cookie', false)); } + public function testFilterResponseSupportsStreamedResponses() + { + $client = new Client(new TestHttpKernel()); + + $r = new \ReflectionObject($client); + $m = $r->getMethod('filterResponse'); + $m->setAccessible(true); + + $response = new StreamedResponse(function () { + echo 'foo'; + }); + + $domResponse = $m->invoke($client, $response); + $this->assertEquals('foo', $domResponse->getContent()); + } + public function testUploadedFile() { $source = tempnam(sys_get_temp_dir(), 'source'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index f517c12b2f92..5a0166d39ec0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -53,7 +53,9 @@ public function testCollect() || (extension_loaded('apc') && ini_get('apc.enabled')) || - (extension_loaded('xcache') && ini_get('xcache.cacher')))) { + (extension_loaded('xcache') && ini_get('xcache.cacher')) + || + (extension_loaded('wincache') && ini_get('wincache.ocenabled')))) { $this->assertTrue($c->hasAccelerator()); } else { $this->assertFalse($c->hasAccelerator()); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/EventDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/EventDataCollectorTest.php deleted file mode 100644 index 67702c7e9625..000000000000 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/EventDataCollectorTest.php +++ /dev/null @@ -1,45 +0,0 @@ -<?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\Component\HttpKernel\Tests\DataCollector; - -use Symfony\Component\HttpKernel\DataCollector\EventDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpKernel\Tests\Fixtures\TestEventDispatcher; - -class EventDataCollectorTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - - public function testCollect() - { - $c = new EventDataCollector(); - $c->setEventDispatcher(new TestEventDispatcher()); - - $c->collect(new Request(), new Response()); - - $this->assertSame('events',$c->getName()); - $this->assertSame(array('foo'),$c->getCalledListeners()); - $this->assertSame(array('bar'),$c->getNotCalledListeners()); - } - -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index 538d077d2c14..10322b132dd6 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -11,10 +11,14 @@ namespace Symfony\Component\HttpKernel\Tests\DataCollector; +use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; +use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Cookie; +use Symfony\Component\EventDispatcher\EventDispatcher; class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase { @@ -43,12 +47,102 @@ public function testCollect(Request $request, Response $response) $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag',$c->getRequestQuery()); $this->assertEquals('html',$c->getFormat()); $this->assertEquals(array(),$c->getSessionAttributes()); + $this->assertEquals('en',$c->getLocale()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag',$c->getResponseHeaders()); $this->assertEquals(200,$c->getStatusCode()); $this->assertEquals('application/json',$c->getContentType()); } + /** + * Test various types of controller callables. + * + * @dataProvider provider + */ + public function testControllerInspection(Request $request, Response $response) + { + // make sure we always match the line number + $r1 = new \ReflectionMethod($this, 'testControllerInspection'); + $r2 = new \ReflectionMethod($this, 'staticControllerMethod'); + // test name, callable, expected + $controllerTests = array( + array( + '"Regular" callable', + array($this, 'testControllerInspection'), + array( + 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'method' => 'testControllerInspection', + 'file' => __FILE__, + 'line' => $r1->getStartLine() + ), + ), + + array( + 'Closure', + function() { return 'foo'; }, + 'Closure', + ), + + array( + 'Static callback as string', + 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest::staticControllerMethod', + 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest::staticControllerMethod', + ), + + array( + 'Static callable with instance', + array($this, 'staticControllerMethod'), + array( + 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'method' => 'staticControllerMethod', + 'file' => __FILE__, + 'line' => $r2->getStartLine() + ), + ), + + array( + 'Static callable with class name', + array('Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'staticControllerMethod'), + array( + 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'method' => 'staticControllerMethod', + 'file' => __FILE__, + 'line' => $r2->getStartLine() + ), + ), + + array( + 'Callable with instance depending on __call()', + array($this, 'magicMethod'), + array( + 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'method' => 'magicMethod', + 'file' => 'n/a', + 'line' => 'n/a' + ), + ), + + array( + 'Callable with class name depending on __callStatic()', + array('Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'magicMethod'), + array( + 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'method' => 'magicMethod', + 'file' => 'n/a', + 'line' => 'n/a' + ), + ), + ); + + $c = new RequestDataCollector(); + + foreach ($controllerTests as $controllerTest) { + $this->injectController($c, $controllerTest[1], $request); + $c->collect($request, $response); + $this->assertEquals($controllerTest[2], $c->getController(), sprintf('Testing: %s', $controllerTest[0])); + } + } + public function provider() { if (!class_exists('Symfony\Component\HttpFoundation\Request')) { @@ -70,4 +164,39 @@ public function provider() ); } + /** + * Inject the given controller callable into the data collector. + */ + protected function injectController($collector, $controller, $request) + { + $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); + $httpKernel = new HttpKernel(new EventDispatcher(), $resolver); + $event = new FilterControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST); + $collector->onKernelController($event); + } + + /** + * Dummy method used as controller callable + */ + public static function staticControllerMethod() + { + throw new \LogicException('Unexpected method call'); + } + + /** + * Magic method to allow non existing methods to be called and delegated. + */ + public function __call($method, $args) + { + throw new \LogicException('Unexpected method call'); + } + + /** + * Magic method to allow non existing methods to be called and delegated. + */ + public static function __callStatic($method, $args) + { + throw new \LogicException('Unexpected method call'); + } + } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ContainerAwareTraceableEventDispatcherTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ContainerAwareTraceableEventDispatcherTest.php deleted file mode 100644 index 40c54e56a5a7..000000000000 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ContainerAwareTraceableEventDispatcherTest.php +++ /dev/null @@ -1,80 +0,0 @@ -<?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\Component\HttpKernel\Tests\Debug; - -use Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher; -use Symfony\Component\HttpKernel\Debug\Stopwatch; - -class ContainerAwareTraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpKernel\HttpKernel')) { - $this->markTestSkipped('The "HttpKernel" component is not available'); - } - } - - /** - * @expectedException \RuntimeException - */ - public function testThrowsAnExceptionWhenAListenerMethodIsNotCallable() - { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $dispatcher = new ContainerAwareTraceableEventDispatcher($container, new Stopwatch()); - $dispatcher->addListener('onFooEvent', new \stdClass()); - } - - public function testClosureDoesNotTriggerErrorNotice() - { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $dispatcher = new ContainerAwareTraceableEventDispatcher($container, new StopWatch()); - $triggered = false; - - $dispatcher->addListener('onFooEvent', function() use (&$triggered) { - $triggered = true; - }); - - try { - $dispatcher->dispatch('onFooEvent'); - } catch (\PHPUnit_Framework_Error_Notice $e) { - $this->fail($e->getMessage()); - } - - $this->assertTrue($triggered, 'Closure should have been executed upon dispatch'); - } - - public function testStaticCallable() - { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $dispatcher = new ContainerAwareTraceableEventDispatcher($container, new StopWatch()); - - $dispatcher->addListener('onFooEvent', array(__NAMESPACE__.'\StaticClassFixture', 'staticListener')); - - $dispatcher->dispatch('onFooEvent'); - - $this->assertTrue(StaticClassFixture::$called); - } -} - -class StaticClassFixture -{ - public static $called = false; - - public static function staticListener($event) - { - self::$called = true; - } -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php index c13e559362b7..4ccbe7dea4e4 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php @@ -45,11 +45,11 @@ public function testStatusCode() $response = $handler->createResponse(new \RuntimeException('Foo')); $this->assertEquals('500', $response->getStatusCode()); - $this->assertContains('<title>Whoops, looks like something went wrong.</title>', $response->getContent()); + $this->assertContains('Whoops, looks like something went wrong.', $response->getContent()); $response = $handler->createResponse(new NotFoundHttpException('Foo')); $this->assertEquals('404', $response->getStatusCode()); - $this->assertContains('<title>Sorry, the page you are looking for could not be found.</title>', $response->getContent()); + $this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent()); } public function testHeaders() diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchEventTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchEventTest.php deleted file mode 100644 index a739bc8a737a..000000000000 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchEventTest.php +++ /dev/null @@ -1,152 +0,0 @@ -<?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\Component\HttpKernel\Tests\Debug; - -use Symfony\Component\HttpKernel\Debug\StopwatchEvent; - -/** - * StopwatchEventTest - * - * @author Fabien Potencier <fabien@symfony.com> - */ -class StopwatchEventTest extends \PHPUnit_Framework_TestCase -{ - public function testGetOrigin() - { - $event = new StopwatchEvent(12); - $this->assertEquals(12, $event->getOrigin()); - } - - public function testGetCategory() - { - $event = new StopwatchEvent(microtime(true) * 1000); - $this->assertEquals('default', $event->getCategory()); - - $event = new StopwatchEvent(microtime(true) * 1000, 'cat'); - $this->assertEquals('cat', $event->getCategory()); - } - - public function testGetPeriods() - { - $event = new StopwatchEvent(microtime(true) * 1000); - $this->assertEquals(array(), $event->getPeriods()); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - $event->stop(); - $this->assertCount(1, $event->getPeriods()); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - $event->stop(); - $event->start(); - $event->stop(); - $this->assertCount(2, $event->getPeriods()); - } - - public function testLap() - { - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - $event->lap(); - $event->stop(); - $this->assertCount(2, $event->getPeriods()); - } - - public function testTotalTime() - { - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - usleep(20000); - $event->stop(); - $total = $event->getTotalTime(); - $this->assertTrue($total >= 11 && $total <= 29, $total.' should be 20 (between 11 and 29)'); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - usleep(10000); - $event->stop(); - $event->start(); - usleep(10000); - $event->stop(); - $total = $event->getTotalTime(); - $this->assertTrue($total >= 11 && $total <= 29, $total.' should be 20 (between 11 and 29)'); - } - - /** - * @expectedException \LogicException - */ - public function testStopWithoutStart() - { - $event = new StopwatchEvent(microtime(true) * 1000); - $event->stop(); - } - - public function testEnsureStopped() - { - // this also test overlap between two periods - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - usleep(10000); - $event->start(); - usleep(10000); - $event->ensureStopped(); - $total = $event->getTotalTime(); - $this->assertTrue($total >= 21 && $total <= 39, $total.' should be 30 (between 21 and 39)'); - } - - public function testStartTime() - { - $event = new StopwatchEvent(microtime(true) * 1000); - $this->assertTrue($event->getStartTime() < 0.5); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - $event->stop(); - $this->assertTrue($event->getStartTime() < 1); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - usleep(10000); - $event->stop(); - $start = $event->getStartTime(); - $this->assertTrue($start >= 0 && $start <= 20); - } - - public function testEndTime() - { - $event = new StopwatchEvent(microtime(true) * 1000); - $this->assertEquals(0, $event->getEndTime()); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - $this->assertEquals(0, $event->getEndTime()); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - usleep(10000); - $event->stop(); - $event->start(); - usleep(10000); - $event->stop(); - $end = $event->getEndTime(); - $this->assertTrue($end >= 11 && $end <= 29, $end.' should be 20 (between 11 and 29)'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidOriginThrowsAnException() - { - new StopwatchEvent("abc"); - } -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchTest.php deleted file mode 100644 index 210acb59595e..000000000000 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchTest.php +++ /dev/null @@ -1,120 +0,0 @@ -<?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\Component\HttpKernel\Tests\Debug; - -use Symfony\Component\HttpKernel\Debug\Stopwatch; - -/** - * StopwatchTest - * - * @author Fabien Potencier <fabien@symfony.com> - */ -class StopwatchTest extends \PHPUnit_Framework_TestCase -{ - public function testStart() - { - $stopwatch = new Stopwatch(); - $event = $stopwatch->start('foo', 'cat'); - - $this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event); - $this->assertEquals('cat', $event->getCategory()); - } - - public function testStop() - { - $stopwatch = new Stopwatch(); - $stopwatch->start('foo', 'cat'); - usleep(20000); - $event = $stopwatch->stop('foo'); - - $this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event); - $total = $event->getTotalTime(); - $this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)'); - } - - public function testLap() - { - $stopwatch = new Stopwatch(); - $stopwatch->start('foo', 'cat'); - usleep(10000); - $event = $stopwatch->lap('foo'); - usleep(10000); - $stopwatch->stop('foo'); - - $this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event); - $total = $event->getTotalTime(); - $this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)'); - } - - /** - * @expectedException \LogicException - */ - public function testStopWithoutStart() - { - $stopwatch = new Stopwatch(); - $stopwatch->stop('foo'); - } - - public function testSection() - { - $stopwatch = new Stopwatch(); - - $stopwatch->openSection(); - $stopwatch->start('foo', 'cat'); - $stopwatch->stop('foo'); - $stopwatch->start('bar', 'cat'); - $stopwatch->stop('bar'); - $stopwatch->stopSection('1'); - - $stopwatch->openSection(); - $stopwatch->start('foobar', 'cat'); - $stopwatch->stop('foobar'); - $stopwatch->stopSection('2'); - - $stopwatch->openSection(); - $stopwatch->start('foobar', 'cat'); - $stopwatch->stop('foobar'); - $stopwatch->stopSection('0'); - - // the section is an event by itself - $this->assertCount(3, $stopwatch->getSectionEvents('1')); - $this->assertCount(2, $stopwatch->getSectionEvents('2')); - $this->assertCount(2, $stopwatch->getSectionEvents('0')); - } - - public function testReopenASection() - { - $stopwatch = new Stopwatch(); - - $stopwatch->openSection(); - $stopwatch->start('foo', 'cat'); - $stopwatch->stopSection('section'); - - $stopwatch->openSection('section'); - $stopwatch->start('bar', 'cat'); - $stopwatch->stopSection('section'); - - $events = $stopwatch->getSectionEvents('section'); - - $this->assertCount(3, $events); - $this->assertCount(2, $events['__section__']->getPeriods()); - } - - /** - * @expectedException \LogicException - */ - public function testReopenANewSectionShouldThrowAnException() - { - $stopwatch = new Stopwatch(); - $stopwatch->openSection('section'); - } -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php new file mode 100644 index 000000000000..88318cc2e988 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -0,0 +1,201 @@ +<?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\Component\HttpKernel\Tests\Debug; + +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; +use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Stopwatch\Stopwatch; + +class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase +{ + protected function setUp() + { + if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { + $this->markTestSkipped('The "EventDispatcher" component is not available'); + } + + if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + $this->markTestSkipped('The "HttpFoundation" component is not available'); + } + } + + public function testAddRemoveListener() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $tdispatcher->addListener('foo', $listener = function () { ; }); + $listeners = $dispatcher->getListeners('foo'); + $this->assertCount(1, $listeners); + $this->assertSame($listener, $listeners[0]); + + $tdispatcher->removeListener('foo', $listener); + $this->assertCount(0, $dispatcher->getListeners('foo')); + } + + public function testGetListeners() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $tdispatcher->addListener('foo', $listener = function () { ; }); + $this->assertSame($dispatcher->getListeners('foo'), $tdispatcher->getListeners('foo')); + } + + public function testHasListeners() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $this->assertFalse($dispatcher->hasListeners('foo')); + $this->assertFalse($tdispatcher->hasListeners('foo')); + + $tdispatcher->addListener('foo', $listener = function () { ; }); + $this->assertTrue($dispatcher->hasListeners('foo')); + $this->assertTrue($tdispatcher->hasListeners('foo')); + } + + public function testAddRemoveSubscriber() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $subscriber = new EventSubscriber(); + + $tdispatcher->addSubscriber($subscriber); + $listeners = $dispatcher->getListeners('foo'); + $this->assertCount(1, $listeners); + $this->assertSame(array($subscriber, 'call'), $listeners[0]); + + $tdispatcher->removeSubscriber($subscriber); + $this->assertCount(0, $dispatcher->getListeners('foo')); + } + + public function testGetCalledListeners() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + $tdispatcher->addListener('foo', $listener = function () { ; }); + + $this->assertEquals(array(), $tdispatcher->getCalledListeners()); + $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getNotCalledListeners()); + + $tdispatcher->dispatch('foo'); + + $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getCalledListeners()); + $this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); + } + + public function testLogger() + { + $logger = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface'); + + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); + $tdispatcher->addListener('foo', $listener1 = function () { ; }); + $tdispatcher->addListener('foo', $listener2 = function () { ; }); + + $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); + $logger->expects($this->at(1))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); + + $tdispatcher->dispatch('foo'); + } + + public function testLoggerWithStoppedEvent() + { + $logger = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface'); + + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); + $tdispatcher->addListener('foo', $listener1 = function (Event $event) { $event->stopPropagation(); }); + $tdispatcher->addListener('foo', $listener2 = function () { ; }); + + $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); + $logger->expects($this->at(1))->method('debug')->with("Listener \"closure\" stopped propagation of the event \"foo\"."); + $logger->expects($this->at(2))->method('debug')->with("Listener \"closure\" was not called for event \"foo\"."); + + $tdispatcher->dispatch('foo'); + } + + public function testDispatchCallListeners() + { + $called = array(); + + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + $tdispatcher->addListener('foo', $listener1 = function () use (&$called) { $called[] = 'foo1'; }); + $tdispatcher->addListener('foo', $listener2 = function () use (&$called) { $called[] = 'foo2'; }); + + $tdispatcher->dispatch('foo'); + + $this->assertEquals(array('foo1', 'foo2'), $called); + } + + public function testDispatchNested() + { + $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $loop = 1; + $dispatcher->addListener('foo', $listener1 = function () use ($dispatcher, &$loop) { + ++$loop; + if (2 == $loop) { + $dispatcher->dispatch('foo'); + } + }); + + $dispatcher->dispatch('foo'); + } + + public function testStopwatchSections() + { + $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch = new Stopwatch()); + $kernel = $this->getHttpKernel($dispatcher, function () { return new Response(); }); + $request = Request::create('/'); + $response = $kernel->handle($request); + $kernel->terminate($request, $response); + + $events = $stopwatch->getSectionEvents($response->headers->get('X-Debug-Token')); + $this->assertEquals(array( + '__section__', + 'kernel.request', + 'kernel.request.loading', + 'kernel.controller', + 'kernel.controller.loading', + 'controller', + 'kernel.response', + 'kernel.response.loading', + 'kernel.terminate', + 'kernel.terminate.loading', + ), array_keys($events)); + } + + protected function getHttpKernel($dispatcher, $controller) + { + $resolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface'); + $resolver->expects($this->once())->method('getController')->will($this->returnValue($controller)); + $resolver->expects($this->once())->method('getArguments')->will($this->returnValue(array())); + + return new HttpKernel($dispatcher, $resolver); + } +} + +class EventSubscriber implements EventSubscriberInterface +{ + static public function getSubscribedEvents() + { + return array('foo' => 'call'); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php index 65975aa96fc8..934b44b4613f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php @@ -14,6 +14,18 @@ use Symfony\Component\HttpKernel\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; +use Symfony\Component\HttpKernel\Exception\ConflictHttpException; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\HttpKernel\Exception\GoneHttpException; +use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException; +use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException; +use Symfony\Component\HttpKernel\Exception\PreconditionRequiredHttpException; +use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; +use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; +use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException; class FlattenExceptionTest extends \PHPUnit_Framework_TestCase { @@ -27,12 +39,66 @@ public function testStatusCode() $flattened = FlattenException::create(new NotFoundHttpException()); $this->assertEquals('404', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new UnauthorizedHttpException('Basic realm="My Realm"')); + $this->assertEquals('401', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new BadRequestHttpException()); + $this->assertEquals('400', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new NotAcceptableHttpException()); + $this->assertEquals('406', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new ConflictHttpException()); + $this->assertEquals('409', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new MethodNotAllowedHttpException(array('POST'))); + $this->assertEquals('405', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new AccessDeniedHttpException()); + $this->assertEquals('403', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new GoneHttpException()); + $this->assertEquals('410', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new LengthRequiredHttpException()); + $this->assertEquals('411', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new PreconditionFailedHttpException()); + $this->assertEquals('412', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new PreconditionRequiredHttpException()); + $this->assertEquals('428', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new ServiceUnavailableHttpException()); + $this->assertEquals('503', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new TooManyRequestsHttpException()); + $this->assertEquals('429', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new UnsupportedMediaTypeHttpException()); + $this->assertEquals('415', $flattened->getStatusCode()); } public function testHeadersForHttpException() { $flattened = FlattenException::create(new MethodNotAllowedHttpException(array('POST'))); $this->assertEquals(array('Allow' => 'POST'), $flattened->getHeaders()); + + $flattened = FlattenException::create(new UnauthorizedHttpException('Basic realm="My Realm"')); + $this->assertEquals(array('WWW-Authenticate' => 'Basic realm="My Realm"'), $flattened->getHeaders()); + + $flattened = FlattenException::create(new ServiceUnavailableHttpException('Fri, 31 Dec 1999 23:59:59 GMT')); + $this->assertEquals(array('Retry-After' => 'Fri, 31 Dec 1999 23:59:59 GMT'), $flattened->getHeaders()); + + $flattened = FlattenException::create(new ServiceUnavailableHttpException(120)); + $this->assertEquals(array('Retry-After' => 120), $flattened->getHeaders()); + + $flattened = FlattenException::create(new TooManyRequestsHttpException('Fri, 31 Dec 1999 23:59:59 GMT')); + $this->assertEquals(array('Retry-After' => 'Fri, 31 Dec 1999 23:59:59 GMT'), $flattened->getHeaders()); + + $flattened = FlattenException::create(new TooManyRequestsHttpException(120)); + $this->assertEquals(array('Retry-After' => 120), $flattened->getHeaders()); } /** @@ -101,7 +167,7 @@ public function testToArray(\Exception $exception, $statusCode) 'args' => array() )), ) - ),$flattened->toArray()); + ), $flattened->toArray()); } public function flattenDataProvider() @@ -125,4 +191,45 @@ private function createException($foo) { return new \Exception(); } + + public function testSetTraceIncompleteClass() + { + $flattened = FlattenException::create(new \Exception('test', 123)); + $flattened->setTrace( + array( + array( + 'file' => __FILE__, + 'line' => 123, + 'function' => 'test', + 'args' => array( + unserialize('O:14:"BogusTestClass":0:{}') + ), + ), + ), + 'foo.php', 123 + ); + + $this->assertEquals(array( + array( + 'message'=> 'test', + 'class'=>'Exception', + 'trace'=>array( + array( + 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '', + 'file' => 'foo.php', 'line' => 123, + 'args' => array(), + ), + array( + 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => 'test', + 'file' => __FILE__, 'line' => 123, + 'args' => array( + array( + 'incomplete-object', 'BogusTestClass' + ), + ), + ) + ), + ) + ), $flattened->toArray()); + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php index 48ff956b4daf..e7d60cff3d0b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php @@ -19,7 +19,12 @@ protected function getScript($request) { $script = parent::getScript($request); - $script = preg_replace('/(\->register\(\);)/', "$0\nrequire_once '".__DIR__."/../bootstrap.php';", $script); + $autoload = file_exists(__DIR__.'/../../vendor/autoload.php') + ? __DIR__.'/../../vendor/autoload.php' + : __DIR__.'/../../../../../../vendor/autoload.php' + ; + + $script = preg_replace('/(\->register\(\);)/', "$0\nrequire_once '$autoload';\n", $script); return $script; } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php index 747d350f4380..12d301f387af 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php @@ -49,6 +49,19 @@ public function testReadsAnEmptyArrayWithReadWhenNothingCachedAtKey() $this->assertEmpty($this->getStoreMetadata('/nothing')); } + public function testUnlockFileThatDoesExist() + { + $cacheKey = $this->storeSimpleEntry(); + $this->store->lock($this->request); + + $this->assertTrue($this->store->unlock($this->request)); + } + + public function testUnlockFileThatDoesNotExist() + { + $this->assertFalse($this->store->unlock($this->request)); + } + public function testRemovesEntriesForKeyWithPurge() { $request = Request::create('/foo'); @@ -194,6 +207,18 @@ public function testOverwritesNonVaryingResponseWithStore() $this->assertCount(2, $this->getStoreMetadata($key)); } + public function testLocking() + { + $req = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); + $this->assertTrue($this->store->lock($req)); + + $path = $this->store->lock($req); + $this->assertTrue($this->store->isLocked($req)); + + $this->store->unlock($req); + $this->assertFalse($this->store->isLocked($req)); + } + protected function storeSimpleEntry($path = null, $headers = array()) { if (null === $path) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php index b79e097fec9c..4b8cf07a6640 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php @@ -29,7 +29,7 @@ public function __construct() } /** - * Add a memcached server to connection pool + * Add a server to connection pool * * @param string $host * @param integer $port diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php index bff52e7c5eed..b2d148d4c3cb 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php @@ -13,6 +13,9 @@ use Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage; use Symfony\Component\HttpKernel\Profiler\Profile; +use Symfony\Component\HttpKernel\DataCollector\DataCollector; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; class DummyMongoDbProfilerStorage extends MongoDbProfilerStorage { @@ -22,6 +25,28 @@ public function getMongo() } } +class MongoDbProfilerStorageTestDataCollector extends DataCollector +{ + public function setData($data) + { + $this->data = $data; + } + + public function getData() + { + return $this->data; + } + + public function collect(Request $request, Response $response, \Exception $exception = null) + { + } + + public function getName() + { + return 'test_data_collector'; + } +} + class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest { protected static $storage; @@ -62,6 +87,28 @@ public function testCleanup() self::$storage->purge(); } + public function testUtf8() + { + $profile = new Profile('utf8_test_profile'); + + $data = 'HÐʃʃϿ, Ï¢orЃd!'; + $nonUtf8Data = mb_convert_encoding($data, 'UCS-2'); + + $collector = new MongoDbProfilerStorageTestDataCollector(); + $collector->setData($nonUtf8Data); + + $profile->setCollectors(array($collector)); + + self::$storage->write($profile); + + $readProfile = self::$storage->read('utf8_test_profile'); + $collectors = $readProfile->getCollectors(); + + $this->assertCount(1, $collectors); + $this->assertArrayHasKey('test_data_collector', $collectors); + $this->assertEquals($nonUtf8Data, $collectors['test_data_collector']->getData(), 'Non-UTF8 data is properly encoded/decoded'); + } + /** * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface */ @@ -79,3 +126,4 @@ protected function setUp() } } } + diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/bootstrap.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/bootstrap.php deleted file mode 100644 index 24b1009e9acd..000000000000 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/bootstrap.php +++ /dev/null @@ -1,22 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\HttpKernel')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\HttpKernel')).'.php')) { - require_once $file; - } - } -}); - -if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) { - require_once $loader; -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json index 12ea499dfd65..a6cf81f10eb0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json @@ -17,35 +17,36 @@ ], "require": { "php": ">=5.3.3", - "symfony/event-dispatcher": "2.1.*", - "symfony/http-foundation": "2.1.*" + "symfony/event-dispatcher": "2.2.*", + "symfony/http-foundation": "2.2.*" }, "require-dev": { - "symfony/browser-kit": "2.1.*", - "symfony/class-loader": "2.1.*", - "symfony/config": "2.1.*", - "symfony/console": "2.1.*", - "symfony/dependency-injection": "2.1.*", - "symfony/finder": "2.1.*", - "symfony/process": "2.1.*", - "symfony/routing": "2.1.*" + "symfony/browser-kit": "2.2.*", + "symfony/class-loader": "2.2.*", + "symfony/config": "2.2.*", + "symfony/console": "2.2.*", + "symfony/dependency-injection": "2.2.*", + "symfony/finder": "2.2.*", + "symfony/process": "2.2.*", + "symfony/routing": "2.2.*", + "symfony/stopwatch": "2.2.*" }, "suggest": { - "symfony/browser-kit": "self.version", - "symfony/class-loader": "self.version", - "symfony/config": "self.version", - "symfony/console": "self.version", - "symfony/dependency-injection": "self.version", - "symfony/finder": "self.version" + "symfony/browser-kit": "2.2.*", + "symfony/class-loader": "2.2.*", + "symfony/config": "2.2.*", + "symfony/console": "2.2.*", + "symfony/dependency-injection": "2.2.*", + "symfony/finder": "2.2.*" }, "autoload": { - "psr-0": { "Symfony\\Component\\HttpKernel": "" } + "psr-0": { "Symfony\\Component\\HttpKernel\\": "" } }, "target-dir": "Symfony/Component/HttpKernel", "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist index dd824acdf7ea..f8490c3f9e66 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="Tests/bootstrap.php" + bootstrap="vendor/autoload.php" > <testsuites> <testsuite name="Symfony HttpKernel Component Test Suite"> diff --git a/core/vendor/symfony/process/Symfony/Component/Process/.gitattributes b/core/vendor/symfony/process/Symfony/Component/Process/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/process/Symfony/Component/Process/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Process.php b/core/vendor/symfony/process/Symfony/Component/Process/Process.php index 4dfd16f1f4af..ba7625560857 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Process.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Process.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Process; +use Symfony\Component\Process\Exception\RuntimeException; + /** * Process is a thin wrapper around proc_* functions to ease * start independent PHP processes. @@ -44,6 +46,7 @@ class Process private $stdout; private $stderr; private $enhanceWindowsCompatibility; + private $enhanceSigchildCompatibility; private $pipes; private $process; private $status = self::STATUS_READY; @@ -51,6 +54,8 @@ class Process private $fileHandles; private $readBytes; + private static $sigchild; + /** * Exit codes translation table. * @@ -134,6 +139,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin $this->stdin = $stdin; $this->setTimeout($timeout); $this->enhanceWindowsCompatibility = true; + $this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled(); $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options); } @@ -216,9 +222,14 @@ public function start($callback = null) array('pipe', 'r'), // stdin array('pipe', 'w'), // stdout array('pipe', 'w'), // stderr - array('pipe', 'w') // last exit code is output on the fourth pipe and caught to work around --enable-sigchild ); - $this->commandline = '('.$this->commandline.') 3>/dev/null; echo $? >&3'; + + if ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) { + // last exit code is output on the fourth pipe and caught to work around --enable-sigchild + $descriptors = array_merge($descriptors, array(array('pipe', 'w'))); + + $this->commandline = '('.$this->commandline.') 3>/dev/null; code=$?; echo $code >&3; exit $code'; + } } $commandline = $this->commandline; @@ -418,10 +429,16 @@ public function getErrorOutput() * * @return integer The exit status code * + * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled + * * @api */ public function getExitCode() { + if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) { + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method'); + } + $this->updateStatus(); return $this->exitcode; @@ -435,14 +452,16 @@ public function getExitCode() * * @return string A string representation for the exit status code * + * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled + * * @see http://tldp.org/LDP/abs/html/exitcodes.html * @see http://en.wikipedia.org/wiki/Unix_signal */ public function getExitCodeText() { - $this->updateStatus(); + $exitcode = $this->getExitCode(); - return isset(self::$exitCodes[$this->exitcode]) ? self::$exitCodes[$this->exitcode] : 'Unknown error'; + return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error'; } /** @@ -450,13 +469,13 @@ public function getExitCodeText() * * @return Boolean true if the process ended successfully, false otherwise * + * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled + * * @api */ public function isSuccessful() { - $this->updateStatus(); - - return 0 == $this->exitcode; + return 0 == $this->getExitCode(); } /** @@ -466,10 +485,16 @@ public function isSuccessful() * * @return Boolean * + * @throws RuntimeException In case --enable-sigchild is activated + * * @api */ public function hasBeenSignaled() { + if ($this->isSigchildEnabled()) { + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); + } + $this->updateStatus(); return $this->processInformation['signaled']; @@ -482,10 +507,16 @@ public function hasBeenSignaled() * * @return integer * + * @throws RuntimeException In case --enable-sigchild is activated + * * @api */ public function getTermSignal() { + if ($this->isSigchildEnabled()) { + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); + } + $this->updateStatus(); return $this->processInformation['termsig']; @@ -508,7 +539,7 @@ public function hasBeenStopped() } /** - * Returns the number of the signal that caused the child process to stop its execution + * Returns the number of the signal that caused the child process to stop its execution. * * It is only meaningful if hasBeenStopped() returns true. * @@ -544,7 +575,7 @@ public function isRunning() * * @param float $timeout The timeout in seconds * - * @return integer The exitcode of the process + * @return integer The exit-code of the process * * @throws \RuntimeException if the process got signaled */ @@ -579,26 +610,51 @@ public function stop($timeout=10) return $this->exitcode; } + /** + * Adds a line to the STDOUT stream. + * + * @param string $line The line to append + */ public function addOutput($line) { $this->stdout .= $line; } + /** + * Adds a line to the STDERR stream. + * + * @param string $line The line to append + */ public function addErrorOutput($line) { $this->stderr .= $line; } + /** + * Gets the command line to be executed. + * + * @return string The command to execute + */ public function getCommandLine() { return $this->commandline; } + /** + * Sets the command line to be executed. + * + * @param string $commandline The command to execute + */ public function setCommandLine($commandline) { $this->commandline = $commandline; } + /** + * Gets the process timeout. + * + * @return integer|null The timeout in seconds or null if it's disabled + */ public function getTimeout() { return $this->timeout; @@ -609,7 +665,9 @@ public function getTimeout() * * To disable the timeout, set this value to null. * - * @param integer|null + * @param integer|null $timeout The timeout in seconds + * + * @throws \InvalidArgumentException if the timeout is negative */ public function setTimeout($timeout) { @@ -628,56 +686,132 @@ public function setTimeout($timeout) $this->timeout = $timeout; } + /** + * Gets the working directory. + * + * @return string The current working directory + */ public function getWorkingDirectory() { return $this->cwd; } + /** + * Sets the current working directory. + * + * @param string $cwd The new working directory + */ public function setWorkingDirectory($cwd) { $this->cwd = $cwd; } + /** + * Gets the environment variables. + * + * @return array The current environment variables + */ public function getEnv() { return $this->env; } + /** + * Sets the environment variables. + * + * @param array $env The new environment variables + */ public function setEnv(array $env) { $this->env = $env; } + /** + * Gets the contents of STDIN. + * + * @return string The current contents + */ public function getStdin() { return $this->stdin; } + /** + * Sets the contents of STDIN. + * + * @param string $stdin The new contents + */ public function setStdin($stdin) { $this->stdin = $stdin; } + /** + * Gets the options for proc_open. + * + * @return array The current options + */ public function getOptions() { return $this->options; } + /** + * Sets the options for proc_open. + * + * @param array $options The new options + */ public function setOptions(array $options) { $this->options = $options; } + /** + * Gets whether or not Windows compatibility is enabled + * + * This is true by default. + * + * @return Boolean + */ public function getEnhanceWindowsCompatibility() { return $this->enhanceWindowsCompatibility; } + /** + * Sets whether or not Windows compatibility is enabled + * + * @param Boolean $enhance + */ public function setEnhanceWindowsCompatibility($enhance) { $this->enhanceWindowsCompatibility = (Boolean) $enhance; } + /** + * Return whether sigchild compatibility mode is activated or not + * + * @return Boolean + */ + public function getEnhanceSigchildCompatibility() + { + return $this->enhanceSigchildCompatibility; + } + + /** + * Activate sigchild compatibility mode + * + * Sigchild compatibility mode is required to get the exit code and + * determine the success of a process when PHP has been compiled with + * the --enable-sigchild option + * + * @param Boolean $enhance + */ + public function setEnhanceSigchildCompatibility($enhance) + { + $this->enhanceSigchildCompatibility = (Boolean) $enhance; + } + /** * Builds up the callback used by wait(). * @@ -743,6 +877,23 @@ protected function updateOutput() } } + /** + * Return whether PHP has been compiled with the '--enable-sigchild' option or not + * + * @return Boolean + */ + protected function isSigchildEnabled() + { + if (null !== self::$sigchild) { + return self::$sigchild; + } + + ob_start(); + phpinfo(INFO_GENERAL); + + return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild'); + } + /** * Handles the windows file handles fallbacks * diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php deleted file mode 100644 index c632e31f7483..000000000000 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ /dev/null @@ -1,64 +0,0 @@ -<?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\Component\Process\Tests; - -use Symfony\Component\Process\PhpExecutableFinder; - -/** - * @author Robert Schönthal <seroscho@googlemail.com> - */ -class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase -{ - /** - * tests find() with the env var PHP_PATH - */ - public function testFindWithPHP_PATH() - { - if (defined('PHP_BINARY')) { - $this->markTestSkipped('The PHP binary is easily available as of PHP 5.4'); - } - - $f = new PhpExecutableFinder(); - - $current = $f->find(); - - //not executable PHP_PATH - putenv('PHP_PATH=/not/executable/php'); - $this->assertFalse($f->find(), '::find() returns false for not executable php'); - - //executable PHP_PATH - putenv('PHP_PATH='.$current); - $this->assertEquals($f->find(), $current, '::find() returns the executable php'); - } - - /** - * tests find() with default executable - */ - public function testFindWithSuffix() - { - if (defined('PHP_BINARY')) { - $this->markTestSkipped('The PHP binary is easily available as of PHP 5.4'); - } - - putenv('PHP_PATH='); - putenv('PHP_PEAR_PHP_BIN='); - $f = new PhpExecutableFinder(); - - $current = $f->find(); - - //TODO maybe php executable is custom or even windows - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->assertTrue(is_executable($current)); - $this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable php with suffixes'); - } - } -} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php deleted file mode 100644 index 9ca45a80a790..000000000000 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php +++ /dev/null @@ -1,108 +0,0 @@ -<?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\Component\Process\Tests; - -use Symfony\Component\Process\ProcessBuilder; - -class ProcessBuilderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @test - */ - public function shouldInheritEnvironmentVars() - { - $snapshot = $_ENV; - $_ENV = $expected = array('foo' => 'bar'); - - $pb = new ProcessBuilder(); - $pb->add('foo')->inheritEnvironmentVariables(); - $proc = $pb->getProcess(); - - $this->assertNull($proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV'); - - $_ENV = $snapshot; - } - - /** - * @test - */ - public function shouldInheritAndOverrideEnvironmentVars() - { - $snapshot = $_ENV; - $_ENV = array('foo' => 'bar', 'bar' => 'baz'); - $expected = array('foo' => 'foo', 'bar' => 'baz'); - - $pb = new ProcessBuilder(); - $pb->add('foo')->inheritEnvironmentVariables() - ->setEnv('foo', 'foo'); - $proc = $pb->getProcess(); - - $this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV'); - - $_ENV = $snapshot; - } - - /** - * @test - */ - public function shouldInheritEnvironmentVarsByDefault() - { - $pb = new ProcessBuilder(); - $proc = $pb->add('foo')->getProcess(); - - $this->assertNull($proc->getEnv()); - } - - /** - * @test - */ - public function shouldNotReplaceExplicitlySetVars() - { - $snapshot = $_ENV; - $_ENV = array('foo' => 'bar'); - $expected = array('foo' => 'baz'); - - $pb = new ProcessBuilder(); - $pb - ->setEnv('foo', 'baz') - ->inheritEnvironmentVariables() - ->add('foo') - ; - $proc = $pb->getProcess(); - - $this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV'); - - $_ENV = $snapshot; - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testNegativeTimeoutFromSetter() - { - $pb = new ProcessBuilder(); - $pb->setTimeout(-1); - } - - public function testNullTimeout() - { - $pb = new ProcessBuilder(); - $pb->setTimeout(10); - $pb->setTimeout(null); - - $r = new \ReflectionObject($pb); - $p = $r->getProperty('timeout'); - $p->setAccessible(true); - - $this->assertNull($p->getValue($pb)); - } -} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php deleted file mode 100644 index 356c7debaa02..000000000000 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ /dev/null @@ -1,75 +0,0 @@ -<?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\Component\Process\Tests; - -use Symfony\Component\Process\Process, - Symfony\Component\Process\Exception\ProcessFailedException; - -/** - * @author Sebastian Marek <proofek@gmail.com> - */ -class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase -{ - /** - * tests ProcessFailedException throws exception if the process was successful - */ - public function testProcessFailedExceptionThrowsException() - { - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful'), - array('php') - ); - $process->expects($this->once()) - ->method('isSuccessful') - ->will($this->returnValue(true)); - - $this->setExpectedException( - '\InvalidArgumentException', - 'Expected a failed process, but the given process was successful.' - ); - $exception = new ProcessFailedException($process); - } - - /** - * tests ProcessFailedException uses information from process output - * to generate exception message - */ - public function testProcessFailedExceptionPopulatesInformationFromProcessOutput() - { - $cmd = 'php'; - $output = "Command output"; - $errorOutput = "FATAL: Unexpected error"; - - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful', 'getOutput', 'getErrorOutput'), - array($cmd) - ); - $process->expects($this->once()) - ->method('isSuccessful') - ->will($this->returnValue(false)); - $process->expects($this->once()) - ->method('getOutput') - ->will($this->returnValue($output)); - $process->expects($this->once()) - ->method('getErrorOutput') - ->will($this->returnValue($errorOutput)); - - $exception = new ProcessFailedException($process); - - $this->assertEquals( - "The command \"$cmd\" failed.\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}", - $exception->getMessage() - ); - } -} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTest.php deleted file mode 100644 index c54f5d89f565..000000000000 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTest.php +++ /dev/null @@ -1,202 +0,0 @@ -<?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\Component\Process\Tests; - -use Symfony\Component\Process\Process; - -/** - * @author Robert Schönthal <seroscho@googlemail.com> - */ -class ProcessTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \InvalidArgumentException - */ - public function testNegativeTimeoutFromConstructor() - { - new Process('', null, null, null, -1); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testNegativeTimeoutFromSetter() - { - $p = new Process(''); - $p->setTimeout(-1); - } - - public function testNullTimeout() - { - $p = new Process(''); - $p->setTimeout(10); - $p->setTimeout(null); - - $this->assertNull($p->getTimeout()); - } - - /** - * tests results from sub processes - * - * @dataProvider responsesCodeProvider - */ - public function testProcessResponses($expected, $getter, $code) - { - $p = new Process(sprintf('php -r %s', escapeshellarg($code))); - $p->run(); - - $this->assertSame($expected, $p->$getter()); - } - - /** - * tests results from sub processes - * - * @dataProvider pipesCodeProvider - */ - public function testProcessPipes($expected, $code) - { - if (strpos(PHP_OS, "WIN") === 0) { - $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800'); - } - - $p = new Process(sprintf('php -r %s', escapeshellarg($code))); - $p->setStdin($expected); - $p->run(); - - $this->assertSame($expected, $p->getOutput()); - $this->assertSame($expected, $p->getErrorOutput()); - $this->assertSame(0, $p->getExitCode()); - } - - public function testCallbackIsExecutedForOutput() - { - $p = new Process(sprintf('php -r %s', escapeshellarg('echo \'foo\';'))); - - $called = false; - $p->run(function ($type, $buffer) use (&$called) { - $called = $buffer === 'foo'; - }); - - $this->assertTrue($called, 'The callback should be executed with the output'); - } - - public function testExitCodeText() - { - $process = new Process(''); - $r = new \ReflectionObject($process); - $p = $r->getProperty('exitcode'); - $p->setAccessible(true); - - $p->setValue($process, 2); - $this->assertEquals('Misuse of shell builtins', $process->getExitCodeText()); - } - - public function testStartIsNonBlocking() - { - $process = new Process('php -r "sleep(4);"'); - $start = microtime(true); - $process->start(); - $end = microtime(true); - $this->assertLessThan(1 , $end-$start); - } - - public function testUpdateStatus() - { - $process = new Process('php -h'); - $process->start(); - usleep(300000); // wait for output - $this->assertEquals(0, $process->getExitCode()); - $this->assertTrue(strlen($process->getOutput()) > 0); - } - - public function testIsRunning() - { - $process = new Process('php -r "sleep(1);"'); - $this->assertFalse($process->isRunning()); - $process->start(); - $this->assertTrue($process->isRunning()); - $process->wait(); - $this->assertFalse($process->isRunning()); - } - - public function testStop() - { - $process = new Process('php -r "while (true) {}"'); - $process->start(); - $this->assertTrue($process->isRunning()); - $process->stop(); - $this->assertFalse($process->isRunning()); - - // skip this check on windows since it does not support signals - if (!defined('PHP_WINDOWS_VERSION_MAJOR')) { - $this->assertTrue($process->hasBeenSignaled()); - } - } - - public function testPhpDeadlock() - { - $this->markTestSkipped('Can course php to hang'); - - // Sleep doesn't work as it will allow the process to handle signals and close - // file handles from the other end. - $process = new Process('php -r "while (true) {}"'); - $process->start(); - - // PHP will deadlock when it tries to cleanup $process - } - - public function responsesCodeProvider() - { - return array( - //expected output / getter / code to execute - //array(1,'getExitCode','exit(1);'), - //array(true,'isSuccessful','exit();'), - array('output', 'getOutput', 'echo \'output\';'), - ); - } - - public function pipesCodeProvider() - { - $variations = array( - 'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);', - 'include \'' . __DIR__ . '/ProcessTestHelper.php\';', - ); - $baseData = str_repeat('*', 1024); - - $codes = array(); - foreach (array(1, 16, 64, 1024, 4096) as $size) { - $data = str_repeat($baseData, $size) . '!'; - foreach ($variations as $code) { - $codes[] = array($data, $code); - } - } - - return $codes; - } - - /** - * provides default method names for simple getter/setter - */ - public function methodProvider() - { - $defaults = array( - array('CommandLine'), - array('Timeout'), - array('WorkingDirectory'), - array('Env'), - array('Stdin'), - array('Options') - ); - - return $defaults; - } -} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php deleted file mode 100644 index 25cfb41f9335..000000000000 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php - -define('ERR_SELECT_FAILED', 1); -define('ERR_TIMEOUT', 2); -define('ERR_READ_FAILED', 3); -define('ERR_WRITE_FAILED', 4); - -$read = array(STDIN); -$write = array(STDOUT, STDERR); - -stream_set_blocking(STDIN, false); -stream_set_blocking(STDOUT, false); -stream_set_blocking(STDERR, false); - -$out = $err = ''; -while ($read || $write) { - $r = $read; - $w = $write; - $e = null; - $n = stream_select($r, $w, $e, 5); - - if (false === $n) { - die(ERR_SELECT_FAILED); - } elseif ($n < 1) { - die(ERR_TIMEOUT); - } - - if (in_array(STDOUT, $w) && strlen($out) > 0) { - $written = fwrite(STDOUT, (binary) $out, 1024); - if (false === $written) { - die(ERR_WRITE_FAILED); - } - $out = (binary) substr($out, $written); - } - if (null === $read && strlen($out) < 1) { - $write = array_diff($write, array(STDOUT)); - } - - if (in_array(STDERR, $w) && strlen($err) > 0) { - $written = fwrite(STDERR, (binary) $err, 1024); - if (false === $written) { - die(ERR_WRITE_FAILED); - } - $err = (binary) substr($err, $written); - } - if (null === $read && strlen($err) < 1) { - $write = array_diff($write, array(STDERR)); - } - - if ($r) { - $str = fread(STDIN, 1024); - if (false !== $str) { - $out .= $str; - $err .= $str; - } - if (false === $str || feof(STDIN)) { - $read = null; - if (!feof(STDIN)) { - die(ERR_READ_FAILED); - } - } - } -} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/bootstrap.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/bootstrap.php deleted file mode 100644 index 11054b98928f..000000000000 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/bootstrap.php +++ /dev/null @@ -1,18 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Process')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Process')).'.php')) { - require_once $file; - } - } -}); diff --git a/core/vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist b/core/vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist deleted file mode 100644 index c120a97e9118..000000000000 --- a/core/vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<phpunit backupGlobals="false" - backupStaticAttributes="false" - colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" - bootstrap="Tests/bootstrap.php" -> - <testsuites> - <testsuite name="Symfony Process Component Test Suite"> - <directory>./Tests/</directory> - </testsuite> - </testsuites> - - <filter> - <whitelist> - <directory>./</directory> - <exclude> - <directory>./Tests</directory> - </exclude> - </whitelist> - </filter> -</phpunit> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/.gitattributes b/core/vendor/symfony/routing/Symfony/Component/Routing/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/.gitignore b/core/vendor/symfony/routing/Symfony/Component/Routing/.gitignore index d1502b087b4d..44de97a36a6d 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/.gitignore +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/.gitignore @@ -1,2 +1,4 @@ vendor/ composer.lock +phpunit.xml + diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php index f60af463f2c1..e593f97ff6dc 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php @@ -25,6 +25,7 @@ class Route private $requirements; private $options; private $defaults; + private $hostnamePattern; /** * Constructor. @@ -43,7 +44,7 @@ public function __construct(array $data) } foreach ($data as $key => $value) { - $method = 'set'.$key; + $method = 'set'.str_replace('_', '', $key); if (!method_exists($this, $method)) { throw new \BadMethodCallException(sprintf("Unknown property '%s' on annotation '%s'.", $key, get_class($this))); } @@ -61,6 +62,16 @@ public function getPattern() return $this->pattern; } + public function setHostnamePattern($pattern) + { + $this->hostnamePattern = $pattern; + } + + public function getHostnamePattern() + { + return $this->hostnamePattern; + } + public function setName($name) { $this->name = $name; diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md b/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md index edfdd4e49144..8c5665b2fca7 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md @@ -1,6 +1,28 @@ CHANGELOG ========= +2.2.0 +----- + + * added support for the method default argument values when defining a @Route + * Adjacent placeholders without separator work now, e.g. `/{x}{y}{z}.{_format}`. + * Characters that function as separator between placeholders are now whitelisted + to fix routes with normal text around a variable, e.g. `/prefix{var}suffix`. + * [BC BREAK] The default requirement of a variable has been changed slightly. + Previously it disallowed the previous and the next char around a variable. Now + it disallows the slash (`/`) and the next char. Using the previous char added + no value and was problematic because the route `/index.{_format}` would be + matched by `/index.ht/ml`. + * The default requirement now uses possesive quantifiers when possible which + improves matching performance by up to 20% because it prevents backtracking + when it's not needed. + * The ConfigurableRequirementsInterface can now also be used to disable the requirements + check on URL generation completely by calling `setStrictRequirements(null)`. It + improves performance in production environment as you should know that params always + pass the requirements (otherwise it would break your link anyway). + * There is no restriction on the route name anymore. So non-alphanumeric characters + are now also allowed. + 2.1.0 ----- @@ -22,5 +44,6 @@ CHANGELOG been used anyway without creating inconsistencies * [BC BREAK] RouteCollection::remove also removes a route from parent collections (not only from its children) - * added strict_requirements option to disable exceptions (and generate empty - URLs instead) when generating a route with an invalid parameter value + * added ConfigurableRequirementsInterface that allows to disable exceptions + (and generate empty URLs instead) when generating a route with an invalid + parameter value diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php b/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php index 54d4e2ce553f..1ccad3c22a39 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php @@ -22,20 +22,32 @@ class CompiledRoute private $tokens; private $staticPrefix; private $regex; + private $pathVariables; + private $hostnameVariables; + private $hostnameRegex; + private $hostnameTokens; /** * Constructor. * - * @param string $staticPrefix The static prefix of the compiled route - * @param string $regex The regular expression to use to match this route - * @param array $tokens An array of tokens to use to generate URL for this route - * @param array $variables An array of variables + * @param string $staticPrefix The static prefix of the compiled route + * @param string $regex The regular expression to use to match this route + * @param array $tokens An array of tokens to use to generate URL for this route + * @param array $pathVariables An array of path variables + * @param string|null $hostnameRegex Hostname regex + * @param array $hostnameTokens Hostname tokens + * @param array $hostnameVariables An array of hostname variables + * @param array $variables An array of variables (variables defined in the path and in the hostname patterns) */ - public function __construct($staticPrefix, $regex, array $tokens, array $variables) + public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostnameRegex = null, array $hostnameTokens = array(), array $hostnameVariables = array(), array $variables = array()) { - $this->staticPrefix = $staticPrefix; + $this->staticPrefix = (string) $staticPrefix; $this->regex = $regex; $this->tokens = $tokens; + $this->pathVariables = $pathVariables; + $this->hostnameRegex = $hostnameRegex; + $this->hostnameTokens = $hostnameTokens; + $this->hostnameVariables = $hostnameVariables; $this->variables = $variables; } @@ -59,6 +71,16 @@ public function getRegex() return $this->regex; } + /** + * Returns the hostname regex + * + * @return string|null The hostname regex or null + */ + public function getHostnameRegex() + { + return $this->hostnameRegex; + } + /** * Returns the tokens. * @@ -69,6 +91,16 @@ public function getTokens() return $this->tokens; } + /** + * Returns the hostname tokens. + * + * @return array The tokens + */ + public function getHostnameTokens() + { + return $this->hostnameTokens; + } + /** * Returns the variables. * @@ -78,4 +110,25 @@ public function getVariables() { return $this->variables; } + + /** + * Returns the path variables. + * + * @return array The variables + */ + public function getPathVariables() + { + return $this->pathVariables; + } + + /** + * Returns the hostname variables. + * + * @return array The variables + */ + public function getHostnameVariables() + { + return $this->hostnameVariables; + } + } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php index 470ce52216e8..32f109137f41 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php @@ -22,7 +22,10 @@ */ class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface { - protected $allowedMethods; + /** + * @var array + */ + protected $allowedMethods = array(); public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null) { @@ -31,6 +34,11 @@ public function __construct(array $allowedMethods, $message = null, $code = 0, \ parent::__construct($message, $code, $previous); } + /** + * Gets the allowed HTTP methods. + * + * @return array + */ public function getAllowedMethods() { return $this->allowedMethods; diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php index 9a795d6aac33..5925838c3fa4 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php @@ -12,25 +12,44 @@ namespace Symfony\Component\Routing\Generator; /** - * ConfigurableRequirementsInterface must be implemented by URL generators in order - * to be able to configure whether an exception should be generated when the - * parameters do not match the requirements. + * ConfigurableRequirementsInterface must be implemented by URL generators that + * can be configured whether an exception should be generated when the parameters + * do not match the requirements. It is also possible to disable the requirements + * check for URL generation completely. + * + * The possible configurations and use-cases: + * - setStrictRequirements(true): Throw an exception for mismatching requirements. This + * is mostly useful in development environment. + * - setStrictRequirements(false): Don't throw an exception but return null as URL for + * mismatching requirements and log the problem. Useful when you cannot control all + * params because they come from third party libs but don't want to have a 404 in + * production environment. It should log the mismatch so one can review it. + * - setStrictRequirements(null): Return the URL with the given parameters without + * checking the requirements at all. When generating an URL you should either trust + * your params or you validated them beforehand because otherwise it would break your + * link anyway. So in production environment you should know that params always pass + * the requirements. Thus this option allows to disable the check on URL generation for + * performance reasons (saving a preg_match for each requirement every time a URL is + * generated). * * @author Fabien Potencier <fabien@symfony.com> + * @author Tobias Schultze <http://tobion.de> */ interface ConfigurableRequirementsInterface { /** * Enables or disables the exception on incorrect parameters. + * Passing null will deactivate the requirements check completely. * - * @param Boolean $enabled + * @param Boolean|null $enabled */ public function setStrictRequirements($enabled); /** - * Gets the strict check of incorrect parameters. + * Returns whether to throw an exception on incorrect parameters. + * Null means the requirements check is deactivated completely. * - * @return Boolean + * @return Boolean|null */ public function isStrictRequirements(); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php index 408be9c6abbc..4739bd8365ce 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php @@ -20,6 +20,9 @@ */ abstract class GeneratorDumper implements GeneratorDumperInterface { + /** + * @var RouteCollection + */ private $routes; /** diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php index 9b5cc0597e0f..c85f0201e450 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Routing\Generator\Dumper; -use Symfony\Component\Routing\Route; - /** * PhpGeneratorDumper creates a PHP class able to generate URLs for a given set of routes. * @@ -93,6 +91,7 @@ private function generateDeclaredRoutes() $properties[] = $route->getDefaults(); $properties[] = $route->getRequirements(); $properties[] = $compiledRoute->getTokens(); + $properties[] = $compiledRoute->getHostnameTokens(); $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); } @@ -115,9 +114,9 @@ public function generate(\$name, \$parameters = array(), \$absolute = false) throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', \$name)); } - list(\$variables, \$defaults, \$requirements, \$tokens) = self::\$declaredRoutes[\$name]; + list(\$variables, \$defaults, \$requirements, \$tokens, \$hostnameTokens) = self::\$declaredRoutes[\$name]; - return \$this->doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$absolute); + return \$this->doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$absolute, \$hostnameTokens); } EOF; } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php index 18edd160dd59..2c510a5e3273 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Routing\Generator; -use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\Exception\InvalidParameterException; @@ -23,13 +22,30 @@ * UrlGenerator generates a URL based on a set of routes. * * @author Fabien Potencier <fabien@symfony.com> + * @author Tobias Schultze <http://tobion.de> * * @api */ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface { + /** + * @var RouteCollection + */ + protected $routes; + + /** + * @var RequestContext + */ protected $context; + + /** + * @var Boolean|null + */ protected $strictRequirements = true; + + /** + * @var LoggerInterface|null + */ protected $logger; /** @@ -60,14 +76,12 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt '%7C' => '|', ); - protected $routes; - /** * Constructor. * - * @param RouteCollection $routes A RouteCollection instance - * @param RequestContext $context The context - * @param LoggerInterface $logger A logger instance + * @param RouteCollection $routes A RouteCollection instance + * @param RequestContext $context The context + * @param LoggerInterface|null $logger A logger instance * * @api */ @@ -99,7 +113,7 @@ public function getContext() */ public function setStrictRequirements($enabled) { - $this->strictRequirements = (Boolean) $enabled; + $this->strictRequirements = null === $enabled ? null : (Boolean) $enabled; } /** @@ -122,23 +136,20 @@ public function generate($name, $parameters = array(), $absolute = false) // the Route has a cache of its own and is not recompiled as long as it does not get modified $compiledRoute = $route->compile(); - return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $absolute); + return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $absolute, $compiledRoute->getHostnameTokens()); } /** * @throws MissingMandatoryParametersException When route has some missing mandatory parameters * @throws InvalidParameterException When a parameter value is not correct */ - protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute) + protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute, $hostnameTokens) { $variables = array_flip($variables); - - $originParameters = $parameters; - $parameters = array_replace($this->context->getParameters(), $parameters); - $tparams = array_replace($defaults, $parameters); + $mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters); // all params must be given - if ($diff = array_diff_key($variables, $tparams)) { + if ($diff = array_diff_key($variables, $mergedParams)) { throw new MissingMandatoryParametersException(sprintf('The "%s" route has some missing mandatory parameters ("%s").', $name, implode('", "', array_keys($diff)))); } @@ -146,30 +157,26 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa $optional = true; foreach ($tokens as $token) { if ('variable' === $token[0]) { - if (false === $optional || !array_key_exists($token[3], $defaults) || (isset($parameters[$token[3]]) && (string) $parameters[$token[3]] != (string) $defaults[$token[3]])) { - if (!$isEmpty = in_array($tparams[$token[3]], array(null, '', false), true)) { - // check requirement - if ($tparams[$token[3]] && !preg_match('#^'.$token[2].'$#', $tparams[$token[3]])) { - $message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given).', $token[3], $name, $token[2], $tparams[$token[3]]); - if ($this->strictRequirements) { - throw new InvalidParameterException($message); - } - - if ($this->logger) { - $this->logger->err($message); - } + if (!$optional || !array_key_exists($token[3], $defaults) || (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]]) { + // check requirement + if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#', $mergedParams[$token[3]])) { + $message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given).', $token[3], $name, $token[2], $mergedParams[$token[3]]); + if ($this->strictRequirements) { + throw new InvalidParameterException($message); + } - return null; + if ($this->logger) { + $this->logger->err($message); } - } - if (!$isEmpty || !$optional) { - $url = $token[1].$tparams[$token[3]].$url; + return null; } + $url = $token[1].$mergedParams[$token[3]].$url; $optional = false; } - } elseif ('text' === $token[0]) { + } else { + // static text $url = $token[1].$url; $optional = false; } @@ -193,18 +200,48 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa } // add a query string if needed - $extra = array_diff_key($originParameters, $variables, $defaults); + $extra = array_diff_key($parameters, $variables); if ($extra && $query = http_build_query($extra, '', '&')) { $url .= '?'.$query; } - if ($this->context->getHost()) { + if ($host = $this->context->getHost()) { $scheme = $this->context->getScheme(); if (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme != $req) { $absolute = true; $scheme = $req; } + if ($hostnameTokens) { + $routeHost = ''; + foreach ($hostnameTokens as $token) { + if ('variable' === $token[0]) { + if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#', $mergedParams[$token[3]])) { + $message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given).', $token[3], $name, $token[2], $mergedParams[$token[3]]); + + if ($this->strictRequirements) { + throw new InvalidParameterException($message); + } + + if ($this->logger) { + $this->logger->err($message); + } + + return null; + } + + $routeHost = $token[1].$mergedParams[$token[3]].$routeHost; + } elseif ('text' === $token[0]) { + $routeHost = $token[1].$routeHost; + } + } + + if ($routeHost != $host) { + $host = $routeHost; + $absolute = true; + } + } + if ($absolute) { $port = ''; if ('http' === $scheme && 80 != $this->context->getHttpPort()) { @@ -213,7 +250,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa $port = ':'.$this->context->getHttpsPort(); } - $url = $scheme.'://'.$this->context->getHost().$port.$url; + $url = $scheme.'://'.$host.$port.$url; } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index d94f7d2c82b9..9b628d665882 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -56,9 +56,20 @@ */ abstract class AnnotationClassLoader implements LoaderInterface { + /** + * @var Reader + */ protected $reader; - protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route'; - protected $defaultRouteIndex; + + /** + * @var string + */ + protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route'; + + /** + * @var integer + */ + protected $defaultRouteIndex = 0; /** * Constructor. @@ -83,8 +94,8 @@ public function setRouteAnnotationClass($class) /** * Loads from annotations from a class. * - * @param string $class A class name - * @param string $type The resource type + * @param string $class A class name + * @param string|null $type The resource type * * @return RouteCollection A RouteCollection instance * @@ -97,10 +108,11 @@ public function load($class, $type = null) } $globals = array( - 'pattern' => '', - 'requirements' => array(), - 'options' => array(), - 'defaults' => array(), + 'pattern' => '', + 'requirements' => array(), + 'options' => array(), + 'defaults' => array(), + 'hostname_pattern' => '', ); $class = new \ReflectionClass($class); @@ -124,6 +136,10 @@ public function load($class, $type = null) if (null !== $annot->getDefaults()) { $globals['defaults'] = $annot->getDefaults(); } + + if (null !== $annot->getHostnamePattern()) { + $globals['hostname_pattern'] = $annot->getHostnamePattern(); + } } $collection = new RouteCollection(); @@ -148,11 +164,21 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl $name = $this->getDefaultRouteName($class, $method); } - $defaults = array_merge($globals['defaults'], $annot->getDefaults()); - $requirements = array_merge($globals['requirements'], $annot->getRequirements()); - $options = array_merge($globals['options'], $annot->getOptions()); + $defaults = array_replace($globals['defaults'], $annot->getDefaults()); + foreach ($method->getParameters() as $param) { + if ($param->isOptional()) { + $defaults[$param->getName()] = $param->getDefaultValue(); + } + } + $requirements = array_replace($globals['requirements'], $annot->getRequirements()); + $options = array_replace($globals['options'], $annot->getOptions()); + + $hostnamePattern = $annot->getHostnamePattern(); + if (null === $hostnamePattern) { + $hostnamePattern = $globals['hostname_pattern']; + } - $route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options); + $route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options, $hostnamePattern); $this->configureRoute($route, $class, $method, $annot); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php index f549fd0fb77e..abd68ed6c4fa 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php @@ -25,8 +25,8 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader /** * Loads from annotations from a directory. * - * @param string $path A directory path - * @param string $type The resource type + * @param string $path A directory path + * @param string|null $type The resource type * * @return RouteCollection A RouteCollection instance * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index bb965e9a45a0..edfe8803f113 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -14,7 +14,7 @@ use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\FileLocator; +use Symfony\Component\Config\FileLocatorInterface; /** * AnnotationFileLoader loads routing information from annotations set @@ -29,11 +29,11 @@ class AnnotationFileLoader extends FileLoader /** * Constructor. * - * @param FileLocator $locator A FileLocator instance + * @param FileLocatorInterface $locator A FileLocator instance * @param AnnotationClassLoader $loader An AnnotationClassLoader instance * @param string|array $paths A path or an array of paths where to look for resources */ - public function __construct(FileLocator $locator, AnnotationClassLoader $loader, $paths = array()) + public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader, $paths = array()) { if (!function_exists('token_get_all')) { throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.'); @@ -47,8 +47,8 @@ public function __construct(FileLocator $locator, AnnotationClassLoader $loader, /** * Loads from annotations from a file. * - * @param string $file A PHP file path - * @param string $type The resource type + * @param string $file A PHP file path + * @param string|null $type The resource type * * @return RouteCollection A RouteCollection instance * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php index c5ad1e70ccb5..0ec442d87df0 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php @@ -27,8 +27,8 @@ class ClosureLoader extends Loader /** * Loads a Closure. * - * @param \Closure $closure A Closure - * @param string $type The resource type + * @param \Closure $closure A Closure + * @param string|null $type The resource type * * @api */ diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php index de2104b8d0f3..b93dd255b92d 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php @@ -28,8 +28,8 @@ class PhpFileLoader extends FileLoader /** * Loads a PHP file. * - * @param mixed $file A PHP file path - * @param string $type The resource type + * @param string $file A PHP file path + * @param string|null $type The resource type * * @api */ diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php index 5e0093da3858..1b3eb0c15fde 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -28,8 +28,8 @@ class XmlFileLoader extends FileLoader /** * Loads an XML file. * - * @param string $file An XML file path - * @param string $type The resource type + * @param string $file An XML file path + * @param string|null $type The resource type * * @return RouteCollection A RouteCollection instance * @@ -61,10 +61,12 @@ public function load($file, $type = null) /** * Parses a node from a loaded XML file. * - * @param RouteCollection $collection the collection to associate with the node - * @param DOMElement $node the node to parse - * @param string $path the path of the XML file being processed - * @param string $file + * @param RouteCollection $collection the collection to associate with the node + * @param \DOMElement $node the node to parse + * @param string $path the path of the XML file being processed + * @param string $file + * + * @throws \InvalidArgumentException When a tag can't be parsed */ protected function parseNode(RouteCollection $collection, \DOMElement $node, $path, $file) { @@ -73,9 +75,10 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, $pa $this->parseRoute($collection, $node, $path); break; case 'import': - $resource = (string) $node->getAttribute('resource'); - $type = (string) $node->getAttribute('type'); - $prefix = (string) $node->getAttribute('prefix'); + $resource = $node->getAttribute('resource'); + $type = $node->getAttribute('type'); + $prefix = $node->getAttribute('prefix'); + $hostnamePattern = $node->getAttribute('hostname-pattern'); $defaults = array(); $requirements = array(); @@ -88,13 +91,13 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, $pa switch ($n->tagName) { case 'default': - $defaults[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); + $defaults[$n->getAttribute('key')] = trim($n->nodeValue); break; case 'requirement': - $requirements[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); + $requirements[$n->getAttribute('key')] = trim($n->nodeValue); break; case 'option': - $options[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); + $options[$n->getAttribute('key')] = trim($n->nodeValue); break; default: throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $n->tagName)); @@ -102,7 +105,7 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, $pa } $this->setCurrentDir(dirname($path)); - $collection->addCollection($this->import($resource, ('' !== $type ? $type : null), false, $file), $prefix, $defaults, $requirements, $options); + $collection->addCollection($this->import($resource, ('' !== $type ? $type : null), false, $file), $prefix, $defaults, $requirements, $options, $hostnamePattern); break; default: throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $node->tagName)); @@ -141,22 +144,22 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $definiti switch ($node->tagName) { case 'default': - $defaults[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); + $defaults[$node->getAttribute('key')] = trim((string) $node->nodeValue); break; case 'option': - $options[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); + $options[$node->getAttribute('key')] = trim((string) $node->nodeValue); break; case 'requirement': - $requirements[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); + $requirements[$node->getAttribute('key')] = trim((string) $node->nodeValue); break; default: throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $node->tagName)); } } - $route = new Route((string) $definition->getAttribute('pattern'), $defaults, $requirements, $options); + $route = new Route($definition->getAttribute('pattern'), $defaults, $requirements, $options, $definition->getAttribute('hostname-pattern')); - $collection->add((string) $definition->getAttribute('id'), $route); + $collection->add($definition->getAttribute('id'), $route); } /** diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php index d51e33918490..4a530fbb6a79 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -27,14 +27,14 @@ class YamlFileLoader extends FileLoader { private static $availableKeys = array( - 'type', 'resource', 'prefix', 'pattern', 'options', 'defaults', 'requirements' + 'type', 'resource', 'prefix', 'pattern', 'options', 'defaults', 'requirements', 'hostname_pattern', ); /** * Loads a Yaml file. * - * @param string $file A Yaml file path - * @param string $type The resource type + * @param string $file A Yaml file path + * @param string|null $type The resource type * * @return RouteCollection A RouteCollection instance * @@ -70,9 +70,10 @@ public function load($file, $type = null) $defaults = isset($config['defaults']) ? $config['defaults'] : array(); $requirements = isset($config['requirements']) ? $config['requirements'] : array(); $options = isset($config['options']) ? $config['options'] : array(); + $hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : ''; $this->setCurrentDir(dirname($path)); - $collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix, $defaults, $requirements, $options); + $collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix, $defaults, $requirements, $options, $hostnamePattern); } else { $this->parseRoute($collection, $name, $config, $path); } @@ -106,12 +107,13 @@ protected function parseRoute(RouteCollection $collection, $name, $config, $file $defaults = isset($config['defaults']) ? $config['defaults'] : array(); $requirements = isset($config['requirements']) ? $config['requirements'] : array(); $options = isset($config['options']) ? $config['options'] : array(); + $hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : null; if (!isset($config['pattern'])) { throw new \InvalidArgumentException(sprintf('You must define a "pattern" for the "%s" route.', $name)); } - $route = new Route($config['pattern'], $defaults, $requirements, $options); + $route = new Route($config['pattern'], $defaults, $requirements, $options, $hostnamePattern); $collection->add($name, $route); } @@ -123,7 +125,7 @@ protected function parseRoute(RouteCollection $collection, $name, $config, $file * * @return array * - * @throws InvalidArgumentException if one of the provided config keys is not supported + * @throws \InvalidArgumentException if one of the provided config keys is not supported */ private function normalizeRouteConfig(array $config) { diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd index b8571e661d07..5346237edb56 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd @@ -5,40 +5,55 @@ targetNamespace="http://symfony.com/schema/routing" elementFormDefault="qualified"> + <xsd:annotation> + <xsd:documentation><![CDATA[ + Symfony XML Routing Schema, version 1.0 + Authors: Fabien Potencier, Tobias Schultze + + This scheme defines the elements and attributes that can be used to define + routes. A route maps an HTTP request to a set of configuration variables. + ]]></xsd:documentation> + </xsd:annotation> + <xsd:element name="routes" type="routes" /> <xsd:complexType name="routes"> - <xsd:choice maxOccurs="unbounded" minOccurs="0"> + <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element name="import" type="import" /> <xsd:element name="route" type="route" /> </xsd:choice> </xsd:complexType> + <xsd:group name="configs"> + <xsd:choice> + <xsd:element name="default" type="element" /> + <xsd:element name="requirement" type="element" /> + <xsd:element name="option" type="element" /> + </xsd:choice> + </xsd:group> + <xsd:complexType name="route"> - <xsd:sequence> - <xsd:element name="default" type="element" minOccurs="0" maxOccurs="unbounded" /> - <xsd:element name="requirement" type="element" minOccurs="0" maxOccurs="unbounded" /> - <xsd:element name="option" type="element" minOccurs="0" maxOccurs="unbounded" /> - </xsd:sequence> - - <xsd:attribute name="id" type="xsd:string" /> - <xsd:attribute name="pattern" type="xsd:string" /> + <xsd:group ref="configs" minOccurs="0" maxOccurs="unbounded" /> + + <xsd:attribute name="id" type="xsd:string" use="required" /> + <xsd:attribute name="pattern" type="xsd:string" default="/" /> + <xsd:attribute name="hostname-pattern" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="import"> - <xsd:sequence> - <xsd:element name="default" type="element" minOccurs="0" maxOccurs="unbounded" /> - <xsd:element name="requirement" type="element" minOccurs="0" maxOccurs="unbounded" /> - <xsd:element name="option" type="element" minOccurs="0" maxOccurs="unbounded" /> - </xsd:sequence> + <xsd:group ref="configs" minOccurs="0" maxOccurs="unbounded" /> <xsd:attribute name="resource" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="prefix" type="xsd:string" /> - <xsd:attribute name="class" type="xsd:string" /> + <xsd:attribute name="hostname-pattern" type="xsd:string" /> </xsd:complexType> - <xsd:complexType name="element" mixed="true"> - <xsd:attribute name="key" type="xsd:string" /> + <xsd:complexType name="element"> + <xsd:simpleContent> + <xsd:extension base="xsd:string"> + <xsd:attribute name="key" type="xsd:string" /> + </xsd:extension> + </xsd:simpleContent> </xsd:complexType> </xsd:schema> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php index 3003dfdebb02..e513f04e3b44 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php @@ -17,6 +17,7 @@ * ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper). * * @author Fabien Potencier <fabien@symfony.com> + * @author Arnaud Le Blanc <arnaud.lb@gmail.com> */ class ApacheUrlMatcher extends UrlMatcher { @@ -36,36 +37,52 @@ public function match($pathinfo) $parameters = array(); $defaults = array(); $allow = array(); - $match = false; + $route = null; foreach ($_SERVER as $key => $value) { $name = $key; - if (0 === strpos($name, 'REDIRECT_')) { - $name = substr($name, 9); + // skip non-routing variables + // this improves performance when $_SERVER contains many usual + // variables like HTTP_*, DOCUMENT_ROOT, REQUEST_URI, ... + if (false === strpos($name, '_ROUTING_')) { + continue; } - if (0 === strpos($name, '_ROUTING_DEFAULTS_')) { - $name = substr($name, 18); - $defaults[$name] = $value; - } elseif (0 === strpos($name, '_ROUTING_')) { + while (0 === strpos($name, 'REDIRECT_')) { $name = substr($name, 9); - if ('_route' == $name) { - $match = true; - $parameters[$name] = $value; - } elseif (0 === strpos($name, '_allow_')) { - $allow[] = substr($name, 7); - } else { + } + + // expect _ROUTING_<type>_<name> + // or _ROUTING_<type> + + if (0 !== strpos($name, '_ROUTING_')) { + continue; + } + if (false !== $pos = strpos($name, '_', 9)) { + $type = substr($name, 9, $pos-9); + $name = substr($name, $pos+1); + } else { + $type = substr($name, 9); + } + + if ('param' === $type) { + if ('' !== $value) { $parameters[$name] = $value; } - } else { - continue; + } elseif ('default' === $type) { + $defaults[$name] = $value; + } elseif ('route' === $type) { + $route = $value; + } elseif ('allow' === $type) { + $allow[] = $name; } unset($_SERVER[$key]); } - if ($match) { + if (null !== $route) { + $parameters['_route'] = $route; return $this->mergeDefaults($parameters, $defaults); } elseif (0 < count($allow)) { throw new MethodNotAllowedException($allow); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php index 102488cd5c46..e46b506b10cb 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Routing\Matcher\Dumper; +use Symfony\Component\Routing\Route; + /** * Dumps a set of Apache mod_rewrite rules. * @@ -44,83 +46,54 @@ public function dump(array $options = array()) $rules = array("# skip \"real\" requests\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule .* - [QSA,L]"); $methodVars = array(); + $hostnameRegexUnique = 0; + $prevHostnameRegex = ''; foreach ($this->getRoutes()->all() as $name => $route) { + $compiledRoute = $route->compile(); + $hostnameRegex = $compiledRoute->getHostnameRegex(); - // prepare the apache regex - $regex = $compiledRoute->getRegex(); - $delimiter = $regex[0]; - $regexPatternEnd = strrpos($regex, $delimiter); - if (strlen($regex) < 2 || 0 === $regexPatternEnd) { - throw new \LogicException('The "%s" route regex "%s" is invalid', $name, $regex); - } - $regex = preg_replace('/\?<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1)); - $regex = '^'.self::escape(preg_quote($options['base_uri']).substr($regex, 1), ' ', '\\'); + if (null !== $hostnameRegex && $prevHostnameRegex !== $hostnameRegex) { + $prevHostnameRegex = $hostnameRegex; + $hostnameRegexUnique++; - $methods = array(); - if ($req = $route->getRequirement('_method')) { - $methods = explode('|', strtoupper($req)); - // GET and HEAD are equivalent - if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { - $methods[] = 'HEAD'; - } - } + $rule = array(); - $hasTrailingSlash = (!$methods || in_array('HEAD', $methods)) && '/$' === substr($regex, -2) && '^/$' !== $regex; + $regex = $this->regexToApacheRegex($hostnameRegex); + $regex = self::escape($regex, ' ', '\\'); - $variables = array('E=_ROUTING__route:'.$name); - foreach ($compiledRoute->getVariables() as $i => $variable) { - $variables[] = 'E=_ROUTING_'.$variable.':%'.($i + 1); - } - foreach ($route->getDefaults() as $key => $value) { - $variables[] = 'E=_ROUTING_DEFAULTS_'.$key.':'.strtr($value, array( - ':' => '\\:', - '=' => '\\=', - '\\' => '\\\\', - ' ' => '\\ ', - )); - } - $variables = implode(',', $variables); + $rule[] = sprintf('RewriteCond %%{HTTP:Host} %s', $regex); - $rule = array("# $name"); + $variables = array(); + $variables[] = sprintf('E=__ROUTING_hostname_%s:1', $hostnameRegexUnique); - // method mismatch - if ($req = $route->getRequirement('_method')) { - $methods = explode('|', strtoupper($req)); - // GET and HEAD are equivalent - if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { - $methods[] = 'HEAD'; - } - $allow = array(); - foreach ($methods as $method) { - $methodVars[] = $method; - $allow[] = 'E=_ROUTING__allow_'.$method.':1'; + foreach ($compiledRoute->getHostnameVariables() as $i => $variable) { + $variables[] = sprintf('E=__ROUTING_hostname_%s_%s:%%%d', $hostnameRegexUnique, $variable, $i+1); } - $rule[] = "RewriteCond %{REQUEST_URI} $regex"; - $rule[] = sprintf("RewriteCond %%{REQUEST_METHOD} !^(%s)$ [NC]", implode('|', $methods)); - $rule[] = sprintf('RewriteRule .* - [S=%d,%s]', $hasTrailingSlash ? 2 : 1, implode(',', $allow)); - } + $variables = implode(',', $variables); + + $rule[] = sprintf('RewriteRule .? - [%s]', $variables); - // redirect with trailing slash appended - if ($hasTrailingSlash) { - $rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$'; - $rule[] = 'RewriteRule .* $0/ [QSA,L,R=301]'; + $rules[] = implode("\n", $rule); } - // the main rule - $rule[] = "RewriteCond %{REQUEST_URI} $regex"; - $rule[] = "RewriteRule .* {$options['script_name']} [QSA,L,$variables]"; + $rules[] = $this->dumpRoute($name, $route, $options, $hostnameRegexUnique); - $rules[] = implode("\n", $rule); + if ($req = $route->getRequirement('_method')) { + $methods = explode('|', strtoupper($req)); + $methodVars = array_merge($methodVars, $methods); + } } - if (0 < count($methodVars)) { $rule = array('# 405 Method Not Allowed'); $methodVars = array_values(array_unique($methodVars)); + if (in_array('GET', $methodVars) && !in_array('HEAD', $methodVars)) { + $methodVars[] = 'HEAD'; + } foreach ($methodVars as $i => $methodVar) { - $rule[] = sprintf('RewriteCond %%{_ROUTING__allow_%s} !-z%s', $methodVar, isset($methodVars[$i + 1]) ? ' [OR]' : ''); + $rule[] = sprintf('RewriteCond %%{ENV:_ROUTING__allow_%s} =1%s', $methodVar, isset($methodVars[$i + 1]) ? ' [OR]' : ''); } $rule[] = sprintf('RewriteRule .* %s [QSA,L]', $options['script_name']); @@ -130,6 +103,121 @@ public function dump(array $options = array()) return implode("\n\n", $rules)."\n"; } + /** + * Dumps a single route + * + * @param string $name Route name + * @param Route $route The route + * @param array $options Options + * @param bool $hostnameRegexUnique Unique identifier for the hostname regex + * + * @return string The compiled route + */ + private function dumpRoute($name, $route, array $options, $hostnameRegexUnique) + { + $compiledRoute = $route->compile(); + + // prepare the apache regex + $regex = $this->regexToApacheRegex($compiledRoute->getRegex()); + $regex = '^'.self::escape(preg_quote($options['base_uri']).substr($regex, 1), ' ', '\\'); + + $methods = $this->getRouteMethods($route); + + $hasTrailingSlash = (!$methods || in_array('HEAD', $methods)) && '/$' === substr($regex, -2) && '^/$' !== $regex; + + $variables = array('E=_ROUTING_route:'.$name); + foreach ($compiledRoute->getHostnameVariables() as $variable) { + $variables[] = sprintf('E=_ROUTING_param_%s:%%{ENV:__ROUTING_hostname_%s_%s}', $variable, $hostnameRegexUnique, $variable); + } + foreach ($compiledRoute->getPathVariables() as $i => $variable) { + $variables[] = 'E=_ROUTING_param_'.$variable.':%'.($i + 1); + } + foreach ($route->getDefaults() as $key => $value) { + $variables[] = 'E=_ROUTING_default_'.$key.':'.strtr($value, array( + ':' => '\\:', + '=' => '\\=', + '\\' => '\\\\', + ' ' => '\\ ', + )); + } + $variables = implode(',', $variables); + + $rule = array("# $name"); + + // method mismatch + if (0 < count($methods)) { + $allow = array(); + foreach ($methods as $method) { + $allow[] = 'E=_ROUTING_allow_'.$method.':1'; + } + + if ($hostnameRegex = $compiledRoute->getHostnameRegex()) { + $rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_hostname_%s} =1", $hostnameRegexUnique); + } + + $rule[] = "RewriteCond %{REQUEST_URI} $regex"; + $rule[] = sprintf("RewriteCond %%{REQUEST_METHOD} !^(%s)$ [NC]", implode('|', $methods)); + $rule[] = sprintf('RewriteRule .* - [S=%d,%s]', $hasTrailingSlash ? 2 : 1, implode(',', $allow)); + } + + // redirect with trailing slash appended + if ($hasTrailingSlash) { + + if ($hostnameRegex = $compiledRoute->getHostnameRegex()) { + $rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_hostname_%s} =1", $hostnameRegexUnique); + } + + $rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$'; + $rule[] = 'RewriteRule .* $0/ [QSA,L,R=301]'; + } + + // the main rule + + if ($hostnameRegex = $compiledRoute->getHostnameRegex()) { + $rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_hostname_%s} =1", $hostnameRegexUnique); + } + + $rule[] = "RewriteCond %{REQUEST_URI} $regex"; + $rule[] = "RewriteRule .* {$options['script_name']} [QSA,L,$variables]"; + + return implode("\n", $rule); + } + + /** + * Returns methods allowed for a route + * + * @param Route $route The route + * + * @return array The methods + */ + private function getRouteMethods(Route $route) + { + $methods = array(); + if ($req = $route->getRequirement('_method')) { + $methods = explode('|', strtoupper($req)); + // GET and HEAD are equivalent + if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { + $methods[] = 'HEAD'; + } + } + + return $methods; + } + + /** + * Converts a regex to make it suitable for mod_rewrite + * + * @param string $regex The regex + * + * @return string The converted regex + */ + private function regexToApacheRegex($regex) + { + $regexPatternEnd = strrpos($regex, $regex[0]); + + return preg_replace('/\?P<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1)); + } + /** * Escapes a string. * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php new file mode 100644 index 000000000000..612ac0d25a14 --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php @@ -0,0 +1,159 @@ +<?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\Component\Routing\Matcher\Dumper; + +/** + * Collection of routes. + * + * @author Arnaud Le Blanc <arnaud.lb@gmail.com> + */ +class DumperCollection implements \IteratorAggregate +{ + /** + * @var DumperCollection|null + */ + private $parent; + + /** + * @var (DumperCollection|DumperRoute)[] + */ + private $children = array(); + + /** + * @var array + */ + private $attributes = array(); + + /** + * Returns the children routes and collections. + * + * @return (DumperCollection|DumperRoute)[] Array of DumperCollection|DumperRoute + */ + public function all() + { + return $this->children; + } + + /** + * Adds a route or collection + * + * @param DumperRoute|DumperCollection The route or collection + */ + public function add($child) + { + if ($child instanceof DumperCollection) { + $child->setParent($this); + } + $this->children[] = $child; + } + + /** + * Sets children. + * + * @param array $children The children + */ + public function setAll(array $children) + { + foreach ($children as $child) { + if ($child instanceof DumperCollection) { + $child->setParent($this); + } + } + $this->children = $children; + } + + /** + * Returns an iterator over the children. + * + * @return \Iterator The iterator + */ + public function getIterator() + { + return new \ArrayIterator($this->children); + } + + /** + * Returns the root of the collection. + * + * @return DumperCollection The root collection + */ + public function getRoot() + { + return (null !== $this->parent) ? $this->parent->getRoot() : $this; + } + + /** + * Returns the parent collection. + * + * @return DumperCollection|null The parent collection or null if the collection has no parent + */ + protected function getParent() + { + return $this->parent; + } + + /** + * Sets the parent collection. + * + * @param DumperCollection $parent The parent collection + */ + protected function setParent(DumperCollection $parent) + { + $this->parent = $parent; + } + + /** + * Returns true if the attribute is defined. + * + * @param string $name The attribute name + * + * @return Boolean true if the attribute is defined, false otherwise + */ + public function hasAttribute($name) + { + return array_key_exists($name, $this->attributes); + } + + /** + * Returns an attribute by name. + * + * @param string $name The attribute name + * @param mixed $default Default value is the attribute doesn't exist + * + * @return mixed The attribute value + */ + public function getAttribute($name, $default = null) + { + return $this->hasAttribute($name) ? $this->attributes[$name] : $default; + } + + /** + * Sets an attribute by name. + * + * @param string $name The attribute name + * @param mixed $value The attribute value + */ + public function setAttribute($name, $value) + { + $this->attributes[$name] = $value; + } + + /** + * Sets multiple attributes. + * + * @param array $attributes The attributes + */ + public function setAttributes($attributes) + { + $this->attributes = $attributes; + } +} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php new file mode 100644 index 000000000000..2480991ae3eb --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php @@ -0,0 +1,106 @@ +<?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\Component\Routing\Matcher\Dumper; + +/** + * Prefix tree of routes preserving routes order. + * + * @author Arnaud Le Blanc <arnaud.lb@gmail.com> + */ +class DumperPrefixCollection extends DumperCollection +{ + /** + * @var string + */ + private $prefix = ''; + + /** + * Returns the prefix. + * + * @return string The prefix + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * Sets the prefix. + * + * @param string $prefix The prefix + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + /** + * Adds a route in the tree. + * + * @param DumperRoute $route The route + * + * @return DumperPrefixCollection The node the route was added to + */ + public function addPrefixRoute(DumperRoute $route) + { + $prefix = $route->getRoute()->compile()->getStaticPrefix(); + + // Same prefix, add to current leave + if ($this->prefix === $prefix) { + $this->add($route); + + return $this; + } + + // Prefix starts with route's prefix + if ('' === $this->prefix || 0 === strpos($prefix, $this->prefix)) { + $collection = new DumperPrefixCollection(); + $collection->setPrefix(substr($prefix, 0, strlen($this->prefix)+1)); + $this->add($collection); + + return $collection->addPrefixRoute($route); + } + + // No match, fallback to parent (recursively) + + if (null === $parent = $this->getParent()) { + throw new \LogicException("The collection root must not have a prefix"); + } + + return $parent->addPrefixRoute($route); + } + + /** + * Merges nodes whose prefix ends with a slash + * + * Children of a node whose prefix ends with a slash are moved to the parent node + */ + public function mergeSlashNodes() + { + $children = array(); + + foreach ($this as $child) { + if ($child instanceof self) { + $child->mergeSlashNodes(); + if ('/' === substr($child->prefix, -1)) { + $children = array_merge($children, $child->all()); + } else { + $children[] = $child; + } + } else { + $children[] = $child; + } + } + + $this->setAll($children); + } +} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php new file mode 100644 index 000000000000..2928cdcc0b21 --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php @@ -0,0 +1,64 @@ +<?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\Component\Routing\Matcher\Dumper; + +use Symfony\Component\Routing\Route; + +/** + * Container for a Route. + * + * @author Arnaud Le Blanc <arnaud.lb@gmail.com> + */ +class DumperRoute +{ + /** + * @var string + */ + private $name; + + /** + * @var Route + */ + private $route; + + /** + * Constructor. + * + * @param string $name The route name + * @param Route $route The route + */ + public function __construct($name, Route $route) + { + $this->name = $name; + $this->route = $route; + } + + /** + * Returns the route name. + * + * @return string The route name + */ + public function getName() + { + return $this->name; + } + + /** + * Returns the route. + * + * @return Route The route + */ + public function getRoute() + { + return $this->route; + } +} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php index 30778cc97a83..52edc017e847 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php @@ -20,6 +20,9 @@ */ abstract class MatcherDumper implements MatcherDumperInterface { + /** + * @var RouteCollection + */ private $routes; /** diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index 15fab9eb6e71..454e26ca7bee 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -19,6 +19,7 @@ * * @author Fabien Potencier <fabien@symfony.com> * @author Tobias Schultze <http://tobion.de> + * @author Arnaud Le Blanc <arnaud.lb@gmail.com> */ class PhpMatcherDumper extends MatcherDumper { @@ -36,7 +37,7 @@ class PhpMatcherDumper extends MatcherDumper */ public function dump(array $options = array()) { - $options = array_merge(array( + $options = array_replace(array( 'class' => 'ProjectUrlMatcher', 'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', ), $options); @@ -99,56 +100,74 @@ public function match(\$pathinfo) } /** - * Counts the number of routes as direct child of the RouteCollection. + * Generates PHP code recursively to match a RouteCollection with all child routes and child collections. * - * @param RouteCollection $routes A RouteCollection instance + * @param RouteCollection $routes A RouteCollection instance + * @param Boolean $supportsRedirections Whether redirections are supported by the base class * - * @return integer Number of Routes + * @return string PHP code */ - private function countDirectChildRoutes(RouteCollection $routes) + private function compileRoutes(RouteCollection $routes, $supportsRedirections) { - $count = 0; - foreach ($routes as $route) { - if ($route instanceof Route) { - $count++; + $fetchedHostname = false; + + $routes = $this->flattenRouteCollection($routes); + $groups = $this->groupRoutesByHostnameRegex($routes); + $code = ''; + + foreach ($groups as $collection) { + if (null !== $regex = $collection->getAttribute('hostname_regex')) { + if (!$fetchedHostname) { + $code .= " \$hostname = \$this->context->getHost();\n\n"; + $fetchedHostname = true; + } + + $code .= sprintf(" if (preg_match(%s, \$hostname, \$hostnameMatches)) {\n", var_export($regex, true)); + } + + $tree = $this->buildPrefixTree($collection); + $groupCode = $this->compilePrefixRoutes($tree, $supportsRedirections); + + if (null !== $regex) { + // apply extra indention at each line (except empty ones) + $groupCode = preg_replace('/^.{2,}$/m', ' $0', $groupCode); + $code .= $groupCode; + $code .= " }\n\n"; + } else { + $code .= $groupCode; } } - return $count; + return $code; } /** - * Generates PHP code recursively to match a RouteCollection with all child routes and child collections. + * Generates PHP code recursively to match a tree of routes * - * @param RouteCollection $routes A RouteCollection instance - * @param Boolean $supportsRedirections Whether redirections are supported by the base class - * @param string|null $parentPrefix The prefix of the parent collection used to optimize the code + * @param DumperPrefixCollection $routes A DumperPrefixCollection instance + * @param Boolean $supportsRedirections Whether redirections are supported by the base class + * @parma string $prefix Prefix of the parent collection * * @return string PHP code */ - private function compileRoutes(RouteCollection $routes, $supportsRedirections, $parentPrefix = null) + private function compilePrefixRoutes(DumperPrefixCollection $collection, $supportsRedirections, $parentPrefix = '') { $code = ''; + $prefix = $collection->getPrefix(); + $optimizable = 1 < strlen($prefix) && 1 < count($collection->all()); + $optimizedPrefix = $parentPrefix; - $prefix = $routes->getPrefix(); - $countDirectChildRoutes = $this->countDirectChildRoutes($routes); - $countAllChildRoutes = count($routes->all()); - // Can the matching be optimized by wrapping it with the prefix condition - // - no need to optimize if current prefix is the same as the parent prefix - // - if $countDirectChildRoutes === 0, the sub-collections can do their own optimizations (in case there are any) - // - it's not worth wrapping a single child route - // - prefixes with variables cannot be optimized because routes within the collection might have different requirements for the same variable - $optimizable = '' !== $prefix && $prefix !== $parentPrefix && $countDirectChildRoutes > 0 && $countAllChildRoutes > 1 && false === strpos($prefix, '{'); if ($optimizable) { + $optimizedPrefix = $prefix; + $code .= sprintf(" if (0 === strpos(\$pathinfo, %s)) {\n", var_export($prefix, true)); } - foreach ($routes as $name => $route) { - if ($route instanceof Route) { - // a single route in a sub-collection is not wrapped so it should do its own optimization in ->compileRoute with $parentPrefix = null - $code .= $this->compileRoute($route, $name, $supportsRedirections, 1 === $countAllChildRoutes ? null : $prefix)."\n"; - } elseif ($countAllChildRoutes - $countDirectChildRoutes > 0) { // we can stop iterating recursively if we already know there are no more routes - $code .= $this->compileRoutes($route, $supportsRedirections, $prefix); + foreach ($collection as $route) { + if ($route instanceof DumperCollection) { + $code .= $this->compilePrefixRoutes($route, $supportsRedirections, $optimizedPrefix); + } else { + $code .= $this->compileRoute($route->getRoute(), $route->getName(), $supportsRedirections, $optimizedPrefix)."\n"; } } @@ -161,7 +180,6 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections, $ return $code; } - /** * Compiles a single Route to PHP code used to match it against the path info. * @@ -179,6 +197,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren $conditions = array(); $hasTrailingSlash = false; $matches = false; + $hostnameMatches = false; $methods = array(); if ($req = $route->getRequirement('_method')) { @@ -191,7 +210,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods)); - if (!count($compiledRoute->getVariables()) && false !== preg_match('#^(.)\^(?<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) { + if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) { if ($supportsTrailingSlash && substr($m['url'], -1) === '/') { $conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true)); $hasTrailingSlash = true; @@ -213,6 +232,10 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren $matches = true; } + if ($compiledRoute->getHostnameVariables()) { + $hostnameMatches = true; + } + $conditions = implode(' && ', $conditions); $code .= <<<EOF @@ -271,14 +294,21 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren } // optimize parameters array - if (true === $matches && $route->getDefaults()) { - $code .= sprintf(" return array_merge(\$this->mergeDefaults(\$matches, %s), array('_route' => '%s'));\n" - , str_replace("\n", '', var_export($route->getDefaults(), true)), $name); - } elseif (true === $matches) { - $code .= sprintf(" \$matches['_route'] = '%s';\n\n", $name); - $code .= " return \$matches;\n"; + if ($matches || $hostnameMatches) { + $vars = array(); + if ($hostnameMatches) { + $vars[] = '$hostnameMatches'; + } + if ($matches) { + $vars[] = '$matches'; + } + $vars[] = "array('_route' => '$name')"; + + $code .= sprintf(" return \$this->mergeDefaults(array_replace(%s), %s);\n" + , implode(', ', $vars), str_replace("\n", '', var_export($route->getDefaults(), true))); + } elseif ($route->getDefaults()) { - $code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_merge($route->getDefaults(), array('_route' => $name)), true))); + $code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true))); } else { $code .= sprintf(" return array('_route' => '%s');\n", $name); } @@ -290,4 +320,83 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren return $code; } + + /** + * Flattens a tree of routes to a single collection. + * + * @param RouteCollection $routes Collection of routes + * @param DumperCollection|null $to A DumperCollection to add routes to + * + * @return DumperCollection + */ + private function flattenRouteCollection(RouteCollection $routes, DumperCollection $to = null) + { + if (null === $to) { + $to = new DumperCollection(); + } + + foreach ($routes as $name => $route) { + if ($route instanceof RouteCollection) { + $this->flattenRouteCollection($route, $to); + } else { + $to->add(new DumperRoute($name, $route)); + } + } + + return $to; + } + + /** + * Groups consecutive routes having the same hostname regex. + * + * The results is a collection of collections of routes having the same hostname regex. + * + * @param DumperCollection $routes Flat collection of DumperRoutes + * + * @return DumperCollection A collection with routes grouped by hostname regex in sub-collections + */ + private function groupRoutesByHostnameRegex(DumperCollection $routes) + { + $groups = new DumperCollection(); + + $currentGroup = new DumperCollection(); + $currentGroup->setAttribute('hostname_regex', null); + $groups->add($currentGroup); + + foreach ($routes as $route) { + $hostnameRegex = $route->getRoute()->compile()->getHostnameRegex(); + if ($currentGroup->getAttribute('hostname_regex') !== $hostnameRegex) { + $currentGroup = new DumperCollection(); + $currentGroup->setAttribute('hostname_regex', $hostnameRegex); + $groups->add($currentGroup); + } + $currentGroup->add($route); + } + + return $groups; + } + + /** + * Organizes the routes into a prefix tree. + * + * Routes order is preserved such that traversing the tree will traverse the + * routes in the origin order + * + * @param DumperCollection $collection A collection of routes + * + * @return DumperPrefixCollection + */ + private function buildPrefixTree(DumperCollection $collection) + { + $tree = new DumperPrefixCollection(); + $current = $tree; + + foreach ($collection as $route) { + $current = $current->addPrefixRoute($route); + } + + $tree->mergeSlashNodes(); + + return $tree; + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php index 929ae9cc78fd..ea91e07511b2 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php @@ -23,9 +23,9 @@ interface RedirectableUrlMatcherInterface /** * Redirects the user to another URL. * - * @param string $path The path info to redirect to. - * @param string $route The route that matched - * @param string $scheme The URL scheme (null to keep the current one) + * @param string $path The path info to redirect to. + * @param string $route The route name that matched + * @param string|null $scheme The URL scheme (null to keep the current one) * * @return array An array of parameters * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php index c417d946d77e..98d7a1fa0816 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -30,10 +30,20 @@ class UrlMatcher implements UrlMatcherInterface const REQUIREMENT_MISMATCH = 1; const ROUTE_MATCH = 2; + /** + * @var RequestContext + */ protected $context; - protected $allow; - private $routes; + /** + * @var array + */ + protected $allow = array(); + + /** + * @var RouteCollection + */ + protected $routes; /** * Constructor. @@ -118,6 +128,11 @@ protected function matchCollection($pathinfo, RouteCollection $routes) continue; } + $hostnameMatches = array(); + if ($compiledRoute->getHostnameRegex() && !preg_match($compiledRoute->getHostnameRegex(), $this->context->getHost(), $hostnameMatches)) { + continue; + } + // check HTTP method requirement if ($req = $route->getRequirement('_method')) { // HEAD and GET are equivalent as per RFC @@ -142,10 +157,30 @@ protected function matchCollection($pathinfo, RouteCollection $routes) continue; } - return array_merge($this->mergeDefaults($matches, $route->getDefaults()), array('_route' => $name)); + return $this->getAttributes($route, $name, array_replace($matches, $hostnameMatches)); } } + /** + * Returns an array of values to use as request attributes. + * + * As this method requires the Route object, it is not available + * in matchers that do not have access to the matched Route instance + * (like the PHP and Apache matcher dumpers). + * + * @param Route $route The route we are matching against + * @param string $name The name of the route + * @param array $attributes An array of attributes from the matcher + * + * @return array An array of parameters + */ + protected function getAttributes(Route $route, $name, array $attributes) + { + $attributes['_route'] = $name; + + return $this->mergeDefaults($attributes, $route->getDefaults()); + } + /** * Handles specific route requirements. * @@ -174,13 +209,12 @@ protected function handleRouteRequirements($pathinfo, $name, Route $route) */ protected function mergeDefaults($params, $defaults) { - $parameters = $defaults; foreach ($params as $key => $value) { if (!is_int($key)) { - $parameters[$key] = $value; + $defaults[$key] = $value; } } - return $parameters; + return $defaults; } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/README.md b/core/vendor/symfony/routing/Symfony/Component/Routing/README.md index 61504c84d946..663844a67429 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/README.md +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/README.md @@ -29,9 +29,6 @@ Resources You can run the unit tests with the following command: - phpunit - -If you also want to run the unit tests that depend on other Symfony -Components, install dev dependencies before running PHPUnit: - - php composer.phar install --dev + $ cd path/to/Symfony/Component/Routing/ + $ composer.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php index 7406b20439c4..1f9cf3c02c92 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php @@ -28,7 +28,11 @@ class RequestContext private $scheme; private $httpPort; private $httpsPort; - private $parameters; + + /** + * @var array + */ + private $parameters = array(); /** * Constructor. @@ -50,7 +54,6 @@ public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $this->scheme = strtolower($scheme); $this->httpPort = $httpPort; $this->httpsPort = $httpsPort; - $this->parameters = array(); } public function fromRequest(Request $request) diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php index 318426a0db09..38fc3f494a95 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php @@ -20,10 +20,34 @@ */ class Route implements \Serializable { - private $pattern; - private $defaults; - private $requirements; - private $options; + /** + * @var string + */ + private $pattern = '/'; + + /** + * @var string + */ + private $hostnamePattern = ''; + + /** + * @var array + */ + private $defaults = array(); + + /** + * @var array + */ + private $requirements = array(); + + /** + * @var array + */ + private $options = array(); + + /** + * @var null|RouteCompiler + */ private $compiled; private static $compilers = array(); @@ -35,19 +59,21 @@ class Route implements \Serializable * * * compiler_class: A class name able to compile this route instance (RouteCompiler by default) * - * @param string $pattern The pattern to match - * @param array $defaults An array of default parameter values - * @param array $requirements An array of requirements for parameters (regexes) - * @param array $options An array of options + * @param string $pattern The path pattern to match + * @param array $defaults An array of default parameter values + * @param array $requirements An array of requirements for parameters (regexes) + * @param array $options An array of options + * @param string $hostnamePattern The hostname pattern to match * * @api */ - public function __construct($pattern, array $defaults = array(), array $requirements = array(), array $options = array()) + public function __construct($pattern, array $defaults = array(), array $requirements = array(), array $options = array(), $hostnamePattern = '') { $this->setPattern($pattern); $this->setDefaults($defaults); $this->setRequirements($requirements); $this->setOptions($options); + $this->setHostnamePattern($hostnamePattern); } public function __clone() @@ -59,6 +85,7 @@ public function serialize() { return serialize(array( 'pattern' => $this->pattern, + 'hostnamePattern' => $this->hostnamePattern, 'defaults' => $this->defaults, 'requirements' => $this->requirements, 'options' => $this->options, @@ -69,13 +96,14 @@ public function unserialize($data) { $data = unserialize($data); $this->pattern = $data['pattern']; + $this->hostnamePattern = $data['hostnamePattern']; $this->defaults = $data['defaults']; $this->requirements = $data['requirements']; $this->options = $data['options']; } /** - * Returns the pattern. + * Returns the pattern for the path. * * @return string The pattern */ @@ -85,7 +113,7 @@ public function getPattern() } /** - * Sets the pattern. + * Sets the pattern for the path. * * This method implements a fluent interface. * @@ -95,13 +123,32 @@ public function getPattern() */ public function setPattern($pattern) { - $this->pattern = trim($pattern); + // A pattern must start with a slash and must not have multiple slashes at the beginning because the + // generated path for this route would be confused with a network path, e.g. '//domain.com/path'. + $this->pattern = '/' . ltrim(trim($pattern), '/'); + $this->compiled = null; - // a route must start with a slash - if ('' === $this->pattern || '/' !== $this->pattern[0]) { - $this->pattern = '/'.$this->pattern; - } + return $this; + } + + /** + * Returns the hostname pattern. + * + * @return string The pattern + */ + public function getHostnamePattern() + { + return $this->hostnamePattern; + } + /** + * Sets the hostname pattern. + * + * @param string $pattern The pattern + */ + public function setHostnamePattern($pattern) + { + $this->hostnamePattern = (string) $pattern; $this->compiled = null; return $this; @@ -147,7 +194,7 @@ public function setOptions(array $options) public function addOptions(array $options) { foreach ($options as $name => $option) { - $this->options[(string) $name] = $option; + $this->options[$name] = $option; } $this->compiled = null; @@ -179,13 +226,25 @@ public function setOption($name, $value) * * @param string $name An option name * - * @return mixed The option value + * @return mixed The option value or null when not given */ public function getOption($name) { return isset($this->options[$name]) ? $this->options[$name] : null; } + /** + * Checks if a an option has been set + * + * @param string $name An option name + * + * @return Boolean true if the option is set, false otherwise + */ + public function hasOption($name) + { + return array_key_exists($name, $this->options); + } + /** * Returns the defaults. * @@ -224,7 +283,7 @@ public function setDefaults(array $defaults) public function addDefaults(array $defaults) { foreach ($defaults as $name => $default) { - $this->defaults[(string) $name] = $default; + $this->defaults[$name] = $default; } $this->compiled = null; @@ -236,7 +295,7 @@ public function addDefaults(array $defaults) * * @param string $name A variable name * - * @return mixed The default value + * @return mixed The default value or null when not given */ public function getDefault($name) { @@ -267,7 +326,7 @@ public function hasDefault($name) */ public function setDefault($name, $default) { - $this->defaults[(string) $name] = $default; + $this->defaults[$name] = $default; $this->compiled = null; return $this; @@ -323,13 +382,25 @@ public function addRequirements(array $requirements) * * @param string $key The key * - * @return string The regex + * @return string|null The regex or null when not given */ public function getRequirement($key) { return isset($this->requirements[$key]) ? $this->requirements[$key] : null; } + /** + * Checks if a requirement is set for the given key. + * + * @param string $name A variable name + * + * @return Boolean true if a requirement is specified, false otherwise + */ + public function hasRequirement($key) + { + return array_key_exists($key, $this->requirements); + } + /** * Sets a requirement for the given key. * @@ -352,6 +423,8 @@ public function setRequirement($key, $regex) * Compiles the route. * * @return CompiledRoute A CompiledRoute instance + * + * @see RouteCompiler which is responsible for the compilation process */ public function compile() { @@ -371,21 +444,21 @@ public function compile() private function sanitizeRequirement($key, $regex) { if (!is_string($regex)) { - throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string', $key)); + throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key)); } - if ('' === $regex) { - throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" cannot be empty', $key)); - } - - if ('^' === $regex[0]) { - $regex = substr($regex, 1); + if ('' !== $regex && '^' === $regex[0]) { + $regex = (string) substr($regex, 1); // returns false for a single character } if ('$' === substr($regex, -1)) { $regex = substr($regex, 0, -1); } + if ('' === $regex) { + throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" cannot be empty.', $key)); + } + return $regex; } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php index 7a0e4c906ace..9e5f4a1d6f98 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php @@ -26,22 +26,25 @@ */ class RouteCollection implements \IteratorAggregate, \Countable { - private $routes; - private $resources; - private $prefix; - private $parent; + /** + * @var (RouteCollection|Route)[] + */ + private $routes = array(); /** - * Constructor. - * - * @api + * @var array */ - public function __construct() - { - $this->routes = array(); - $this->resources = array(); - $this->prefix = ''; - } + private $resources = array(); + + /** + * @var string + */ + private $prefix = ''; + + /** + * @var RouteCollection|null + */ + private $parent; public function __clone() { @@ -109,16 +112,10 @@ public function count() * @param string $name The route name * @param Route $route A Route instance * - * @throws \InvalidArgumentException When route name contains non valid characters - * * @api */ public function add($name, Route $route) { - if (!preg_match('/^[a-z0-9A-Z_.]+$/', $name)) { - throw new \InvalidArgumentException(sprintf('The provided route name "%s" contains non valid characters. A route name must only contain digits (0-9), letters (a-z and A-Z), underscores (_) and dots (.).', $name)); - } - $this->remove($name); $this->routes[$name] = $route; @@ -127,7 +124,7 @@ public function add($name, Route $route) /** * Returns all routes in this collection and its children. * - * @return array An array of routes + * @return Route[] An array of routes */ public function all() { @@ -183,17 +180,18 @@ public function remove($name) /** * Adds a route collection to the current set of routes (at the end of the current set). * - * @param RouteCollection $collection A RouteCollection instance - * @param string $prefix An optional prefix to add before each pattern of the route collection - * @param array $defaults An array of default values - * @param array $requirements An array of requirements - * @param array $options An array of options + * @param RouteCollection $collection A RouteCollection instance + * @param string $prefix An optional prefix to add before each pattern of the route collection + * @param array $defaults An array of default values + * @param array $requirements An array of requirements + * @param array $options An array of options + * @param string $hostnamePattern Hostname pattern * * @throws \InvalidArgumentException When the RouteCollection already exists in the tree * * @api */ - public function addCollection(RouteCollection $collection, $prefix = '', $defaults = array(), $requirements = array(), $options = array()) + public function addCollection(RouteCollection $collection, $prefix = '', $defaults = array(), $requirements = array(), $options = array(), $hostnamePattern = '') { // prevent infinite loops by recursive referencing $root = $this->getRoot(); @@ -208,6 +206,11 @@ public function addCollection(RouteCollection $collection, $prefix = '', $defaul // the sub-collection must have the prefix of the parent (current instance) prepended because it does not // necessarily already have it applied (depending on the order RouteCollections are added to each other) $collection->addPrefix($this->getPrefix() . $prefix, $defaults, $requirements, $options); + + if ('' !== $hostnamePattern) { + $collection->setHostnamePattern($hostnamePattern); + } + $this->routes[] = $collection; } @@ -223,25 +226,25 @@ public function addCollection(RouteCollection $collection, $prefix = '', $defaul */ public function addPrefix($prefix, $defaults = array(), $requirements = array(), $options = array()) { - // a prefix must not end with a slash - $prefix = rtrim($prefix, '/'); + $prefix = trim(trim($prefix), '/'); if ('' === $prefix && empty($defaults) && empty($requirements) && empty($options)) { return; } - // a prefix must start with a slash - if ('' !== $prefix && '/' !== $prefix[0]) { - $prefix = '/'.$prefix; + // a prefix must start with a single slash and must not end with a slash + if ('' !== $prefix) { + $this->prefix = '/' . $prefix . $this->prefix; } - $this->prefix = $prefix.$this->prefix; - foreach ($this->routes as $route) { if ($route instanceof RouteCollection) { - $route->addPrefix($prefix, $defaults, $requirements, $options); + // we add the slashes so the prefix is not lost by trimming in the sub-collection + $route->addPrefix('/' . $prefix . '/', $defaults, $requirements, $options); } else { - $route->setPattern($prefix.$route->getPattern()); + if ('' !== $prefix) { + $route->setPattern('/' . $prefix . $route->getPattern()); + } $route->addDefaults($defaults); $route->addRequirements($requirements); $route->addOptions($options); @@ -259,6 +262,18 @@ public function getPrefix() return $this->prefix; } + /** + * Sets the hostname pattern on all child routes. + * + * @param string $pattern The pattern + */ + public function setHostnamePattern($pattern) + { + foreach ($this->routes as $route) { + $route->setHostnamePattern($pattern); + } + } + /** * Returns an array of resources loaded to build this collection. * @@ -267,7 +282,7 @@ public function getPrefix() public function getResources() { $resources = $this->resources; - foreach ($this as $routes) { + foreach ($this->routes as $routes) { if ($routes instanceof RouteCollection) { $resources = array_merge($resources, $routes->getResources()); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php index 5aaae19c3483..4b1927166611 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php @@ -15,66 +15,147 @@ * RouteCompiler compiles Route instances to CompiledRoute instances. * * @author Fabien Potencier <fabien@symfony.com> + * @author Tobias Schultze <http://tobion.de> */ class RouteCompiler implements RouteCompilerInterface { const REGEX_DELIMITER = '#'; + /** + * This string defines the characters that are automatically considered separators in front of + * optional placeholders (with default and no static text following). Such a single separator + * can be left out together with the optional placeholder from matching and generating URLs. + */ + const SEPARATORS = '/,;.:-_~+*=@|'; + /** * {@inheritDoc} * - * @throws \LogicException If a variable is referenced more than once + * @throws \LogicException If a variable is referenced more than once + * @throws \DomainException If a variable name is numeric because PHP raises an error for such + * subpatterns in PCRE and thus would break matching, e.g. "(?P<123>.+)". */ public function compile(Route $route) { + $staticPrefix = null; + $hostnameVariables = array(); + $pathVariables = array(); + $variables = array(); + $tokens = array(); + $regex = null; + $hostnameRegex = null; + $hostnameTokens = array(); + + if ('' !== $hostnamePattern = $route->getHostnamePattern()) { + $result = $this->compilePattern($route, $hostnamePattern, true); + + $hostnameVariables = $result['variables']; + $variables = array_merge($variables, $hostnameVariables); + + $hostnameTokens = $result['tokens']; + $hostnameRegex = $result['regex']; + } + $pattern = $route->getPattern(); - $len = strlen($pattern); + + $result = $this->compilePattern($route, $pattern, false); + + $staticPrefix = $result['staticPrefix']; + + $pathVariables = $result['variables']; + $variables = array_merge($variables, $pathVariables); + + $tokens = $result['tokens']; + $regex = $result['regex']; + + return new CompiledRoute( + $staticPrefix, + $regex, + $tokens, + $pathVariables, + $hostnameRegex, + $hostnameTokens, + $hostnameVariables, + array_unique($variables) + ); + } + + private function compilePattern(Route $route, $pattern, $isHostname) + { $tokens = array(); $variables = array(); + $matches = array(); $pos = 0; - preg_match_all('#.\{(\w+)\}#', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); - foreach ($matches as $match) { - if ($text = substr($pattern, $pos, $match[0][1] - $pos)) { - $tokens[] = array('text', $text); - } + $defaultSeparator = $isHostname ? '.' : '/'; + // Match all variables enclosed in "{}" and iterate over them. But we only want to match the innermost variable + // in case of nested "{}", e.g. {foo{bar}}. This in ensured because \w does not match "{" or "}" itself. + preg_match_all('#\{\w+\}#', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); + foreach ($matches as $match) { + $varName = substr($match[0][0], 1, -1); + // get all static text preceding the current variable + $precedingText = substr($pattern, $pos, $match[0][1] - $pos); $pos = $match[0][1] + strlen($match[0][0]); - $var = $match[1][0]; + $precedingChar = strlen($precedingText) > 0 ? substr($precedingText, -1) : ''; + $isSeparator = '' !== $precedingChar && false !== strpos(static::SEPARATORS, $precedingChar); - if ($req = $route->getRequirement($var)) { - $regexp = $req; - } else { - // Use the character preceding the variable as a separator - $separators = array($match[0][0][0]); - - if ($pos !== $len) { - // Use the character following the variable as the separator when available - $separators[] = $pattern[$pos]; - } - $regexp = sprintf('[^%s]+', preg_quote(implode('', array_unique($separators)), self::REGEX_DELIMITER)); + if (is_numeric($varName)) { + throw new \DomainException(sprintf('Variable name "%s" cannot be numeric in route pattern "%s". Please use a different name.', $varName, $pattern)); + } + if (in_array($varName, $variables)) { + throw new \LogicException(sprintf('Route pattern "%s" cannot reference variable name "%s" more than once.', $pattern, $varName)); } - $tokens[] = array('variable', $match[0][0][0], $regexp, $var); + if ($isSeparator && strlen($precedingText) > 1) { + $tokens[] = array('text', substr($precedingText, 0, -1)); + } elseif (!$isSeparator && strlen($precedingText) > 0) { + $tokens[] = array('text', $precedingText); + } - if (in_array($var, $variables)) { - throw new \LogicException(sprintf('Route pattern "%s" cannot reference variable name "%s" more than once.', $route->getPattern(), $var)); + $regexp = $route->getRequirement($varName); + if (null === $regexp) { + $followingPattern = (string) substr($pattern, $pos); + // Find the next static character after the variable that functions as a separator. By default, this separator and '/' + // are disallowed for the variable. This default requirement makes sure that optional variables can be matched at all + // and that the generating-matching-combination of URLs unambiguous, i.e. the params used for generating the URL are + // the same that will be matched. Example: new Route('/{page}.{_format}', array('_format' => 'html')) + // If {page} would also match the separating dot, {_format} would never match as {page} will eagerly consume everything. + // Also even if {_format} was not optional the requirement prevents that {page} matches something that was originally + // part of {_format} when generating the URL, e.g. _format = 'mobile.html'. + $nextSeparator = $this->findNextSeparator($followingPattern); + $regexp = sprintf( + '[^%s%s]+', + preg_quote($defaultSeparator, self::REGEX_DELIMITER), + $defaultSeparator !== $nextSeparator && '' !== $nextSeparator ? preg_quote($nextSeparator, self::REGEX_DELIMITER) : '' + ); + if (('' !== $nextSeparator && !preg_match('#^\{\w+\}#', $followingPattern)) || '' === $followingPattern) { + // When we have a separator, which is disallowed for the variable, we can optimize the regex with a possessive + // quantifier. This prevents useless backtracking of PCRE and improves performance by 20% for matching those patterns. + // Given the above example, there is no point in backtracking into {page} (that forbids the dot) when a dot must follow + // after it. This optimization cannot be applied when the next char is no real separator or when the next variable is + // directly adjacent, e.g. '/{x}{y}'. + $regexp .= '+'; + } } - $variables[] = $var; + $tokens[] = array('variable', $isSeparator ? $precedingChar : '', $regexp, $varName); + $variables[] = $varName; } - if ($pos < $len) { + if ($pos < strlen($pattern)) { $tokens[] = array('text', substr($pattern, $pos)); } // find the first optional token $firstOptional = INF; - for ($i = count($tokens) - 1; $i >= 0; $i--) { - $token = $tokens[$i]; - if ('variable' === $token[0] && $route->hasDefault($token[3])) { - $firstOptional = $i; - } else { - break; + if (!$isHostname) { + for ($i = count($tokens) - 1; $i >= 0; $i--) { + $token = $tokens[$i]; + if ('variable' === $token[0] && $route->hasDefault($token[3])) { + $firstOptional = $i; + } else { + break; + } } } @@ -84,14 +165,33 @@ public function compile(Route $route) $regexp .= $this->computeRegexp($tokens, $i, $firstOptional); } - return new CompiledRoute( - 'text' === $tokens[0][0] ? $tokens[0][1] : '', - self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s', - array_reverse($tokens), - $variables + return array( + 'staticPrefix' => 'text' === $tokens[0][0] ? $tokens[0][1] : '', + 'regex' => self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s', + 'tokens' => array_reverse($tokens), + 'variables' => $variables, ); } + /** + * Returns the next static character in the Route pattern that will serve as a separator. + * + * @param string $pattern The route pattern + * + * @return string The next static character that functions as separator (or empty string when none available) + */ + private function findNextSeparator($pattern) + { + if ('' == $pattern) { + // return empty string if pattern is empty or false (false which can be returned by substr) + return ''; + } + // first remove all placeholders from the pattern so we can find the next real static character + $pattern = preg_replace('#\{\w+\}#', '', $pattern); + + return isset($pattern[0]) && false !== strpos(static::SEPARATORS, $pattern[0]) ? $pattern[0] : ''; + } + /** * Computes the regexp used to match a specific token. It can be static text or a subpattern. * @@ -111,9 +211,9 @@ private function computeRegexp(array $tokens, $index, $firstOptional) // Variable tokens if (0 === $index && 0 === $firstOptional) { // When the only token is an optional variable token, the separator is required - return sprintf('%s(?<%s>%s)?', preg_quote($token[1], self::REGEX_DELIMITER), $token[3], $token[2]); + return sprintf('%s(?P<%s>%s)?', preg_quote($token[1], self::REGEX_DELIMITER), $token[3], $token[2]); } else { - $regexp = sprintf('%s(?<%s>%s)', preg_quote($token[1], self::REGEX_DELIMITER), $token[3], $token[2]); + $regexp = sprintf('%s(?P<%s>%s)', preg_quote($token[1], self::REGEX_DELIMITER), $token[3], $token[2]); if ($index >= $firstOptional) { // Enclose each optional token in a subpattern to make it optional. // "?:" means it is non-capturing, i.e. the portion of the subject string that diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php index f617a60b559e..68d73ab24db4 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php @@ -15,6 +15,8 @@ use Symfony\Component\Config\ConfigCache; use Symfony\Component\HttpKernel\Log\LoggerInterface; use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\Matcher\UrlMatcherInterface; /** * The Router class is an example of the integration of all pieces of the @@ -24,13 +26,44 @@ */ class Router implements RouterInterface { + /** + * @var UrlMatcherInterface|null + */ protected $matcher; + + /** + * @var UrlGeneratorInterface|null + */ protected $generator; + + /** + * @var RequestContext + */ protected $context; + + /** + * @var LoaderInterface + */ protected $loader; + + /** + * @var RouteCollection|null + */ protected $collection; + + /** + * @var mixed + */ protected $resource; - protected $options; + + /** + * @var array + */ + protected $options = array(); + + /** + * @var LoggerInterface|null + */ protected $logger; /** @@ -83,17 +116,15 @@ public function setOptions(array $options) // check option names and live merge, if errors are encountered Exception will be thrown $invalid = array(); - $isInvalid = false; foreach ($options as $key => $value) { if (array_key_exists($key, $this->options)) { $this->options[$key] = $value; } else { - $isInvalid = true; $invalid[] = $key; } } - if ($isInvalid) { + if ($invalid) { throw new \InvalidArgumentException(sprintf('The Router does not support the following options: "%s".', implode('\', \'', $invalid))); } } @@ -152,8 +183,12 @@ public function setContext(RequestContext $context) { $this->context = $context; - $this->getMatcher()->setContext($context); - $this->getGenerator()->setContext($context); + if (null !== $this->matcher) { + $this->getMatcher()->setContext($context); + } + if (null !== $this->generator) { + $this->getGenerator()->setContext($context); + } } /** diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php index ff3c20c26d99..e1da00270056 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php @@ -39,7 +39,8 @@ public function getValidParameters() array('requirements', array('_method' => 'GET'), 'getRequirements'), array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'), array('name', 'blog_index', 'getName'), - array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults') + array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'), + array('hostname_pattern', array('{locale}.example.com'), 'getHostnamePattern') ); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/CompiledRouteTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/CompiledRouteTest.php index c65da0c6f2ee..215ebb707bad 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/CompiledRouteTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/CompiledRouteTest.php @@ -17,10 +17,10 @@ class CompiledRouteTest extends \PHPUnit_Framework_TestCase { public function testAccessors() { - $compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array('variables')); - $this->assertEquals('prefix', $compiled->getStaticPrefix(), '__construct() takes a static prefix as its first argument'); - $this->assertEquals('regex', $compiled->getRegex(), '__construct() takes a regexp as its second argument'); - $this->assertEquals(array('tokens'), $compiled->getTokens(), '__construct() takes an array of tokens as its third argument'); - $this->assertEquals(array('variables'), $compiled->getVariables(), '__construct() takes an array of variables as its forth argument'); + $compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array(), array(), array(), array(), array('variables')); + $this->assertEquals('prefix', $compiled->getStaticPrefix(), '__construct() takes a static prefix as its second argument'); + $this->assertEquals('regex', $compiled->getRegex(), '__construct() takes a regexp as its third argument'); + $this->assertEquals(array('tokens'), $compiled->getTokens(), '__construct() takes an array of tokens as its fourth argument'); + $this->assertEquals(array('variables'), $compiled->getVariables(), '__construct() takes an array of variables as its ninth argument'); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php new file mode 100644 index 000000000000..a3882773c4d2 --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php @@ -0,0 +1,19 @@ +<?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\Component\Routing\Tests\Fixtures\AnnotatedClasses; + +class BarClass +{ + public function routeAction($arg1, $arg2 = 'defaultValue2', $arg3 = 'defaultValue3') + { + } +} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache index ea17bca529e9..4b9c11d4d061 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache @@ -4,72 +4,160 @@ RewriteRule .* - [QSA,L] # foo RewriteCond %{REQUEST_URI} ^/foo/(baz|symfony)$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:foo,E=_ROUTING_bar:%1,E=_ROUTING_DEFAULTS_def:test] +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:foo,E=_ROUTING_param_bar:%1,E=_ROUTING_default_def:test] # foobar -RewriteCond %{REQUEST_URI} ^/foo(?:/([^/]+))?$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:foobar,E=_ROUTING_bar:%1,E=_ROUTING_DEFAULTS_bar:toto] +RewriteCond %{REQUEST_URI} ^/foo(?:/([^/]++))?$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:foobar,E=_ROUTING_param_bar:%1,E=_ROUTING_default_bar:toto] # bar -RewriteCond %{REQUEST_URI} ^/bar/([^/]+)$ +RewriteCond %{REQUEST_URI} ^/bar/([^/]++)$ RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [NC] -RewriteRule .* - [S=1,E=_ROUTING__allow_GET:1,E=_ROUTING__allow_HEAD:1] -RewriteCond %{REQUEST_URI} ^/bar/([^/]+)$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:bar,E=_ROUTING_foo:%1] +RewriteRule .* - [S=1,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_HEAD:1] +RewriteCond %{REQUEST_URI} ^/bar/([^/]++)$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:bar,E=_ROUTING_param_foo:%1] # baragain -RewriteCond %{REQUEST_URI} ^/baragain/([^/]+)$ +RewriteCond %{REQUEST_URI} ^/baragain/([^/]++)$ RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$ [NC] -RewriteRule .* - [S=1,E=_ROUTING__allow_GET:1,E=_ROUTING__allow_POST:1,E=_ROUTING__allow_HEAD:1] -RewriteCond %{REQUEST_URI} ^/baragain/([^/]+)$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baragain,E=_ROUTING_foo:%1] +RewriteRule .* - [S=1,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_POST:1,E=_ROUTING_allow_HEAD:1] +RewriteCond %{REQUEST_URI} ^/baragain/([^/]++)$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baragain,E=_ROUTING_param_foo:%1] # baz RewriteCond %{REQUEST_URI} ^/test/baz$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baz] +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz] # baz2 RewriteCond %{REQUEST_URI} ^/test/baz\.html$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baz2] +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz2] # baz3 RewriteCond %{REQUEST_URI} ^/test/baz3$ RewriteRule .* $0/ [QSA,L,R=301] RewriteCond %{REQUEST_URI} ^/test/baz3/$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baz3] +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz3] # baz4 -RewriteCond %{REQUEST_URI} ^/test/([^/]+)$ +RewriteCond %{REQUEST_URI} ^/test/([^/]++)$ RewriteRule .* $0/ [QSA,L,R=301] -RewriteCond %{REQUEST_URI} ^/test/([^/]+)/$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baz4,E=_ROUTING_foo:%1] +RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz4,E=_ROUTING_param_foo:%1] # baz5 -RewriteCond %{REQUEST_URI} ^/test/([^/]+)/$ +RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$ RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [NC] -RewriteRule .* - [S=2,E=_ROUTING__allow_GET:1,E=_ROUTING__allow_HEAD:1] -RewriteCond %{REQUEST_URI} ^/test/([^/]+)$ +RewriteRule .* - [S=2,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_HEAD:1] +RewriteCond %{REQUEST_URI} ^/test/([^/]++)$ RewriteRule .* $0/ [QSA,L,R=301] -RewriteCond %{REQUEST_URI} ^/test/([^/]+)/$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baz5,E=_ROUTING_foo:%1] +RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz5,E=_ROUTING_param_foo:%1] # baz5unsafe -RewriteCond %{REQUEST_URI} ^/testunsafe/([^/]+)/$ +RewriteCond %{REQUEST_URI} ^/testunsafe/([^/]++)/$ RewriteCond %{REQUEST_METHOD} !^(POST)$ [NC] -RewriteRule .* - [S=1,E=_ROUTING__allow_POST:1] -RewriteCond %{REQUEST_URI} ^/testunsafe/([^/]+)/$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baz5unsafe,E=_ROUTING_foo:%1] +RewriteRule .* - [S=1,E=_ROUTING_allow_POST:1] +RewriteCond %{REQUEST_URI} ^/testunsafe/([^/]++)/$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz5unsafe,E=_ROUTING_param_foo:%1] # baz6 RewriteCond %{REQUEST_URI} ^/test/baz$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baz6,E=_ROUTING_DEFAULTS_foo:bar\ baz] +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz6,E=_ROUTING_default_foo:bar\ baz] # baz7 RewriteCond %{REQUEST_URI} ^/te\ st/baz$ -RewriteRule .* app.php [QSA,L,E=_ROUTING__route:baz7] +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz7] + +# baz8 +RewriteCond %{REQUEST_URI} ^/te\\\ st/baz$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz8] + +# baz9 +RewriteCond %{REQUEST_URI} ^/test/(te\\\ st)$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz9,E=_ROUTING_param_baz:%1] + +RewriteCond %{HTTP:Host} ^a\.example\.com$ +RewriteRule .? - [E=__ROUTING_hostname_1:1] + +# route1 +RewriteCond %{ENV:__ROUTING_hostname_1} =1 +RewriteCond %{REQUEST_URI} ^/route1$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route1] + +# route2 +RewriteCond %{ENV:__ROUTING_hostname_1} =1 +RewriteCond %{REQUEST_URI} ^/c2/route2$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route2] + +RewriteCond %{HTTP:Host} ^b\.example\.com$ +RewriteRule .? - [E=__ROUTING_hostname_2:1] + +# route3 +RewriteCond %{ENV:__ROUTING_hostname_2} =1 +RewriteCond %{REQUEST_URI} ^/c2/route3$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route3] + +RewriteCond %{HTTP:Host} ^a\.example\.com$ +RewriteRule .? - [E=__ROUTING_hostname_3:1] + +# route4 +RewriteCond %{ENV:__ROUTING_hostname_3} =1 +RewriteCond %{REQUEST_URI} ^/route4$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route4] + +RewriteCond %{HTTP:Host} ^c\.example\.com$ +RewriteRule .? - [E=__ROUTING_hostname_4:1] + +# route5 +RewriteCond %{ENV:__ROUTING_hostname_4} =1 +RewriteCond %{REQUEST_URI} ^/route5$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route5] + +# route6 +RewriteCond %{REQUEST_URI} ^/route6$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route6] + +RewriteCond %{HTTP:Host} ^([^\.]++)\.example\.com$ +RewriteRule .? - [E=__ROUTING_hostname_5:1,E=__ROUTING_hostname_5_var1:%1] + +# route11 +RewriteCond %{ENV:__ROUTING_hostname_5} =1 +RewriteCond %{REQUEST_URI} ^/route11$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route11,E=_ROUTING_param_var1:%{ENV:__ROUTING_hostname_5_var1}] + +# route12 +RewriteCond %{ENV:__ROUTING_hostname_5} =1 +RewriteCond %{REQUEST_URI} ^/route12$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route12,E=_ROUTING_param_var1:%{ENV:__ROUTING_hostname_5_var1},E=_ROUTING_default_var1:val] + +# route13 +RewriteCond %{ENV:__ROUTING_hostname_5} =1 +RewriteCond %{REQUEST_URI} ^/route13/([^/]++)$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route13,E=_ROUTING_param_var1:%{ENV:__ROUTING_hostname_5_var1},E=_ROUTING_param_name:%1] + +# route14 +RewriteCond %{ENV:__ROUTING_hostname_5} =1 +RewriteCond %{REQUEST_URI} ^/route14/([^/]++)$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route14,E=_ROUTING_param_var1:%{ENV:__ROUTING_hostname_5_var1},E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val] + +RewriteCond %{HTTP:Host} ^c\.example\.com$ +RewriteRule .? - [E=__ROUTING_hostname_6:1] + +# route15 +RewriteCond %{ENV:__ROUTING_hostname_6} =1 +RewriteCond %{REQUEST_URI} ^/route15/([^/]++)$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route15,E=_ROUTING_param_name:%1] + +# route16 +RewriteCond %{REQUEST_URI} ^/route16/([^/]++)$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route16,E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val] + +# route17 +RewriteCond %{REQUEST_URI} ^/route17$ +RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route17] # 405 Method Not Allowed -RewriteCond %{_ROUTING__allow_GET} !-z [OR] -RewriteCond %{_ROUTING__allow_HEAD} !-z [OR] -RewriteCond %{_ROUTING__allow_POST} !-z +RewriteCond %{ENV:_ROUTING__allow_GET} =1 [OR] +RewriteCond %{ENV:_ROUTING__allow_HEAD} =1 [OR] +RewriteCond %{ENV:_ROUTING__allow_POST} =1 RewriteRule .* app.php [QSA,L] diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php index 2558b2d9f35e..bb4e623ed979 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php @@ -26,83 +26,82 @@ public function match($pathinfo) $pathinfo = rawurldecode($pathinfo); // foo - if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?<bar>baz|symfony)$#s', $pathinfo, $matches)) { - return array_merge($this->mergeDefaults($matches, array ( 'def' => 'test',)), array('_route' => 'foo')); + if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); } - // bar - if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { - $allow = array_merge($allow, array('GET', 'HEAD')); - goto not_bar; - } - - $matches['_route'] = 'bar'; - - return $matches; - } - not_bar: + if (0 === strpos($pathinfo, '/bar')) { + // bar + if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { + $allow = array_merge($allow, array('GET', 'HEAD')); + goto not_bar; + } - // barhead - if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { - $allow = array_merge($allow, array('GET', 'HEAD')); - goto not_barhead; + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ()); } + not_bar: - $matches['_route'] = 'barhead'; - - return $matches; - } - not_barhead: + // barhead + if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { + $allow = array_merge($allow, array('GET', 'HEAD')); + goto not_barhead; + } - // baz - if ($pathinfo === '/test/baz') { - return array('_route' => 'baz'); - } + return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ()); + } + not_barhead: - // baz2 - if ($pathinfo === '/test/baz.html') { - return array('_route' => 'baz2'); } - // baz3 - if ($pathinfo === '/test/baz3/') { - return array('_route' => 'baz3'); - } + if (0 === strpos($pathinfo, '/test')) { + if (0 === strpos($pathinfo, '/test/baz')) { + // baz + if ($pathinfo === '/test/baz') { + return array('_route' => 'baz'); + } - // baz4 - if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+)/$#s', $pathinfo, $matches)) { - $matches['_route'] = 'baz4'; + // baz2 + if ($pathinfo === '/test/baz.html') { + return array('_route' => 'baz2'); + } - return $matches; - } + // baz3 + if ($pathinfo === '/test/baz3/') { + return array('_route' => 'baz3'); + } - // baz5 - if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+)/$#s', $pathinfo, $matches)) { - if ($this->context->getMethod() != 'POST') { - $allow[] = 'POST'; - goto not_baz5; } - $matches['_route'] = 'baz5'; + // baz4 + if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); + } - return $matches; - } - not_baz5: + // baz5 + if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) { + if ($this->context->getMethod() != 'POST') { + $allow[] = 'POST'; + goto not_baz5; + } - // baz.baz6 - if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+)/$#s', $pathinfo, $matches)) { - if ($this->context->getMethod() != 'PUT') { - $allow[] = 'PUT'; - goto not_bazbaz6; + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ()); } + not_baz5: - $matches['_route'] = 'baz.baz6'; + // baz.baz6 + if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) { + if ($this->context->getMethod() != 'PUT') { + $allow[] = 'PUT'; + goto not_bazbaz6; + } + + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ()); + } + not_bazbaz6: - return $matches; } - not_bazbaz6: // foofoo if ($pathinfo === '/foofoo') { @@ -110,10 +109,8 @@ public function match($pathinfo) } // quoter - if (preg_match('#^/(?<quoter>[\']+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'quoter'; - - return $matches; + if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); } // space @@ -124,41 +121,31 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/a')) { if (0 === strpos($pathinfo, '/a/b\'b')) { // foo1 - if (preg_match('#^/a/b\'b/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'foo1'; - - return $matches; + if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); } // bar1 - if (preg_match('#^/a/b\'b/(?<bar>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'bar1'; - - return $matches; + if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); } } // overridden - if (preg_match('#^/a/(?<var>.*)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'overridden'; - - return $matches; + if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ()); } if (0 === strpos($pathinfo, '/a/b\'b')) { // foo2 - if (preg_match('#^/a/b\'b/(?<foo1>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'foo2'; - - return $matches; + if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); } // bar2 - if (preg_match('#^/a/b\'b/(?<bar1>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'bar2'; - - return $matches; + if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); } } @@ -167,8 +154,8 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/multi')) { // helloWorld - if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?<who>[^/]+))?$#s', $pathinfo, $matches)) { - return array_merge($this->mergeDefaults($matches, array ( 'who' => 'World!',)), array('_route' => 'helloWorld')); + if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); } // overridden2 @@ -184,29 +171,117 @@ public function match($pathinfo) } // foo3 - if (preg_match('#^/(?<_locale>[^/]+)/b/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'foo3'; - - return $matches; + if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); } // bar3 - if (preg_match('#^/(?<_locale>[^/]+)/b/(?<bar>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'bar3'; + if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ()); + } + + if (0 === strpos($pathinfo, '/aba')) { + // ababa + if ($pathinfo === '/ababa') { + return array('_route' => 'ababa'); + } + + // foo4 + if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); + } - return $matches; } - // ababa - if ($pathinfo === '/ababa') { - return array('_route' => 'ababa'); + $hostname = $this->context->getHost(); + + if (preg_match('#^a\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route1 + if ($pathinfo === '/route1') { + return array('_route' => 'route1'); + } + + // route2 + if ($pathinfo === '/c2/route2') { + return array('_route' => 'route2'); + } + + } + + if (preg_match('#^b\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route3 + if ($pathinfo === '/c2/route3') { + return array('_route' => 'route3'); + } + + } + + if (preg_match('#^a\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route4 + if ($pathinfo === '/route4') { + return array('_route' => 'route4'); + } + + } + + if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route5 + if ($pathinfo === '/route5') { + return array('_route' => 'route5'); + } + + } + + // route6 + if ($pathinfo === '/route6') { + return array('_route' => 'route6'); + } + + if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) { + if (0 === strpos($pathinfo, '/route1')) { + // route11 + if ($pathinfo === '/route11') { + return $this->mergeDefaults(array_replace($hostnameMatches, array('_route' => 'route11')), array ()); + } + + // route12 + if ($pathinfo === '/route12') { + return $this->mergeDefaults(array_replace($hostnameMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); + } + + // route13 + if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route13')), array ()); + } + + // route14 + if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); + } + + } + } - // foo4 - if (0 === strpos($pathinfo, '/aba') && preg_match('#^/aba/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'foo4'; + if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route15 + if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); + } + + } + + if (0 === strpos($pathinfo, '/route1')) { + // route16 + if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); + } + + // route17 + if ($pathinfo === '/route17') { + return array('_route' => 'route17'); + } - return $matches; } if (0 === strpos($pathinfo, '/a')) { @@ -217,17 +292,13 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/a/b')) { // b - if (preg_match('#^/a/b/(?<var>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'b'; - - return $matches; + if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ()); } // c - if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?<var>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'c'; - - return $matches; + if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.apache b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.apache index d16ab974bf35..309f2ff0e539 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.apache +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.apache @@ -4,4 +4,4 @@ RewriteRule .* - [QSA,L] # foo RewriteCond %{REQUEST_URI} ^/foo$ -RewriteRule .* ap\ p_d\ ev.php [QSA,L,E=_ROUTING__route:foo] +RewriteRule .* ap\ p_d\ ev.php [QSA,L,E=_ROUTING_route:foo] diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index ad1476edccc5..2bd38122a088 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -26,91 +26,90 @@ public function match($pathinfo) $pathinfo = rawurldecode($pathinfo); // foo - if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?<bar>baz|symfony)$#s', $pathinfo, $matches)) { - return array_merge($this->mergeDefaults($matches, array ( 'def' => 'test',)), array('_route' => 'foo')); + if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); } - // bar - if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { - $allow = array_merge($allow, array('GET', 'HEAD')); - goto not_bar; - } + if (0 === strpos($pathinfo, '/bar')) { + // bar + if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { + $allow = array_merge($allow, array('GET', 'HEAD')); + goto not_bar; + } - $matches['_route'] = 'bar'; + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ()); + } + not_bar: - return $matches; - } - not_bar: + // barhead + if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { + $allow = array_merge($allow, array('GET', 'HEAD')); + goto not_barhead; + } - // barhead - if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { - $allow = array_merge($allow, array('GET', 'HEAD')); - goto not_barhead; + return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ()); } + not_barhead: - $matches['_route'] = 'barhead'; - - return $matches; } - not_barhead: - // baz - if ($pathinfo === '/test/baz') { - return array('_route' => 'baz'); - } + if (0 === strpos($pathinfo, '/test')) { + if (0 === strpos($pathinfo, '/test/baz')) { + // baz + if ($pathinfo === '/test/baz') { + return array('_route' => 'baz'); + } - // baz2 - if ($pathinfo === '/test/baz.html') { - return array('_route' => 'baz2'); - } + // baz2 + if ($pathinfo === '/test/baz.html') { + return array('_route' => 'baz2'); + } - // baz3 - if (rtrim($pathinfo, '/') === '/test/baz3') { - if (substr($pathinfo, -1) !== '/') { - return $this->redirect($pathinfo.'/', 'baz3'); - } + // baz3 + if (rtrim($pathinfo, '/') === '/test/baz3') { + if (substr($pathinfo, -1) !== '/') { + return $this->redirect($pathinfo.'/', 'baz3'); + } - return array('_route' => 'baz3'); - } + return array('_route' => 'baz3'); + } - // baz4 - if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+)/?$#s', $pathinfo, $matches)) { - if (substr($pathinfo, -1) !== '/') { - return $this->redirect($pathinfo.'/', 'baz4'); } - $matches['_route'] = 'baz4'; - - return $matches; - } + // baz4 + if (preg_match('#^/test/(?P<foo>[^/]++)/?$#s', $pathinfo, $matches)) { + if (substr($pathinfo, -1) !== '/') { + return $this->redirect($pathinfo.'/', 'baz4'); + } - // baz5 - if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+)/$#s', $pathinfo, $matches)) { - if ($this->context->getMethod() != 'POST') { - $allow[] = 'POST'; - goto not_baz5; + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); } - $matches['_route'] = 'baz5'; - - return $matches; - } - not_baz5: + // baz5 + if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) { + if ($this->context->getMethod() != 'POST') { + $allow[] = 'POST'; + goto not_baz5; + } - // baz.baz6 - if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+)/$#s', $pathinfo, $matches)) { - if ($this->context->getMethod() != 'PUT') { - $allow[] = 'PUT'; - goto not_bazbaz6; + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ()); } + not_baz5: - $matches['_route'] = 'baz.baz6'; + // baz.baz6 + if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) { + if ($this->context->getMethod() != 'PUT') { + $allow[] = 'PUT'; + goto not_bazbaz6; + } + + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ()); + } + not_bazbaz6: - return $matches; } - not_bazbaz6: // foofoo if ($pathinfo === '/foofoo') { @@ -118,10 +117,8 @@ public function match($pathinfo) } // quoter - if (preg_match('#^/(?<quoter>[\']+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'quoter'; - - return $matches; + if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); } // space @@ -132,41 +129,31 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/a')) { if (0 === strpos($pathinfo, '/a/b\'b')) { // foo1 - if (preg_match('#^/a/b\'b/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'foo1'; - - return $matches; + if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); } // bar1 - if (preg_match('#^/a/b\'b/(?<bar>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'bar1'; - - return $matches; + if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); } } // overridden - if (preg_match('#^/a/(?<var>.*)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'overridden'; - - return $matches; + if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ()); } if (0 === strpos($pathinfo, '/a/b\'b')) { // foo2 - if (preg_match('#^/a/b\'b/(?<foo1>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'foo2'; - - return $matches; + if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); } // bar2 - if (preg_match('#^/a/b\'b/(?<bar1>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'bar2'; - - return $matches; + if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); } } @@ -175,8 +162,8 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/multi')) { // helloWorld - if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?<who>[^/]+))?$#s', $pathinfo, $matches)) { - return array_merge($this->mergeDefaults($matches, array ( 'who' => 'World!',)), array('_route' => 'helloWorld')); + if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); } // overridden2 @@ -196,29 +183,117 @@ public function match($pathinfo) } // foo3 - if (preg_match('#^/(?<_locale>[^/]+)/b/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'foo3'; - - return $matches; + if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); } // bar3 - if (preg_match('#^/(?<_locale>[^/]+)/b/(?<bar>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'bar3'; + if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ()); + } + + if (0 === strpos($pathinfo, '/aba')) { + // ababa + if ($pathinfo === '/ababa') { + return array('_route' => 'ababa'); + } + + // foo4 + if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); + } - return $matches; } - // ababa - if ($pathinfo === '/ababa') { - return array('_route' => 'ababa'); + $hostname = $this->context->getHost(); + + if (preg_match('#^a\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route1 + if ($pathinfo === '/route1') { + return array('_route' => 'route1'); + } + + // route2 + if ($pathinfo === '/c2/route2') { + return array('_route' => 'route2'); + } + + } + + if (preg_match('#^b\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route3 + if ($pathinfo === '/c2/route3') { + return array('_route' => 'route3'); + } + } - // foo4 - if (0 === strpos($pathinfo, '/aba') && preg_match('#^/aba/(?<foo>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'foo4'; + if (preg_match('#^a\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route4 + if ($pathinfo === '/route4') { + return array('_route' => 'route4'); + } + + } + + if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route5 + if ($pathinfo === '/route5') { + return array('_route' => 'route5'); + } + + } + + // route6 + if ($pathinfo === '/route6') { + return array('_route' => 'route6'); + } + + if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) { + if (0 === strpos($pathinfo, '/route1')) { + // route11 + if ($pathinfo === '/route11') { + return $this->mergeDefaults(array_replace($hostnameMatches, array('_route' => 'route11')), array ()); + } + + // route12 + if ($pathinfo === '/route12') { + return $this->mergeDefaults(array_replace($hostnameMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); + } + + // route13 + if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route13')), array ()); + } + + // route14 + if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); + } + + } + + } + + if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) { + // route15 + if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); + } + + } + + if (0 === strpos($pathinfo, '/route1')) { + // route16 + if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); + } + + // route17 + if ($pathinfo === '/route17') { + return array('_route' => 'route17'); + } - return $matches; } if (0 === strpos($pathinfo, '/a')) { @@ -229,17 +304,13 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/a/b')) { // b - if (preg_match('#^/a/b/(?<var>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'b'; - - return $matches; + if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ()); } // c - if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?<var>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'c'; - - return $matches; + if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php index 13ffeb95e43e..f2f642eb8669 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php @@ -32,10 +32,8 @@ public function match($pathinfo) } // dynamic - if (preg_match('#^/rootprefix/(?<var>[^/]+)$#s', $pathinfo, $matches)) { - $matches['_route'] = 'dynamic'; - - return $matches; + if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#s', $pathinfo, $matches)) { + return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ()); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml new file mode 100644 index 000000000000..1009741a86a9 --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml @@ -0,0 +1,2 @@ +"#$péß^a|": + pattern: "true" diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php index 0d1d3a73dad6..08e7d6e34779 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php @@ -6,8 +6,9 @@ $collection->add('blog_show', new Route( '/blog/{slug}', array('_controller' => 'MyBlogBundle:Blog:show'), - array(), - array('compiler_class' => 'RouteCompiler') + array('_method' => 'GET', 'locale' => '\w+'), + array('compiler_class' => 'RouteCompiler'), + '{locale}.example.com' )); return $collection; diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml index fdb38073a0ea..079116399c46 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml @@ -4,9 +4,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - <route id="blog_show" pattern="/blog/{slug}"> + <route id="blog_show" pattern="/blog/{slug}" hostname-pattern="{locale}.example.com"> <default key="_controller">MyBundle:Blog:show</default> <requirement key="_method">GET</requirement> + <requirement key="locale">\w+</requirement> <option key="compiler_class">RouteCompiler</option> </route> </routes> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml index d5136cbab803..8fad8a0923a4 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml @@ -1,5 +1,7 @@ blog_show: - pattern: /blog/{slug} - defaults: { _controller: MyBlogBundle:Blog:show } + pattern: /blog/{slug} + defaults: { _controller: MyBlogBundle:Blog:show } + hostname_pattern: "{locale}.example.com" + requirements: { '_method': 'GET', 'locale': '\w+' } options: compiler_class: RouteCompiler diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml index 14ac0fc331bb..b3747864fbe5 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml @@ -4,8 +4,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - <import resource="validpattern.xml" prefix="/{foo}"> - <default key="foo">foo</default> + <import resource="validpattern.xml" prefix="/{foo}" hostname-pattern="{locale}.example.com"> + <default key="foo">123</default> <requirement key="foo">\d+</requirement> <option key="foo">bar</option> </import> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml index e66f37613b7f..35a45398ff14 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml @@ -1,6 +1,7 @@ blog_show: - resource: validpattern.yml - prefix: /{foo} - defaults: { 'foo': 'foo' } - requirements: { 'foo': '\d+' } - options: { 'foo': 'bar' } + resource: validpattern.yml + prefix: /{foo} + defaults: { 'foo': '123' } + requirements: { 'foo': '\d+' } + options: { 'foo': 'bar' } + hostname_pattern: "{locale}.example.com" diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 69c06a44ea71..a3f50b6aca13 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -74,12 +74,15 @@ public function testRelativeUrlWithNullParameter() $this->assertEquals('/app.php/testing', $url); } + /** + * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException + */ public function testRelativeUrlWithNullParameterButNotOptional() { $routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', array('foo' => null))); - $url = $this->getGenerator($routes)->generate('test', array(), false); - - $this->assertEquals('/app.php/testing//bar', $url); + // This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params. + // Generating path "/testing//bar" would be wrong as matching this route would fail. + $this->getGenerator($routes)->generate('test', array(), false); } public function testRelativeUrlWithOptionalZeroParameter() @@ -90,6 +93,13 @@ public function testRelativeUrlWithOptionalZeroParameter() $this->assertEquals('/app.php/testing/0', $url); } + public function testNotPassedOptionalParameterInBetween() + { + $routes = $this->getRoutes('test', new Route('/{slug}/{page}', array('slug' => 'index', 'page' => 0))); + $this->assertSame('/app.php/index/1', $this->getGenerator($routes)->generate('test', array('page' => 1))); + $this->assertSame('/app.php/', $this->getGenerator($routes)->generate('test')); + } + public function testRelativeUrlWithExtraParameters() { $routes = $this->getRoutes('test', new Route('/testing')); @@ -138,6 +148,18 @@ public function testUrlWithGlobalParameter() $this->assertEquals('/app.php/testing/bar', $url); } + public function testGlobalParameterHasHigherPriorityThanDefault() + { + $routes = $this->getRoutes('test', new Route('/{_locale}', array('_locale' => 'en'))); + $generator = $this->getGenerator($routes); + $context = new RequestContext('/app.php'); + $context->setParameter('_locale', 'de'); + $generator->setContext($context); + $url = $generator->generate('test', array()); + + $this->assertSame('/app.php/de', $url); + } + /** * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException */ @@ -165,6 +187,15 @@ public function testGenerateForRouteWithInvalidOptionalParameter() $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), true); } + /** + * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException + */ + public function testGenerateForRouteWithInvalidParameter() + { + $routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => '1|2'))); + $this->getGenerator($routes)->generate('test', array('foo' => '0'), true); + } + public function testGenerateForRouteWithInvalidOptionalParameterNonStrict() { $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); @@ -175,7 +206,7 @@ public function testGenerateForRouteWithInvalidOptionalParameterNonStrict() public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger() { - if (!class_exists('Symfony\Component\HttpKernel\Log\LoggerInterface')) { + if (!interface_exists('Symfony\Component\HttpKernel\Log\LoggerInterface')) { $this->markTestSkipped('The "HttpKernel" component is not available'); } @@ -188,6 +219,14 @@ public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLog $this->assertNull($generator->generate('test', array('foo' => 'bar'), true)); } + public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck() + { + $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); + $generator = $this->getGenerator($routes); + $generator->setStrictRequirements(null); + $this->assertSame('/app.php/testing/bar', $generator->generate('test', array('foo' => 'bar'))); + } + /** * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException */ @@ -197,6 +236,15 @@ public function testGenerateForRouteWithInvalidMandatoryParameter() $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), true); } + /** + * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException + */ + public function testRequiredParamAndEmptyPassed() + { + $routes = $this->getRoutes('test', new Route('/{slug}', array(), array('slug' => '.+'))); + $this->getGenerator($routes)->generate('test', array('slug' => '')); + } + public function testSchemeRequirementDoesNothingIfSameCurrentScheme() { $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); @@ -215,6 +263,14 @@ public function testSchemeRequirementForcesAbsoluteUrl() $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); } + public function testPathWithTwoStartingSlashes() + { + $routes = $this->getRoutes('test', new Route('//path-and-not-domain')); + + // this must not generate '//path-and-not-domain' because that would be a network path + $this->assertSame('/path-and-not-domain', $this->getGenerator($routes, array('BaseUrl' => ''))->generate('test')); + } + public function testNoTrailingSlashForMultipleOptionalParameters() { $routes = $this->getRoutes('test', new Route('/category/{slug1}/{slug2}/{slug3}', array('slug2' => null, 'slug3' => null))); @@ -229,6 +285,22 @@ public function testWithAnIntegerAsADefaultValue() $this->assertEquals('/app.php/foo', $this->getGenerator($routes)->generate('test', array('default' => 'foo'))); } + public function testQueryParamSameAsDefault() + { + $routes = $this->getRoutes('test', new Route('/test', array('default' => 'value'))); + + $this->assertSame('/app.php/test?default=foo', $this->getGenerator($routes)->generate('test', array('default' => 'foo'))); + $this->assertSame('/app.php/test?default=value', $this->getGenerator($routes)->generate('test', array('default' => 'value'))); + $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test')); + } + + public function testGenerateWithSpecialRouteName() + { + $routes = $this->getRoutes('$péß^a|', new Route('/bar')); + + $this->assertSame('/app.php/bar', $this->getGenerator($routes)->generate('$péß^a|')); + } + public function testUrlEncoding() { // This tests the encoding of reserved characters that are used for delimiting of URI components (defined in RFC 3986) @@ -255,6 +327,119 @@ public function testEncodingOfRelativePathSegments() $this->assertSame('/app.php/a./.a/a../..a/...', $this->getGenerator($routes)->generate('test')); } + public function testAdjacentVariables() + { + $routes = $this->getRoutes('test', new Route('/{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => '\d+'))); + $generator = $this->getGenerator($routes); + $this->assertSame('/app.php/foo123', $generator->generate('test', array('x' => 'foo', 'y' => '123'))); + $this->assertSame('/app.php/foo123bar.xml', $generator->generate('test', array('x' => 'foo', 'y' => '123', 'z' => 'bar', '_format' => 'xml'))); + + // The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything + // and following optional variables like _format could never match. + $this->setExpectedException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $generator->generate('test', array('x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml')); + } + + public function testOptionalVariableWithNoRealSeparator() + { + $routes = $this->getRoutes('test', new Route('/get{what}', array('what' => 'All'))); + $generator = $this->getGenerator($routes); + + $this->assertSame('/app.php/get', $generator->generate('test')); + $this->assertSame('/app.php/getSites', $generator->generate('test', array('what' => 'Sites'))); + } + + public function testRequiredVariableWithNoRealSeparator() + { + $routes = $this->getRoutes('test', new Route('/get{what}Suffix')); + $generator = $this->getGenerator($routes); + + $this->assertSame('/app.php/getSitesSuffix', $generator->generate('test', array('what' => 'Sites'))); + } + + public function testDefaultRequirementOfVariable() + { + $routes = $this->getRoutes('test', new Route('/{page}.{_format}')); + $generator = $this->getGenerator($routes); + + $this->assertSame('/app.php/index.mobile.html', $generator->generate('test', array('page' => 'index', '_format' => 'mobile.html'))); + } + + /** + * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException + */ + public function testDefaultRequirementOfVariableDisallowsSlash() + { + $routes = $this->getRoutes('test', new Route('/{page}.{_format}')); + $this->getGenerator($routes)->generate('test', array('page' => 'index', '_format' => 'sl/ash')); + } + + /** + * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException + */ + public function testDefaultRequirementOfVariableDisallowsNextSeparator() + { + + $routes = $this->getRoutes('test', new Route('/{page}.{_format}')); + $this->getGenerator($routes)->generate('test', array('page' => 'do.t', '_format' => 'html')); + } + + public function testWithHostnameDifferentFromContext() + { + $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); + + $this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' =>'Fabien', 'locale' => 'fr'))); + } + + public function testWithHostnameSameAsContext() + { + $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); + + $this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' =>'Fabien', 'locale' => 'fr'))); + } + + public function testWithHostnameSameAsContextAndAbsolute() + { + $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); + + $this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' =>'Fabien', 'locale' => 'fr'), true)); + } + + /** + * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException + */ + public function testUrlWithInvalidParameterInHostname() + { + $routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com')); + $this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false); + } + + /** + * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException + */ + public function testUrlWithInvalidParameterInHostnameWhenParamHasADefaultValue() + { + $routes = $this->getRoutes('test', new Route('/', array('foo' => 'bar'), array('foo' => 'bar'), array(), '{foo}.example.com')); + $this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false); + } + + /** + * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException + */ + public function testUrlWithInvalidParameterEqualsDefaultValueInHostname() + { + $routes = $this->getRoutes('test', new Route('/', array('foo' => 'baz'), array('foo' => 'bar'), array(), '{foo}.example.com')); + $this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false); + } + + public function testUrlWithInvalidParameterInHostnameInNonStrictMode() + { + $routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com')); + $generator = $this->getGenerator($routes); + $generator->setStrictRequirements(false); + $this->assertNull($generator->generate('test', array('foo' => 'baz'), false)); + } + protected function getGenerator(RouteCollection $routes, array $parameters = array(), $logger = null) { $context = new RequestContext('/app.php'); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php index faeacfb2ff4c..002d7449b8cd 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php @@ -21,7 +21,8 @@ protected function setUp() { parent::setUp(); - $this->loader = $this->getClassLoader($this->getReader()); + $this->reader = $this->getReader(); + $this->loader = $this->getClassLoader($this->reader); } /** @@ -71,4 +72,52 @@ public function testSupportsChecksTypeIfSpecified() $this->assertFalse($this->loader->supports('class', 'foo'), '->supports() checks the resource type if specified'); } + public function getLoadTests() + { + return array( + array( + 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', + array('name'=>'route1'), + array('arg2' => 'defaultValue2', 'arg3' =>'defaultValue3') + ), + array( + 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', + array('name'=>'route1', 'defaults' => array('arg2' => 'foo')), + array('arg2' => 'defaultValue2', 'arg3' =>'defaultValue3') + ), + ); + } + + /** + * @dataProvider getLoadTests + */ + public function testLoad($className, $routeDatas = array(), $methodArgs = array()) + { + $routeDatas = array_replace(array( + 'name' => 'route', + 'pattern' => '/', + 'requirements' => array(), + 'options' => array(), + 'defaults' => array(), + ), $routeDatas); + + $this->reader + ->expects($this->once()) + ->method('getMethodAnnotations') + ->will($this->returnValue(array($this->getAnnotedRoute($routeDatas)))) + ; + $routeCollection = $this->loader->load($className); + $route = $routeCollection->get($routeDatas['name']); + + $this->assertSame($routeDatas['pattern'], $route->getPattern(), '->load preserves pattern annotation'); + $this->assertSame($routeDatas['requirements'],$route->getRequirements(), '->load preserves requirements annotation'); + $this->assertCount(0, array_intersect($route->getOptions(), $routeDatas['options']), '->load preserves options annotation'); + $this->assertSame(array_replace($routeDatas['defaults'], $methodArgs), $route->getDefaults(), '->load preserves defaults annotation'); + } + + private function getAnnotedRoute($datas) + { + return new \Symfony\Component\Routing\Annotation\Route($datas); + } + } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php index 3877eeca741d..a8ac7331201f 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php @@ -29,7 +29,13 @@ protected function setUp() public function testLoad() { - $this->reader->expects($this->once())->method('getClassAnnotation'); + $this->reader->expects($this->exactly(2))->method('getClassAnnotation'); + + $this->reader + ->expects($this->any()) + ->method('getMethodAnnotations') + ->will($this->returnValue(array())) + ; $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses'); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php index 74c38737f2f9..0ea7b32e1712 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php @@ -47,6 +47,10 @@ public function testLoadWithRoute() $this->assertEquals(1, count($routes), 'One route is loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); $route = $routes['blog_show']; + $this->assertEquals('/blog/{slug}', $route->getPattern()); + $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller')); + $this->assertEquals('GET', $route->getRequirement('_method')); + $this->assertEquals('{locale}.example.com', $route->getHostnamePattern()); $this->assertEquals('RouteCompiler', $route->getOption('compiler_class')); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index e6f217606da4..235a9d13af4c 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -48,6 +48,11 @@ public function testLoadWithRoute() $this->assertEquals(1, count($routes), 'One route is loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); $route = $routes['blog_show']; + $this->assertEquals('/blog/{slug}', $route->getPattern()); + $this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller')); + $this->assertEquals('GET', $route->getRequirement('_method')); + $this->assertEquals('\w+', $route->getRequirement('locale')); + $this->assertEquals('{locale}.example.com', $route->getHostnamePattern()); $this->assertEquals('RouteCompiler', $route->getOption('compiler_class')); } @@ -59,9 +64,12 @@ public function testLoadWithImport() $this->assertEquals(1, count($routes), 'One route is loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - $this->assertEquals('foo', $routes['blog_show']->getDefault('foo')); + $this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPattern()); + $this->assertEquals('MyBundle:Blog:show', $routes['blog_show']->getDefault('_controller')); + $this->assertEquals('123', $routes['blog_show']->getDefault('foo')); $this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo')); $this->assertEquals('bar', $routes['blog_show']->getOption('foo')); + $this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostnamePattern()); } /** diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index 0c870e667a6a..e2e0f98eeb1e 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -79,6 +79,16 @@ public function testLoadThrowsExceptionWhenIncomplete() $loader->load('incomplete.yml'); } + public function testLoadSpecialRouteName() + { + $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); + $routeCollection = $loader->load('special_route_name.yml'); + $route = $routeCollection->get('#$péß^a|'); + + $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); + $this->assertSame('/true', $route->getPattern()); + } + public function testLoadWithPattern() { $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); @@ -88,6 +98,11 @@ public function testLoadWithPattern() $this->assertEquals(1, count($routes), 'One route is loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); $route = $routes['blog_show']; + $this->assertEquals('/blog/{slug}', $route->getPattern()); + $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller')); + $this->assertEquals('GET', $route->getRequirement('_method')); + $this->assertEquals('\w+', $route->getRequirement('locale')); + $this->assertEquals('{locale}.example.com', $route->getHostnamePattern()); $this->assertEquals('RouteCompiler', $route->getOption('compiler_class')); } @@ -99,9 +114,12 @@ public function testLoadWithResource() $this->assertEquals(1, count($routes), 'One route is loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - $this->assertEquals('foo', $routes['blog_show']->getDefault('foo')); + $this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPattern()); + $this->assertEquals('MyBlogBundle:Blog:show', $routes['blog_show']->getDefault('_controller')); + $this->assertEquals('123', $routes['blog_show']->getDefault('foo')); $this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo')); $this->assertEquals('bar', $routes['blog_show']->getOption('foo')); + $this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostnamePattern()); } /** diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php index 88487201cc31..6550911eb7b2 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php @@ -51,57 +51,85 @@ public function getMatchData() 'Simple route', '/hello/world', array( - '_ROUTING__route' => 'hello', - '_ROUTING__controller' => 'AcmeBundle:Default:index', - '_ROUTING_name' => 'world', + '_ROUTING_route' => 'hello', + '_ROUTING_param__controller' => 'AcmeBundle:Default:index', + '_ROUTING_param_name' => 'world', ), array( - '_route' => 'hello', '_controller' => 'AcmeBundle:Default:index', 'name' => 'world', + '_route' => 'hello', ), ), array( 'Route with params and defaults', '/hello/hugo', array( - '_ROUTING__route' => 'hello', - '_ROUTING__controller' => 'AcmeBundle:Default:index', - '_ROUTING_name' => 'hugo', - '_ROUTING_DEFAULTS_name' => 'world', + '_ROUTING_route' => 'hello', + '_ROUTING_param__controller' => 'AcmeBundle:Default:index', + '_ROUTING_param_name' => 'hugo', + '_ROUTING_default_name' => 'world', ), array( 'name' => 'hugo', - '_route' => 'hello', '_controller' => 'AcmeBundle:Default:index', + '_route' => 'hello', ), ), array( 'Route with defaults only', '/hello', array( - '_ROUTING__route' => 'hello', - '_ROUTING__controller' => 'AcmeBundle:Default:index', - '_ROUTING_DEFAULTS_name' => 'world', + '_ROUTING_route' => 'hello', + '_ROUTING_param__controller' => 'AcmeBundle:Default:index', + '_ROUTING_default_name' => 'world', ), array( 'name' => 'world', - '_route' => 'hello', '_controller' => 'AcmeBundle:Default:index', + '_route' => 'hello', ), ), array( 'REDIRECT_ envs', '/hello/world', array( - 'REDIRECT__ROUTING__route' => 'hello', - 'REDIRECT__ROUTING__controller' => 'AcmeBundle:Default:index', - 'REDIRECT__ROUTING_name' => 'world', + 'REDIRECT__ROUTING_route' => 'hello', + 'REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index', + 'REDIRECT__ROUTING_param_name' => 'world', + ), + array( + '_controller' => 'AcmeBundle:Default:index', + 'name' => 'world', + '_route' => 'hello', + ), + ), + array( + 'REDIRECT_REDIRECT_ envs', + '/hello/world', + array( + 'REDIRECT_REDIRECT__ROUTING_route' => 'hello', + 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index', + 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world', ), array( + '_controller' => 'AcmeBundle:Default:index', + 'name' => 'world', '_route' => 'hello', + ), + ), + array( + 'REDIRECT_REDIRECT_ envs', + '/hello/world', + array( + 'REDIRECT_REDIRECT__ROUTING_route' => 'hello', + 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index', + 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world', + ), + array( '_controller' => 'AcmeBundle:Default:index', 'name' => 'world', + '_route' => 'hello', ), ), ); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php index 2847564b90ed..e72976f047ab 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php @@ -124,6 +124,71 @@ private function getRouteCollection() $collection->add('baz7', new Route( '/te st/baz' )); + // space preceded with \ in path + $collection->add('baz8', new Route( + '/te\\ st/baz' + )); + // space preceded with \ in requirement + $collection->add('baz9', new Route( + '/test/{baz}', + array(), + array( + 'baz' => 'te\\\\ st', + ) + )); + + $collection1 = new RouteCollection(); + + $route1 = new Route('/route1', array(), array(), array(), 'a.example.com'); + $collection1->add('route1', $route1); + + $collection2 = new RouteCollection(); + + $route2 = new Route('/route2', array(), array(), array(), 'a.example.com'); + $collection2->add('route2', $route2); + + $route3 = new Route('/route3', array(), array(), array(), 'b.example.com'); + $collection2->add('route3', $route3); + + $collection1->addCollection($collection2, '/c2'); + + $route4 = new Route('/route4', array(), array(), array(), 'a.example.com'); + $collection1->add('route4', $route4); + + $route5 = new Route('/route5', array(), array(), array(), 'c.example.com'); + $collection1->add('route5', $route5); + + $route6 = new Route('/route6', array(), array(), array(), null); + $collection1->add('route6', $route6); + + $collection->addCollection($collection1); + + // hostname and variables + + $collection1 = new RouteCollection(); + + $route11 = new Route('/route11', array(), array(), array(), '{var1}.example.com'); + $collection1->add('route11', $route11); + + $route12 = new Route('/route12', array('var1' => 'val'), array(), array(), '{var1}.example.com'); + $collection1->add('route12', $route12); + + $route13 = new Route('/route13/{name}', array(), array(), array(), '{var1}.example.com'); + $collection1->add('route13', $route13); + + $route14 = new Route('/route14/{name}', array('var1' => 'val'), array(), array(), '{var1}.example.com'); + $collection1->add('route14', $route14); + + $route15 = new Route('/route15/{name}', array(), array(), array(), 'c.example.com'); + $collection1->add('route15', $route15); + + $route16 = new Route('/route16/{name}', array('var1' => 'val'), array(), array(), null); + $collection1->add('route16', $route16); + + $route17 = new Route('/route17', array(), array(), array(), null); + $collection1->add('route17', $route17); + + $collection->addCollection($collection1); return $collection; } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php new file mode 100644 index 000000000000..62ca947848c4 --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php @@ -0,0 +1,24 @@ +<?php + +namespace Symfony\Component\Routing\Test\Matcher\Dumper; + +use Symfony\Component\Routing\Matcher\Dumper\DumperCollection; + +class DumperCollectionTest extends \PHPUnit_Framework_TestCase +{ + public function testGetRoot() + { + $a = new DumperCollection(); + + $b = new DumperCollection(); + $a->add($b); + + $c = new DumperCollection(); + $b->add($c); + + $d = new DumperCollection(); + $c->add($d); + + $this->assertSame($a, $c->getRoot()); + } +} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php new file mode 100644 index 000000000000..9ba140bf8c7d --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php @@ -0,0 +1,114 @@ +<?php + +namespace Symfony\Component\Routing\Tests\Matcher\Dumper; + +use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection; +use Symfony\Component\Routing\Matcher\Dumper\DumperRoute; +use Symfony\Component\Routing\Matcher\Dumper\DumperCollection; + +class DumperPrefixCollectionTest extends \PHPUnit_Framework_TestCase +{ + public function testAddPrefixRoute() + { + $coll = new DumperPrefixCollection; + $coll->setPrefix(''); + + $route = new DumperRoute('bar', new Route('/foo/bar')); + $coll = $coll->addPrefixRoute($route); + + $route = new DumperRoute('bar2', new Route('/foo/bar')); + $coll = $coll->addPrefixRoute($route); + + $route = new DumperRoute('qux', new Route('/foo/qux')); + $coll = $coll->addPrefixRoute($route); + + $route = new DumperRoute('bar3', new Route('/foo/bar')); + $coll = $coll->addPrefixRoute($route); + + $route = new DumperRoute('bar4', new Route('')); + $result = $coll->addPrefixRoute($route); + + $expect = <<<'EOF' + |-coll / + | |-coll /f + | | |-coll /fo + | | | |-coll /foo + | | | | |-coll /foo/ + | | | | | |-coll /foo/b + | | | | | | |-coll /foo/ba + | | | | | | | |-coll /foo/bar + | | | | | | | | |-route bar /foo/bar + | | | | | | | | |-route bar2 /foo/bar + | | | | | |-coll /foo/q + | | | | | | |-coll /foo/qu + | | | | | | | |-coll /foo/qux + | | | | | | | | |-route qux /foo/qux + | | | | | |-coll /foo/b + | | | | | | |-coll /foo/ba + | | | | | | | |-coll /foo/bar + | | | | | | | | |-route bar3 /foo/bar + | |-route bar4 / + +EOF; + + $this->assertSame($expect, $this->collectionToString($result->getRoot(), ' ')); + } + + public function testMergeSlashNodes() + { + $coll = new DumperPrefixCollection; + $coll->setPrefix(''); + + $route = new DumperRoute('bar', new Route('/foo/bar')); + $coll = $coll->addPrefixRoute($route); + + $route = new DumperRoute('bar2', new Route('/foo/bar')); + $coll = $coll->addPrefixRoute($route); + + $route = new DumperRoute('qux', new Route('/foo/qux')); + $coll = $coll->addPrefixRoute($route); + + $route = new DumperRoute('bar3', new Route('/foo/bar')); + $result = $coll->addPrefixRoute($route); + + $result->getRoot()->mergeSlashNodes(); + + $expect = <<<'EOF' + |-coll /f + | |-coll /fo + | | |-coll /foo + | | | |-coll /foo/b + | | | | |-coll /foo/ba + | | | | | |-coll /foo/bar + | | | | | | |-route bar /foo/bar + | | | | | | |-route bar2 /foo/bar + | | | |-coll /foo/q + | | | | |-coll /foo/qu + | | | | | |-coll /foo/qux + | | | | | | |-route qux /foo/qux + | | | |-coll /foo/b + | | | | |-coll /foo/ba + | | | | | |-coll /foo/bar + | | | | | | |-route bar3 /foo/bar + +EOF; + + $this->assertSame($expect, $this->collectionToString($result->getRoot(), ' ')); + } + + private function collectionToString(DumperCollection $collection, $prefix) + { + $string = ''; + foreach ($collection as $route) { + if ($route instanceof DumperCollection) { + $string .= sprintf("%s|-coll %s\n", $prefix, $route->getPrefix()); + $string .= $this->collectionToString($route, $prefix.'| '); + } else { + $string .= sprintf("%s|-route %s %s\n", $prefix, $route->getName(), $route->getRoute()->getPattern()); + } + } + + return $string; + } +} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index ee113851cd33..9c15be5642bf 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -40,7 +40,6 @@ public function testDump(RouteCollection $collection, $fixture, $options = array $basePath = __DIR__.'/../../Fixtures/dumper/'; $dumper = new PhpMatcherDumper($collection); - $this->assertStringEqualsFile($basePath.$fixture, $dumper->dump($options), '->dump() correctly dumps routes as optimized PHP code.'); } @@ -156,6 +155,59 @@ public function getRouteCollections() $collection1->add('foo4', new Route('/{foo}')); $collection->addCollection($collection1, '/aba'); + // prefix and hostname + + $collection1 = new RouteCollection(); + + $route1 = new Route('/route1', array(), array(), array(), 'a.example.com'); + $collection1->add('route1', $route1); + + $collection2 = new RouteCollection(); + + $route2 = new Route('/c2/route2', array(), array(), array(), 'a.example.com'); + $collection1->add('route2', $route2); + + $route3 = new Route('/c2/route3', array(), array(), array(), 'b.example.com'); + $collection1->add('route3', $route3); + + $route4 = new Route('/route4', array(), array(), array(), 'a.example.com'); + $collection1->add('route4', $route4); + + $route5 = new Route('/route5', array(), array(), array(), 'c.example.com'); + $collection1->add('route5', $route5); + + $route6 = new Route('/route6', array(), array(), array(), null); + $collection1->add('route6', $route6); + + $collection->addCollection($collection1); + + // hostname and variables + + $collection1 = new RouteCollection(); + + $route11 = new Route('/route11', array(), array(), array(), '{var1}.example.com'); + $collection1->add('route11', $route11); + + $route12 = new Route('/route12', array('var1' => 'val'), array(), array(), '{var1}.example.com'); + $collection1->add('route12', $route12); + + $route13 = new Route('/route13/{name}', array(), array(), array(), '{var1}.example.com'); + $collection1->add('route13', $route13); + + $route14 = new Route('/route14/{name}', array('var1' => 'val'), array(), array(), '{var1}.example.com'); + $collection1->add('route14', $route14); + + $route15 = new Route('/route15/{name}', array(), array(), array(), 'c.example.com'); + $collection1->add('route15', $route15); + + $route16 = new Route('/route16/{name}', array('var1' => 'val'), array(), array(), null); + $collection1->add('route16', $route16); + + $route17 = new Route('/route17', array(), array(), array(), null); + $collection1->add('route17', $route17); + + $collection->addCollection($collection1); + // multiple sub-collections with a single route and a prefix each $collection1 = new RouteCollection(); $collection1->add('a', new Route('/a...')); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index 31069b2af7f1..64ef2d339b9a 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -158,6 +158,15 @@ public function testMatchWithDynamicPrefix() $this->assertEquals(array('_locale' => 'fr', '_route' => 'foo', 'foo' => 'foo'), $matcher->match('/fr/b/foo')); } + public function testMatchSpecialRouteName() + { + $collection = new RouteCollection(); + $collection->add('$péß^a|', new Route('/bar')); + + $matcher = new UrlMatcher($collection, new RequestContext()); + $this->assertEquals(array('_route' => '$péß^a|'), $matcher->match('/bar')); + } + public function testMatchNonAlpha() { $collection = new RouteCollection(); @@ -214,6 +223,15 @@ public function testMatchRegression() } } + public function testDefaultRequirementForOptionalVariables() + { + $coll = new RouteCollection(); + $coll->add('test', new Route('/{page}.{_format}', array('page' => 'index', '_format' => 'html'))); + + $matcher = new UrlMatcher($coll, new RequestContext()); + $this->assertEquals(array('page' => 'my-page', '_format' => 'xml', '_route' => 'test'), $matcher->match('/my-page.xml')); + } + public function testMatchingIsEager() { $coll = new RouteCollection(); @@ -223,6 +241,83 @@ public function testMatchingIsEager() $this->assertEquals(array('foo' => 'text1-text2-text3', 'bar' => 'text4', '_route' => 'test'), $matcher->match('/text1-text2-text3-text4-')); } + public function testAdjacentVariables() + { + $coll = new RouteCollection(); + $coll->add('test', new Route('/{w}{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => 'y|Y'))); + + $matcher = new UrlMatcher($coll, new RequestContext()); + // 'w' eagerly matches as much as possible and the other variables match the remaining chars. + // This also shows that the variables w-z must all exclude the separating char (the dot '.' in this case) by default requirement. + // Otherwise they would also consume '.xml' and _format would never match as it's an optional variable. + $this->assertEquals(array('w' => 'wwwww', 'x' => 'x', 'y' => 'Y', 'z' => 'Z','_format' => 'xml', '_route' => 'test'), $matcher->match('/wwwwwxYZ.xml')); + // As 'y' has custom requirement and can only be of value 'y|Y', it will leave 'ZZZ' to variable z. + // So with carefully chosen requirements adjacent variables, can be useful. + $this->assertEquals(array('w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'ZZZ','_format' => 'html', '_route' => 'test'), $matcher->match('/wwwwwxyZZZ')); + // z and _format are optional. + $this->assertEquals(array('w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'default-z','_format' => 'html', '_route' => 'test'), $matcher->match('/wwwwwxy')); + + $this->setExpectedException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $matcher->match('/wxy.html'); + } + + public function testOptionalVariableWithNoRealSeparator() + { + $coll = new RouteCollection(); + $coll->add('test', new Route('/get{what}', array('what' => 'All'))); + $matcher = new UrlMatcher($coll, new RequestContext()); + + $this->assertEquals(array('what' => 'All', '_route' => 'test'), $matcher->match('/get')); + $this->assertEquals(array('what' => 'Sites', '_route' => 'test'), $matcher->match('/getSites')); + + // Usually the character in front of an optional parameter can be left out, e.g. with pattern '/get/{what}' just '/get' would match. + // But here the 't' in 'get' is not a separating character, so it makes no sense to match without it. + $this->setExpectedException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $matcher->match('/ge'); + } + + public function testRequiredVariableWithNoRealSeparator() + { + $coll = new RouteCollection(); + $coll->add('test', new Route('/get{what}Suffix')); + $matcher = new UrlMatcher($coll, new RequestContext()); + + $this->assertEquals(array('what' => 'Sites', '_route' => 'test'), $matcher->match('/getSitesSuffix')); + } + + public function testDefaultRequirementOfVariable() + { + $coll = new RouteCollection(); + $coll->add('test', new Route('/{page}.{_format}')); + $matcher = new UrlMatcher($coll, new RequestContext()); + + $this->assertEquals(array('page' => 'index', '_format' => 'mobile.html', '_route' => 'test'), $matcher->match('/index.mobile.html')); + } + + /** + * @expectedException Symfony\Component\Routing\Exception\ResourceNotFoundException + */ + public function testDefaultRequirementOfVariableDisallowsSlash() + { + $coll = new RouteCollection(); + $coll->add('test', new Route('/{page}.{_format}')); + $matcher = new UrlMatcher($coll, new RequestContext()); + + $matcher->match('/index.sl/ash'); + } + + /** + * @expectedException Symfony\Component\Routing\Exception\ResourceNotFoundException + */ + public function testDefaultRequirementOfVariableDisallowsNextSeparator() + { + $coll = new RouteCollection(); + $coll->add('test', new Route('/{page}.{_format}', array(), array('_format' => 'html|xml'))); + $matcher = new UrlMatcher($coll, new RequestContext()); + + $matcher->match('/do.t.html'); + } + /** * @expectedException Symfony\Component\Routing\Exception\ResourceNotFoundException */ @@ -242,4 +337,39 @@ public function testDecodeOnce() $matcher = new UrlMatcher($coll, new RequestContext()); $this->assertEquals(array('foo' => 'bar%23', '_route' => 'foo'), $matcher->match('/foo/bar%2523')); } + + public function testWithHostname() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo/{foo}', array(), array(), array(), '{locale}.example.com')); + + $matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com')); + $this->assertEquals(array('foo' => 'bar', '_route' => 'foo', 'locale' => 'en'), $matcher->match('/foo/bar')); + } + + public function testWithHostnameOnRouteCollection() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo/{foo}')); + $coll->add('bar', new Route('/bar/{foo}', array(), array(), array(), '{locale}.example.net')); + $coll->setHostnamePattern('{locale}.example.com'); + + $matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com')); + $this->assertEquals(array('foo' => 'bar', '_route' => 'foo', 'locale' => 'en'), $matcher->match('/foo/bar')); + + $matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com')); + $this->assertEquals(array('foo' => 'bar', '_route' => 'bar', 'locale' => 'en'), $matcher->match('/bar/bar')); + } + + /** + * @expectedException Symfony\Component\Routing\Exception\ResourceNotFoundException + */ + public function testWithOutHostnameHostnameDoesNotMatch() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo/{foo}', array(), array(), array(), '{locale}.example.com')); + + $matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'example.com')); + $matcher->match('/foo/bar'); + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 792e65daccfa..08cd7a9a26f2 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -27,16 +27,6 @@ public function testRoute() $this->assertNull($collection->get('bar'), '->get() returns null if a route does not exist'); } - /** - * @expectedException \InvalidArgumentException - */ - public function testAddInvalidRoute() - { - $collection = new RouteCollection(); - $route = new Route('/foo'); - $collection->add('f o o', $route); - } - public function testOverriddenRoute() { $collection = new RouteCollection(); @@ -140,14 +130,19 @@ public function testAddPrefix() { $collection = new RouteCollection(); $collection->add('foo', $foo = new Route('/foo')); - $collection->add('bar', $bar = new Route('/bar')); + $collection2 = new RouteCollection(); + $collection2->add('bar', $bar = new Route('/bar')); + $collection->addCollection($collection2); + $this->assertSame('', $collection->getPrefix(), '->getPrefix() is initialized with ""'); + $collection->addPrefix(' / '); + $this->assertSame('', $collection->getPrefix(), '->addPrefix() trims the prefix and a single slash has no effect'); $collection->addPrefix('/{admin}', array('admin' => 'admin'), array('admin' => '\d+'), array('foo' => 'bar')); $this->assertEquals('/{admin}/foo', $collection->get('foo')->getPattern(), '->addPrefix() adds a prefix to all routes'); $this->assertEquals('/{admin}/bar', $collection->get('bar')->getPattern(), '->addPrefix() adds a prefix to all routes'); - $this->assertEquals(array('admin' => 'admin'), $collection->get('foo')->getDefaults(), '->addPrefix() adds a prefix to all routes'); - $this->assertEquals(array('admin' => 'admin'), $collection->get('bar')->getDefaults(), '->addPrefix() adds a prefix to all routes'); - $this->assertEquals(array('admin' => '\d+'), $collection->get('foo')->getRequirements(), '->addPrefix() adds a prefix to all routes'); - $this->assertEquals(array('admin' => '\d+'), $collection->get('bar')->getRequirements(), '->addPrefix() adds a prefix to all routes'); + $this->assertEquals(array('admin' => 'admin'), $collection->get('foo')->getDefaults(), '->addPrefix() adds defaults to all routes'); + $this->assertEquals(array('admin' => 'admin'), $collection->get('bar')->getDefaults(), '->addPrefix() adds defaults to all routes'); + $this->assertEquals(array('admin' => '\d+'), $collection->get('foo')->getRequirements(), '->addPrefix() adds requirements to all routes'); + $this->assertEquals(array('admin' => '\d+'), $collection->get('bar')->getRequirements(), '->addPrefix() adds requirements to all routes'); $this->assertEquals( array('foo' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), $collection->get('foo')->getOptions(), '->addPrefix() adds an option to all routes' @@ -158,6 +153,10 @@ public function testAddPrefix() ); $collection->addPrefix('0'); $this->assertEquals('/0/{admin}', $collection->getPrefix(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash'); + $collection->addPrefix('/ /'); + $this->assertSame('/ /0/{admin}', $collection->getPrefix(), '->addPrefix() can handle spaces if desired'); + $this->assertSame('/ /0/{admin}/foo', $collection->get('foo')->getPattern(), 'the route pattern is in synch with the collection prefix'); + $this->assertSame('/ /0/{admin}/bar', $collection->get('bar')->getPattern(), 'the route pattern in a sub-collection is in synch with the collection prefix'); } public function testAddPrefixOverridesDefaultsAndRequirements() @@ -288,4 +287,18 @@ public function testPatternDoesNotChangeWhenDefinitionOrderChanges() $this->assertEquals($rootCollection_A, $rootCollection_B); } + + public function testSetHostnamePattern() + { + $collection = new RouteCollection(); + $routea = new Route('/a'); + $routeb = new Route('/b', array(), array(), array(), '{locale}.example.net'); + $collection->add('a', $routea); + $collection->add('b', $routeb); + + $collection->setHostnamePattern('{locale}.example.com'); + + $this->assertEquals('{locale}.example.com', $routea->getHostnamePattern()); + $this->assertEquals('{locale}.example.com', $routeb->getHostnamePattern()); + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php index 5288ca68fa2c..93321051a259 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -43,82 +43,109 @@ public function provideCompileData() array( 'Route with a variable', array('/foo/{bar}'), - '/foo', '#^/foo/(?<bar>[^/]+)$#s', array('bar'), array( - array('variable', '/', '[^/]+', 'bar'), + '/foo', '#^/foo/(?P<bar>[^/]++)$#s', array('bar'), array( + array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), )), array( 'Route with a variable that has a default value', array('/foo/{bar}', array('bar' => 'bar')), - '/foo', '#^/foo(?:/(?<bar>[^/]+))?$#s', array('bar'), array( - array('variable', '/', '[^/]+', 'bar'), + '/foo', '#^/foo(?:/(?P<bar>[^/]++))?$#s', array('bar'), array( + array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), )), array( 'Route with several variables', array('/foo/{bar}/{foobar}'), - '/foo', '#^/foo/(?<bar>[^/]+)/(?<foobar>[^/]+)$#s', array('bar', 'foobar'), array( - array('variable', '/', '[^/]+', 'foobar'), - array('variable', '/', '[^/]+', 'bar'), + '/foo', '#^/foo/(?P<bar>[^/]++)/(?P<foobar>[^/]++)$#s', array('bar', 'foobar'), array( + array('variable', '/', '[^/]++', 'foobar'), + array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), )), array( 'Route with several variables that have default values', array('/foo/{bar}/{foobar}', array('bar' => 'bar', 'foobar' => '')), - '/foo', '#^/foo(?:/(?<bar>[^/]+)(?:/(?<foobar>[^/]+))?)?$#s', array('bar', 'foobar'), array( - array('variable', '/', '[^/]+', 'foobar'), - array('variable', '/', '[^/]+', 'bar'), + '/foo', '#^/foo(?:/(?P<bar>[^/]++)(?:/(?P<foobar>[^/]++))?)?$#s', array('bar', 'foobar'), array( + array('variable', '/', '[^/]++', 'foobar'), + array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), )), array( 'Route with several variables but some of them have no default values', array('/foo/{bar}/{foobar}', array('bar' => 'bar')), - '/foo', '#^/foo/(?<bar>[^/]+)/(?<foobar>[^/]+)$#s', array('bar', 'foobar'), array( - array('variable', '/', '[^/]+', 'foobar'), - array('variable', '/', '[^/]+', 'bar'), + '/foo', '#^/foo/(?P<bar>[^/]++)/(?P<foobar>[^/]++)$#s', array('bar', 'foobar'), array( + array('variable', '/', '[^/]++', 'foobar'), + array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), )), array( 'Route with an optional variable as the first segment', array('/{bar}', array('bar' => 'bar')), - '', '#^/(?<bar>[^/]+)?$#s', array('bar'), array( - array('variable', '/', '[^/]+', 'bar'), + '', '#^/(?P<bar>[^/]++)?$#s', array('bar'), array( + array('variable', '/', '[^/]++', 'bar'), + )), + + array( + 'Route with a requirement of 0', + array('/{bar}', array('bar' => null), array('bar' => '0')), + '', '#^/(?P<bar>0)?$#s', array('bar'), array( + array('variable', '/', '0', 'bar'), )), array( 'Route with an optional variable as the first segment with requirements', array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')), - '', '#^/(?<bar>(foo|bar))?$#s', array('bar'), array( + '', '#^/(?P<bar>(foo|bar))?$#s', array('bar'), array( array('variable', '/', '(foo|bar)', 'bar'), )), array( 'Route with only optional variables', array('/{foo}/{bar}', array('foo' => 'foo', 'bar' => 'bar')), - '', '#^/(?<foo>[^/]+)?(?:/(?<bar>[^/]+))?$#s', array('foo', 'bar'), array( - array('variable', '/', '[^/]+', 'bar'), - array('variable', '/', '[^/]+', 'foo'), + '', '#^/(?P<foo>[^/]++)?(?:/(?P<bar>[^/]++))?$#s', array('foo', 'bar'), array( + array('variable', '/', '[^/]++', 'bar'), + array('variable', '/', '[^/]++', 'foo'), )), array( 'Route with a variable in last position', array('/foo-{bar}'), - '/foo', '#^/foo\-(?<bar>[^\-]+)$#s', array('bar'), array( - array('variable', '-', '[^\-]+', 'bar'), + '/foo', '#^/foo\-(?P<bar>[^/]++)$#s', array('bar'), array( + array('variable', '-', '[^/]++', 'bar'), array('text', '/foo'), )), + array( + 'Route with nested placeholders', + array('/{static{var}static}'), + '/{static', '#^/\{static(?P<var>[^/]+)static\}$#s', array('var'), array( + array('text', 'static}'), + array('variable', '', '[^/]+', 'var'), + array('text', '/{static'), + )), + + array( + 'Route without separator between variables', + array('/{w}{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => '(y|Y)')), + '', '#^/(?P<w>[^/\.]+)(?P<x>[^/\.]+)(?P<y>(y|Y))(?:(?P<z>[^/\.]++)(?:\.(?P<_format>[^/]++))?)?$#s', array('w', 'x', 'y', 'z', '_format'), array( + array('variable', '.', '[^/]++', '_format'), + array('variable', '', '[^/\.]++', 'z'), + array('variable', '', '(y|Y)', 'y'), + array('variable', '', '[^/\.]+', 'x'), + array('variable', '/', '[^/\.]+', 'w'), + )), + array( 'Route with a format', array('/foo/{bar}.{_format}'), - '/foo', '#^/foo/(?<bar>[^/\.]+)\.(?<_format>[^\.]+)$#s', array('bar', '_format'), array( - array('variable', '.', '[^\.]+', '_format'), - array('variable', '/', '[^/\.]+', 'bar'), + '/foo', '#^/foo/(?P<bar>[^/\.]++)\.(?P<_format>[^/]++)$#s', array('bar', '_format'), array( + array('variable', '.', '[^/]++', '_format'), + array('variable', '/', '[^/\.]++', 'bar'), array('text', '/foo'), )), ); @@ -133,4 +160,94 @@ public function testRouteWithSameVariableTwice() $compiled = $route->compile(); } + + /** + * @dataProvider getNumericVariableNames + * @expectedException \DomainException + */ + public function testRouteWithNumericVariableName($name) + { + $route = new Route('/{'. $name . '}'); + $route->compile(); + } + + public function getNumericVariableNames() + { + return array( + array('09'), + array('123'), + array('1e2') + ); + } + + /** + * @dataProvider provideCompileWithHostnameData + */ + public function testCompileWithHostname($name, $arguments, $prefix, $regex, $variables, $pathVariables, $tokens, $hostnameRegex, $hostnameVariables, $hostnameTokens) + { + $r = new \ReflectionClass('Symfony\\Component\\Routing\\Route'); + $route = $r->newInstanceArgs($arguments); + + $compiled = $route->compile(); + $this->assertEquals($prefix, $compiled->getStaticPrefix(), $name.' (static prefix)'); + $this->assertEquals($regex, str_replace(array("\n", ' '), '', $compiled->getRegex()), $name.' (regex)'); + $this->assertEquals($variables, $compiled->getVariables(), $name.' (variables)'); + $this->assertEquals($pathVariables, $compiled->getPathVariables(), $name.' (path variables)'); + $this->assertEquals($tokens, $compiled->getTokens(), $name.' (tokens)'); + $this->assertEquals($hostnameRegex, str_replace(array("\n", ' '), '', $compiled->getHostnameRegex()), $name.' (hostname regex)'); + $this->assertEquals($hostnameVariables, $compiled->getHostnameVariables(), $name.' (hostname variables)'); + $this->assertEquals($hostnameTokens, $compiled->getHostnameTokens(), $name.' (hostname tokens)'); + } + + public function provideCompileWithHostnameData() + { + return array( + array( + 'Route with hostname pattern', + array('/hello', array(), array(), array(), 'www.example.com'), + '/hello', '#^/hello$#s', array(), array(), array( + array('text', '/hello'), + ), + '#^www\.example\.com$#s', array(), array( + array('text', 'www.example.com'), + ), + ), + array( + 'Route with hostname pattern and some variables', + array('/hello/{name}', array(), array(), array(), 'www.example.{tld}'), + '/hello', '#^/hello/(?P<name>[^/]++)$#s', array('tld', 'name'), array('name'), array( + array('variable', '/', '[^/]++', 'name'), + array('text', '/hello'), + ), + '#^www\.example\.(?P<tld>[^\.]++)$#s', array('tld'), array( + array('variable', '.', '[^\.]++', 'tld'), + array('text', 'www.example'), + ), + ), + array( + 'Route with variable at begining of hostname', + array('/hello', array(), array(), array(), '{locale}.example.{tld}'), + '/hello', '#^/hello$#s', array('locale', 'tld'), array(), array( + array('text', '/hello'), + ), + '#^(?P<locale>[^\.]++)\.example\.(?P<tld>[^\.]++)$#s', array('locale', 'tld'), array( + array('variable', '.', '[^\.]++', 'tld'), + array('text', '.example'), + array('variable', '', '[^\.]++', 'locale'), + ), + ), + array( + 'Route with hostname variables that has a default value', + array('/hello', array('locale' => 'a', 'tld' => 'b'), array(), array(), '{locale}.example.{tld}'), + '/hello', '#^/hello$#s', array('locale', 'tld'), array(), array( + array('text', '/hello'), + ), + '#^(?P<locale>[^\.]++)\.example\.(?P<tld>[^\.]++)$#s', array('locale', 'tld'), array( + array('variable', '.', '[^\.]++', 'tld'), + array('text', '.example'), + array('variable', '', '[^\.]++', 'locale'), + ), + ), + ); + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php index 8e466826dae3..1a11d7440e66 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php @@ -17,11 +17,12 @@ class RouteTest extends \PHPUnit_Framework_TestCase { public function testConstructor() { - $route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar')); + $route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'), '{locale}.example.com'); $this->assertEquals('/{foo}', $route->getPattern(), '__construct() takes a pattern as its first argument'); $this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '__construct() takes defaults as its second argument'); $this->assertEquals(array('foo' => '\d+'), $route->getRequirements(), '__construct() takes requirements as its third argument'); $this->assertEquals('bar', $route->getOption('foo'), '__construct() takes options as its fourth argument'); + $this->assertEquals('{locale}.example.com', $route->getHostnamePattern(), '__construct() takes a hostname pattern as its fifth argument'); } public function testPattern() @@ -34,6 +35,8 @@ public function testPattern() $route->setPattern('bar'); $this->assertEquals('/bar', $route->getPattern(), '->setPattern() adds a / at the beginning of the pattern if needed'); $this->assertEquals($route, $route->setPattern(''), '->setPattern() implements a fluent interface'); + $route->setPattern('//path'); + $this->assertEquals('/path', $route->getPattern(), '->setPattern() does not allow two slahes "//" at the beginning of the pattern as it would be confused with a network path when generating the path from the route'); } public function testOptions() @@ -112,10 +115,20 @@ public function getInvalidRequirements() { return array( array(''), - array(array()) + array(array()), + array('^$'), + array('^'), + array('$') ); } + public function testHostnamePattern() + { + $route = new Route('/'); + $route->setHostnamePattern('{locale}.example.net'); + $this->assertEquals('{locale}.example.net', $route->getHostnamePattern(), '->setHostnamePattern() sets the hostname pattern'); + } + public function testCompile() { $route = new Route('/{foo}'); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/bootstrap.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/bootstrap.php deleted file mode 100644 index 23303c04bb7e..000000000000 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/bootstrap.php +++ /dev/null @@ -1,22 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Routing')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Routing')).'.php')) { - require_once $file; - } - } -}); - -if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) { - require_once $loader; -} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json index 09706a6ff3a5..d3f653b761c8 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json @@ -19,24 +19,24 @@ "php": ">=5.3.3" }, "require-dev": { - "symfony/config": "2.1.*", - "symfony/yaml": "2.1.*", - "symfony/http-kernel": "2.1.*", + "symfony/config": "2.2.*", + "symfony/yaml": "2.2.*", + "symfony/http-kernel": "2.2.*", "doctrine/common": ">=2.2,<2.4-dev" }, "suggest": { - "symfony/config": "self.version", - "symfony/yaml": "self.version", + "symfony/config": "2.2.*", + "symfony/yaml": "2.2.*", "doctrine/common": ">=2.2,<2.4-dev" }, "autoload": { - "psr-0": { "Symfony\\Component\\Routing": "" } + "psr-0": { "Symfony\\Component\\Routing\\": "" } }, "target-dir": "Symfony/Component/Routing", "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist b/core/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist index 6d25ebf91f83..830066aab59b 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="Tests/bootstrap.php" + bootstrap="vendor/autoload.php" > <testsuites> <testsuite name="Symfony Routing Component Test Suite"> diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/.gitattributes b/core/vendor/symfony/serializer/Symfony/Component/Serializer/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/.gitignore b/core/vendor/symfony/serializer/Symfony/Component/Serializer/.gitignore new file mode 100644 index 000000000000..44de97a36a6d --- /dev/null +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/.gitignore @@ -0,0 +1,4 @@ +vendor/ +composer.lock +phpunit.xml + diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/DecoderInterface.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/DecoderInterface.php index 21a367803caf..e95271f740b0 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/DecoderInterface.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/DecoderInterface.php @@ -32,6 +32,7 @@ public function decode($data, $format); * Checks whether the serializer can decode from given format * * @param string $format format name + * * @return Boolean */ public function supportsDecoding($format); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/EncoderInterface.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/EncoderInterface.php index b4739edd6a32..4a68ad3fe9ea 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/EncoderInterface.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/EncoderInterface.php @@ -32,6 +32,7 @@ public function encode($data, $format); * Checks whether the serializer can encode to given format * * @param string $format format name + * * @return Boolean */ public function supportsEncoding($format); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php index cb46926111c7..6c0e2b5b3839 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -96,6 +96,7 @@ public function decode($data, $format) * Checks whether the serializer can encode to given format * * @param string $format format name + * * @return Boolean */ public function supportsEncoding($format) @@ -107,6 +108,7 @@ public function supportsEncoding($format) * Checks whether the serializer can decode from given format * * @param string $format format name + * * @return Boolean */ public function supportsDecoding($format) @@ -116,6 +118,7 @@ public function supportsDecoding($format) /** * Sets the root node name + * * @param string $name root node name */ public function setRootNodeName($name) diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index aba4df8d4e48..4510fa0b8006 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -40,6 +40,7 @@ public function denormalize($data, $class, $format = null) * * @param mixed $data Data to normalize. * @param string $format The format being (de-)serialized from or into. + * * @return Boolean */ public function supportsNormalization($data, $format = null) @@ -53,6 +54,7 @@ public function supportsNormalization($data, $format = null) * @param mixed $data Data to denormalize from. * @param string $type The class to which the data should be denormalized. * @param string $format The format being deserialized from. + * * @return Boolean */ public function supportsDenormalization($data, $type, $format = null) diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php index 7c4fd4f8f856..384f9febb668 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php @@ -24,6 +24,7 @@ interface DenormalizerInterface * @param mixed $data data to restore * @param string $class the expected class to instantiate * @param string $format format the given data was extracted from + * * @return object */ public function denormalize($data, $class, $format = null); @@ -34,6 +35,7 @@ public function denormalize($data, $class, $format = null); * @param mixed $data Data to denormalize from. * @param string $type The class to which the data should be denormalized. * @param string $format The format being deserialized from. + * * @return Boolean */ public function supportsDenormalization($data, $type, $format = null); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index 4dfe1770e578..2c5f1b3e874d 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Normalizer; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Exception\RuntimeException; /** @@ -42,12 +43,14 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal * Set normalization callbacks * * @param array $callbacks help normalize the result + * + * @throws InvalidArgumentException if a non-callable callback is set */ public function setCallbacks(array $callbacks) { foreach ($callbacks as $attribute => $callback) { if (!is_callable($callback)) { - throw new \InvalidArgumentException(sprintf('The given callback for attribute "%s" is not callable.', $attribute)); + throw new InvalidArgumentException(sprintf('The given callback for attribute "%s" is not callable.', $attribute)); } } $this->callbacks = $callbacks; @@ -158,6 +161,7 @@ public function supportsDenormalization($data, $type, $format = null) * Checks if the given class has any get{Property} method. * * @param string $class + * * @return Boolean */ private function supports($class) @@ -176,7 +180,8 @@ private function supports($class) /** * Checks if a method's name is get.* and can be called without parameters. * - * @param ReflectionMethod $method the method to check + * @param \ReflectionMethod $method the method to check + * * @return Boolean whether the method is a getter. */ private function isGetMethod(\ReflectionMethod $method) diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php index b7b8e51a7e5a..fb77a836d8d9 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php @@ -31,6 +31,7 @@ interface NormalizableInterface * can use it to normalize objects contained within this object. * @param string|null $format The format is optionally given to be able to normalize differently * based on different output formats. + * * @return array|scalar */ public function normalize(NormalizerInterface $normalizer, $format = null); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php index 7b90d18e1f8b..f0915db2b453 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php @@ -23,6 +23,7 @@ interface NormalizerInterface * * @param object $object object to normalize * @param string $format format the normalization result will be encoded as + * * @return array|scalar */ public function normalize($object, $format = null); @@ -32,6 +33,7 @@ public function normalize($object, $format = null); * * @param mixed $data Data to normalize. * @param string $format The format being (de-)serialized from or into. + * * @return Boolean */ public function supportsNormalization($data, $format = null); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/README.md b/core/vendor/symfony/serializer/Symfony/Component/Serializer/README.md index df74a9a00112..3e808059db4d 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/README.md +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/README.md @@ -10,4 +10,6 @@ Resources You can run the unit tests with the following command: - phpunit + $ cd path/to/Symfony/Component/Serializer/ + $ composer.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php index f2c513baec05..5bdeeada28d7 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php @@ -220,6 +220,7 @@ final public function decode($data, $format) * * @param object $object object to normalize * @param string $format format name, present to give the option to normalizers to act differently based on formats + * * @return array|scalar */ private function normalizeObject($object, $format = null) @@ -250,6 +251,7 @@ private function normalizeObject($object, $format = null) * @param mixed $data data to restore * @param string $class the expected class to instantiate * @param string $format format name, present to give the option to normalizers to act differently based on formats + * * @return object */ private function denormalizeObject($data, $class, $format = null) diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/SerializerInterface.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/SerializerInterface.php index f1879596e177..143179fe7a31 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/SerializerInterface.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/SerializerInterface.php @@ -23,6 +23,7 @@ interface SerializerInterface * * @param mixed $data any data * @param string $format format name + * * @return string */ public function serialize($data, $format); @@ -33,6 +34,8 @@ public function serialize($data, $format); * @param mixed $data * @param string $type * @param string $format + * + * @return object */ public function deserialize($data, $type, $format); } diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/bootstrap.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/bootstrap.php deleted file mode 100644 index 3b0e811a9410..000000000000 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/bootstrap.php +++ /dev/null @@ -1,18 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Serializer')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Serializer')).'.php')) { - require_once $file; - } - } -}); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json b/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json index 1c8feb3050e6..cff1e49cfa4f 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json @@ -19,13 +19,13 @@ "php": ">=5.3.3" }, "autoload": { - "psr-0": { "Symfony\\Component\\Serializer": "" } + "psr-0": { "Symfony\\Component\\Serializer\\": "" } }, "target-dir": "Symfony/Component/Serializer", "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } } } diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/phpunit.xml.dist b/core/vendor/symfony/serializer/Symfony/Component/Serializer/phpunit.xml.dist index c85ffa717a28..691219da83c1 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/phpunit.xml.dist +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="Tests/bootstrap.php" + bootstrap="vendor/autoload.php" > <testsuites> <testsuite name="Symfony Serializer Component Test Suite"> diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/.gitattributes b/core/vendor/symfony/yaml/Symfony/Component/Yaml/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore b/core/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore new file mode 100644 index 000000000000..44de97a36a6d --- /dev/null +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore @@ -0,0 +1,4 @@ +vendor/ +composer.lock +phpunit.xml + diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php index fe9f33ff0f6a..f77545db9563 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php @@ -25,13 +25,13 @@ class Escaper // first to ensure proper escaping because str_replace operates iteratively // on the input arrays. This ordering of the characters avoids the use of strtr, // which performs more slowly. - private static $escapees = array('\\\\', '\\"', + private static $escapees = array('\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9"); - private static $escaped = array('\\"', '\\\\', + private static $escaped = array('\\"', '\\\\', '\\"', "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php index 53952ce1adfd..9b3e6de07958 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php @@ -18,6 +18,6 @@ * * @api */ -class DumpException extends \RuntimeException implements ExceptionInterface +class DumpException extends RuntimeException { } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php index 975fe6d46eb7..a27a005e6f55 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php @@ -18,7 +18,7 @@ * * @api */ -class ParseException extends \RuntimeException implements ExceptionInterface +class ParseException extends RuntimeException { private $parsedFile; private $parsedLine; diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php new file mode 100644 index 000000000000..3573bf15abb8 --- /dev/null +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php @@ -0,0 +1,23 @@ +<?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\Component\Yaml\Exception; + +/** + * Exception class thrown when an error occurs during parsing. + * + * @author Romain Neutron <imprec@gmail.com> + * + * @api + */ +class RuntimeException extends \RuntimeException implements ExceptionInterface +{ +} diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php index f28d89b7e0cb..d09227b2797e 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php @@ -608,11 +608,11 @@ private function isNextLineUnIndentedCollection() } /** - * Returns true if the string is unindented collection item + * Returns true if the string is un-indented collection item * - * @return Boolean Returns true if the string is unindented collection item, false otherwise + * @return Boolean Returns true if the string is un-indented collection item, false otherwise */ - private function isStringUnIndentedCollectionItem($string) + private function isStringUnIndentedCollectionItem() { return (0 === strpos($this->currentLine, '- ')); } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/README.md b/core/vendor/symfony/yaml/Symfony/Component/Yaml/README.md index 34413166991a..0864e49dca05 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/README.md +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/README.md @@ -14,4 +14,6 @@ Resources You can run the unit tests with the following command: - phpunit + $ cd path/to/Symfony/Component/Yaml/ + $ composer.phar install --dev + $ phpunit diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml index 7f17ed5c12cd..09bf86e79027 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml @@ -137,3 +137,11 @@ yaml: | \x41 \u0041 \U00000041" php: | "Fun with \x5C\n\x22 \x07 \x08 \x1B \x0C\n\x0A \x0D \x09 \x0B \x00\n\x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9\nA A A" +--- +test: Double quotes with a line feed +yaml: | + { double: "some value\n \"some quoted string\" and 'some single quotes one'" } +php: | + array( + 'double' => "some value\n \"some quoted string\" and 'some single quotes one'" + ) diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/bootstrap.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/bootstrap.php deleted file mode 100644 index 985f1f22e2c6..000000000000 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/bootstrap.php +++ /dev/null @@ -1,18 +0,0 @@ -<?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. - */ - -spl_autoload_register(function ($class) { - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Yaml')).'.php')) { - require_once $file; - } - } -}); diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php index ac3a576b677b..708f2a18f285 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php @@ -130,7 +130,7 @@ public function unescapeCharacter($value) * * @return string The string with the new encoding * - * @throws \RuntimeException if no suitable encoding function is found (iconv or mbstring) + * @throws RuntimeException if no suitable encoding function is found (iconv or mbstring) */ private function convertEncoding($value, $to, $from) { @@ -140,6 +140,6 @@ private function convertEncoding($value, $to, $from) return iconv($from, $to, $value); } - throw new \RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); + throw new RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); } } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json b/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json index 88460ce34b70..e04dabf3fc22 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json @@ -19,13 +19,13 @@ "php": ">=5.3.3" }, "autoload": { - "psr-0": { "Symfony\\Component\\Yaml": "" } + "psr-0": { "Symfony\\Component\\Yaml\\": "" } }, "target-dir": "Symfony/Component/Yaml", "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } } } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist b/core/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist index d025f9e49a7e..aa77e9de77ce 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="Tests/bootstrap.php" + bootstrap="vendor/autoload.php" > <testsuites> <testsuite name="Symfony Yaml Component Test Suite"> diff --git a/core/vendor/twig/twig/.gitignore b/core/vendor/twig/twig/.gitignore new file mode 100644 index 000000000000..840b78e7e423 --- /dev/null +++ b/core/vendor/twig/twig/.gitignore @@ -0,0 +1,2 @@ +/ext/twig/autom4te.cache/ + diff --git a/core/vendor/twig/twig/CHANGELOG b/core/vendor/twig/twig/CHANGELOG index fd38774eacc8..dcfab94ac61a 100644 --- a/core/vendor/twig/twig/CHANGELOG +++ b/core/vendor/twig/twig/CHANGELOG @@ -1,3 +1,62 @@ +* 1.11.1 (2012-11-11) + + * fixed debug info line numbering (was off by 2) + * fixed escaping when calling a macro inside another one (regression introduced in 1.9.1) + * optimized variable access on PHP 5.4 + * fixed a crash of the C extension when an exception was thrown from a macro called without being imported (using _self.XXX) + +* 1.11.0 (2012-11-07) + + * fixed macro compilation when a variable name is a PHP reserved keyword + * changed the date filter behavior to always apply the default timezone, except if false is passed as the timezone + * fixed bitwise operator precedences + * added the template_from_string function + * fixed default timezone usage for the date function + * optimized the way Twig exceptions are managed (to make them faster) + * added Twig_ExistsLoaderInterface (implementing this interface in your loader make the chain loader much faster) + +* 1.10.3 (2012-10-19) + + * fixed wrong template location in some error messages + * reverted a BC break introduced in 1.10.2 + * added a split filter + +* 1.10.2 (2012-10-15) + + * fixed macro calls on PHP 5.4 + +* 1.10.1 (2012-10-15) + + * made a speed optimization to macro calls when imported via the "import" tag + * fixed C extension compilation on Windows + * fixed a segfault in the C extension when using DateTime objects + +* 1.10.0 (2012-09-28) + + * extracted functional tests framework to make it reusable for third-party extensions + * added namespaced templates support in Twig_Loader_Filesystem + * added Twig_Loader_Filesystem::prependPath() + * fixed an error when a token parser pass a closure as a test to the subparse() method + +* 1.9.2 (2012-08-25) + + * fixed the in operator for objects that contain circular references + * fixed the C extension when accessing a public property of an object implementing the \ArrayAccess interface + +* 1.9.1 (2012-07-22) + + * optimized macro calls when auto-escaping is on + * fixed wrong parent class for Twig_Function_Node + * made Twig_Loader_Chain more explicit about problems + +* 1.9.0 (2012-07-13) + + * made the parsing independent of the template loaders + * fixed exception trace when an error occurs when rendering a child template + * added escaping strategies for CSS, URL, and HTML attributes + * fixed nested embed tag calls + * added the date_modify filter + * 1.8.3 (2012-06-17) * fixed paths in the filesystem loader when passing a path that ends with a slash or a backslash diff --git a/core/vendor/twig/twig/composer.json b/core/vendor/twig/twig/composer.json index 9ca80fc9854a..3bbc5cab1be7 100644 --- a/core/vendor/twig/twig/composer.json +++ b/core/vendor/twig/twig/composer.json @@ -25,7 +25,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.11-dev" } } } diff --git a/core/vendor/twig/twig/doc/advanced.rst b/core/vendor/twig/twig/doc/advanced.rst index 0b33bead2c3f..4be84ed36d6f 100644 --- a/core/vendor/twig/twig/doc/advanced.rst +++ b/core/vendor/twig/twig/doc/advanced.rst @@ -61,7 +61,8 @@ Now, let's use a ``lipsum`` *filter*: Again, it works, but it looks weird. A filter transforms the passed value to something else but here we use the value to indicate the number of words to -generate. +generate (so, ``40`` is an argument of the filter, not the value we want to +transform). Next, let's use a ``lipsum`` *function*: @@ -243,8 +244,10 @@ case, set the ``is_safe`` option:: $filter = new Twig_Filter_Function('nl2br', array('is_safe' => array('html'))); -Some filters may have to work on already escaped or safe values. In such a -case, set the ``pre_escape`` option:: +Some filters may need to work on input that is already escaped or safe, for +example when adding (safe) html tags to originally unsafe output. In such a +case, set the ``pre_escape`` option to escape the input data before it is run +through your filter:: $filter = new Twig_Filter_Function('somefilter', array('pre_escape' => 'html', 'is_safe' => array('html'))); @@ -829,5 +832,59 @@ The ``getTests()`` methods allows to add new test functions:: // ... } +Testing an Extension +-------------------- + +.. versionadded:: 1.10 + Support for functional tests was added in Twig 1.10. + +Functional Tests +~~~~~~~~~~~~~~~~ + +You can create functional tests for extensions simply by creating the +following file structure in your test directory:: + + Fixtures/ + filters/ + foo.test + bar.test + functions/ + foo.test + bar.test + tags/ + foo.test + bar.test + IntegrationTest.php + +The ``IntegrationTest.php`` file should look like this:: + + class Project_Tests_IntegrationTest extends Twig_Test_IntegrationTestCase + { + public function getExtensions() + { + return array( + new Project_Twig_Extension1(), + new Project_Twig_Extension2(), + ); + } + + public function getFixturesDir() + { + return dirname(__FILE__).'/Fixtures/'; + } + } + +Fixtures examples can be found within the Twig repository +`tests/Twig/Fixtures`_ directory. + +Node Tests +~~~~~~~~~~ + +Testing the node visitors can be complex, so extend your test cases from +``Twig_Test_NodeTestCase``. Examples can be found in the Twig repository +`tests/Twig/Node`_ directory. + .. _`spl_autoload_register()`: http://www.php.net/spl_autoload_register -.. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php +.. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php +.. _`tests/Twig/Fixtures`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Fixtures +.. _`tests/Twig/Node`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Node diff --git a/core/vendor/twig/twig/doc/api.rst b/core/vendor/twig/twig/doc/api.rst index a4620666bbb4..fbcc8bc74e19 100644 --- a/core/vendor/twig/twig/doc/api.rst +++ b/core/vendor/twig/twig/doc/api.rst @@ -96,10 +96,11 @@ The following options are available: * ``autoescape``: If set to ``true``, auto-escaping will be enabled by default for all templates (default to ``true``). As of Twig 1.8, you can set the - escaping strategy to use (``html``, ``js``, ``false`` to disable, or a PHP - callback that takes the template "filename" and must return the escaping - strategy to use -- the callback cannot be a function name to avoid collision - with built-in escaping strategies). + escaping strategy to use (``html``, ``js``, ``false`` to disable). + As of Twig 1.9, you can set the escaping strategy to use (``css``, ``url``, + ``html_attr``, or a PHP callback that takes the template "filename" and must + return the escaping strategy to use -- the callback cannot be a function name + to avoid collision with built-in escaping strategies). * ``optimizations``: A flag that indicates which optimizations to apply (default to ``-1`` -- all optimizations are enabled; set it to ``0`` to @@ -125,30 +126,76 @@ Built-in Loaders Here is a list of the built-in loaders Twig provides: -* ``Twig_Loader_Filesystem``: Loads templates from the file system. This - loader can find templates in folders on the file system and is the preferred - way to load them:: +``Twig_Loader_Filesystem`` +.......................... - $loader = new Twig_Loader_Filesystem($templateDir); +.. versionadded:: 1.10 + The ``prependPath()`` and support for namespaces were added in Twig 1.10. - It can also look for templates in an array of directories:: +``Twig_Loader_Filesystem`` loads templates from the file system. This loader +can find templates in folders on the file system and is the preferred way to +load them:: - $loader = new Twig_Loader_Filesystem(array($templateDir1, $templateDir2)); + $loader = new Twig_Loader_Filesystem($templateDir); - With such a configuration, Twig will first look for templates in - ``$templateDir1`` and if they do not exist, it will fallback to look for - them in the ``$templateDir2``. +It can also look for templates in an array of directories:: -* ``Twig_Loader_String``: Loads templates from a string. It's a dummy loader - as you pass it the source code directly:: + $loader = new Twig_Loader_Filesystem(array($templateDir1, $templateDir2)); - $loader = new Twig_Loader_String(); +With such a configuration, Twig will first look for templates in +``$templateDir1`` and if they do not exist, it will fallback to look for them +in the ``$templateDir2``. -* ``Twig_Loader_Array``: Loads a template from a PHP array. It's passed an - array of strings bound to template names. This loader is useful for unit - testing:: +You can add or prepend paths via the ``addPath()`` and ``prependPath()`` +methods:: - $loader = new Twig_Loader_Array($templates); + $loader->addPath($templateDir3); + $loader->prependPath($templateDir4); + +The filesystem loader also supports namespaced templates. This allows to group +your templates under different namespaces which have their own template paths. + +When using the ``setPaths()``, ``addPath()``, and ``prependPath()`` methods, +specify the namespace as the second argument (when not specified, these +methods act on the "main" namespace):: + + $loader->addPath($templateDir, 'admin'); + +Namespaced templates can be accessed via the special +``@namespace_name/template_path`` notation:: + + $twig->render('@admin/index.html', array()); + +``Twig_Loader_String`` +...................... + +``Twig_Loader_String`` loads templates from strings. It's a dummy loader as +the template reference is the template source code:: + + $loader = new Twig_Loader_String(); + $twig = new Twig_Environment($loader); + + echo $twig->render('Hello {{ name }}!', array('name' => 'Fabien')); + +This loader should only be used for unit testing as it has severe limitations: +several tags, like ``extends`` or ``include`` do not make sense to use as the +reference to the template is the template source code itself. + +``Twig_Loader_Array`` +..................... + +``Twig_Loader_Array`` loads a template from a PHP array. It's passed an array +of strings bound to template names:: + + $loader = new Twig_Loader_Array(array( + 'index.html' => 'Hello {{ name }}!', + )); + $twig = new Twig_Environment($loader); + + echo $twig->render('index.html', array('name' => 'Fabien')); + +This loader is very useful for unit testing. It can also be used for small +projects where storing all templates in a single PHP file might make sense. .. tip:: @@ -158,6 +205,35 @@ Here is a list of the built-in loaders Twig provides: don't want to see your cache grows out of control, you need to take care of clearing the old cache file by yourself. +``Twig_Loader_Chain`` +..................... + +``Twig_Loader_Chain`` delegates the loading of templates to other loaders:: + + $loader1 = new Twig_Loader_Array(array( + 'base.html' => '{% block content %}{% endblock %}', + )); + $loader2 = new Twig_Loader_Array(array( + 'index.html' => '{% extends "base.twig" %}{% block content %}Hello {{ name }}{% endblock %}', + 'base.html' => 'Will never be loaded', + )); + + $loader = new Twig_Loader_Chain(array($loader1, $loader2)); + + $twig = new Twig_Environment($loader); + +When looking for a template, Twig will try each loader in turn and it will +return as soon as the template is found. When rendering the ``index.html`` +template from the above example, Twig will load it with ``$loader2`` but the +``base.html`` template will be loaded from ``$loader1``. + +``Twig_Loader_Chain`` accepts any loader that implements +``Twig_LoaderInterface``. + +.. note:: + + You can also add loaders via the ``addLoader()`` method. + Create your own Loader ~~~~~~~~~~~~~~~~~~~~~~ @@ -215,6 +291,11 @@ As an example, here is how the built-in ``Twig_Loader_String`` reads:: The ``isFresh()`` method must return ``true`` if the current cached template is still fresh, given the last modification time, or ``false`` otherwise. +.. tip:: + + As of Twig 1.11.0, you can also implement ``Twig_ExistsLoaderInterface`` + to make your loader faster when used with the chain loader. + Using Extensions ---------------- @@ -269,6 +350,13 @@ The ``core`` extension defines all the core features of Twig: * ``from`` * ``set`` * ``spaceless`` + * ``autoescape`` + * ``do`` + * ``embed`` + * ``flush`` + * ``raw`` + * ``sandbox`` + * ``use`` * Filters: @@ -291,6 +379,14 @@ The ``core`` extension defines all the core features of Twig: * ``keys`` * ``escape`` * ``e`` + * ``abs`` + * ``convert_encoding`` + * ``date_modify`` + * ``nl2br`` + * ``number_format`` + * ``raw`` + * ``slice`` + * ``trim`` * Functions: @@ -299,6 +395,10 @@ The ``core`` extension defines all the core features of Twig: * ``cycle`` * ``parent`` * ``block`` + * ``attribute`` + * ``date`` + * ``dump`` + * ``random`` * Tests: @@ -310,6 +410,7 @@ The ``core`` extension defines all the core features of Twig: * ``divisibleby`` * ``constant`` * ``empty`` + * ``iterable`` Escaper Extension ~~~~~~~~~~~~~~~~~ @@ -395,10 +496,10 @@ The escaping rules are implemented as follows: .. code-block:: jinja - {% autoescape true js %} - {{ var|escape('html') }} {# will be escaped for html and javascript #} - {{ var }} {# will be escaped for javascript #} - {{ var|escape('js') }} {# won't be double-escaped #} + {% autoescape 'js' %} + {{ var|escape('html') }} {# will be escaped for html and javascript #} + {{ var }} {# will be escaped for javascript #} + {{ var|escape('js') }} {# won't be double-escaped #} {% endautoescape %} .. note:: diff --git a/core/vendor/twig/twig/doc/filters/date.rst b/core/vendor/twig/twig/doc/filters/date.rst index 9833f0342f27..39ad732c181e 100644 --- a/core/vendor/twig/twig/doc/filters/date.rst +++ b/core/vendor/twig/twig/doc/filters/date.rst @@ -10,6 +10,9 @@ .. versionadded:: 1.6.1 The default timezone support has been added in Twig 1.6.1. +.. versionadded:: 1.11.0 + The introduction of the false value for the timezone was introduced in Twig 1.11.0 + The ``date`` filter formats a date to a given format: .. code-block:: jinja @@ -17,24 +20,27 @@ The ``date`` filter formats a date to a given format: {{ post.published_at|date("m/d/Y") }} The ``date`` filter accepts strings (it must be in a format supported by the -`date`_ function), `DateTime`_ instances, or `DateInterval`_ instances. For +`strtotime`_ function), `DateTime`_ instances, or `DateInterval`_ instances. For instance, to display the current date, filter the word "now": .. code-block:: jinja {{ "now"|date("m/d/Y") }} -To escape words and characters in the date format use ``\\`` in front of each character: +To escape words and characters in the date format use ``\\`` in front of each +character: .. code-block:: jinja {{ post.published_at|date("F jS \\a\\t g:ia") }} -You can also specify a timezone: +If the value passed to the ``date`` filter is ``null``, it will return the +current date by default. If an empty string is desired instead of the current +date, use a ternary operator: .. code-block:: jinja - {{ post.published_at|date("m/d/Y", "Europe/Paris") }} + {{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }} If no format is provided, Twig will use the default one: ``F j, Y H:i``. This default can be easily changed by calling the ``setDateFormat()`` method on the @@ -46,6 +52,24 @@ dates and the second one is the default format for date intervals: $twig = new Twig_Environment($loader); $twig->getExtension('core')->setDateFormat('d/m/Y', '%d days'); +Timezone +-------- + +By default, the date is displayed by applying the default timezone (the one +specified in php.ini or declared in Twig -- see below), but you can override +it by explicitly specifying a timezone: + +.. code-block:: jinja + + {{ post.published_at|date("m/d/Y", "Europe/Paris") }} + +If the date is already a DateTime object, and if you want to keep its current +timezone, pass ``false`` as the timezone value: + +.. code-block:: jinja + + {{ post.published_at|date("m/d/Y", false) }} + The default timezone can also be set globally by calling ``setTimezone()``: .. code-block:: php @@ -53,13 +77,6 @@ The default timezone can also be set globally by calling ``setTimezone()``: $twig = new Twig_Environment($loader); $twig->getExtension('core')->setTimezone('Europe/Paris'); -.. _`date`: http://www.php.net/date +.. _`strtotime`: http://www.php.net/strtotime .. _`DateTime`: http://www.php.net/DateTime .. _`DateInterval`: http://www.php.net/DateInterval - -If the value passed to the ``date`` filter is null, it will return the current date by default. -If an empty string is desired instead of the current date, use a ternary operator: - -.. code-block:: jinja - - {{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }} diff --git a/core/vendor/twig/twig/doc/filters/date_modify.rst b/core/vendor/twig/twig/doc/filters/date_modify.rst new file mode 100644 index 000000000000..ae12c52975e0 --- /dev/null +++ b/core/vendor/twig/twig/doc/filters/date_modify.rst @@ -0,0 +1,18 @@ +``date_modify`` +=============== + +.. versionadded:: 1.9.0 + The date_modify filter has been added in Twig 1.9.0. + +The ``date_modify`` filter modifies a date with a given modifier string: + +.. code-block:: jinja + + {{ post.published_at|date_modify("+1 day")|date("m/d/Y") }} + +The ``date_modify`` filter accepts strings (it must be in a format supported +by the `strtotime`_ function) or `DateTime`_ instances. You can easily combine +it with the :doc:`date<date>` filter for formatting. + +.. _`strtotime`: http://www.php.net/strtotime +.. _`DateTime`: http://www.php.net/DateTime diff --git a/core/vendor/twig/twig/doc/filters/escape.rst b/core/vendor/twig/twig/doc/filters/escape.rst index 51429775c262..ddb2bbba0186 100644 --- a/core/vendor/twig/twig/doc/filters/escape.rst +++ b/core/vendor/twig/twig/doc/filters/escape.rst @@ -1,9 +1,15 @@ ``escape`` ========== -The ``escape`` filter converts the characters ``&``, ``<``, ``>``, ``'``, and -``"`` in strings to HTML-safe sequences. Use this if you need to display text -that might contain such characters in HTML: +.. versionadded:: 1.9.0 + The ``css``, ``url``, and ``html_attr`` strategies were added in Twig + 1.9.0. + +The ``escape`` filter escapes a string for safe insertion into the final +output. It supports different escaping strategies depending on the template +context. + +By default, it uses the HTML escaping strategy: .. code-block:: jinja @@ -31,9 +37,51 @@ And here is how to escape variables included in JavaScript code: {{ user.username|escape('js') }} {{ user.username|e('js') }} +The ``escape`` filter supports the following escaping strategies: + +* ``html``: escapes a string for the **HTML body** context. + +* ``js``: escapes a string for the **JavaScript context**. + +* ``css``: escapes a string for the **CSS context**. CSS escaping can be + applied to any string being inserted into CSS and escapes everything except + alphanumerics. + +* ``url``: escapes a string for the **URI or parameter contexts**. This should + not be used to escape an entire URI; only a subcomponent being inserted. + +* ``html_attr``: escapes a string for the **HTML attribute** context. + .. note:: Internally, ``escape`` uses the PHP native `htmlspecialchars`_ function for the HTML escaping strategy. +.. caution:: + + When using automatic escaping, Twig tries to not double-escape a variable + when the automatic escaping strategy is the same as the one applied by the + escape filter; but that does not work when using a variable as the + escaping strategy: + + .. code-block:: jinja + + {% set strategy = 'html' %} + + {% autoescape 'html' %} + {{ var|escape('html') }} {# won't be double-escaped #} + {{ var|escape(strategy) }} {# will be double-escaped #} + {% endautoescape %} + + When using a variable as the escaping strategy, you should disable + automatic escaping:: + + .. code-block:: jinja + + {% set strategy = 'html' %} + + {% autoescape 'html' %} + {{ var|escape(strategy)|raw }} {# won't be double-escaped #} + {% endautoescape %} + .. _`htmlspecialchars`: http://php.net/htmlspecialchars diff --git a/core/vendor/twig/twig/doc/filters/index.rst b/core/vendor/twig/twig/doc/filters/index.rst index bd8f49513f5f..e29e3ae3de55 100644 --- a/core/vendor/twig/twig/doc/filters/index.rst +++ b/core/vendor/twig/twig/doc/filters/index.rst @@ -5,6 +5,7 @@ Filters :maxdepth: 1 date + date_modify format replace number_format @@ -18,7 +19,9 @@ Filters lower striptags join + split reverse + abs length sort default diff --git a/core/vendor/twig/twig/doc/filters/number_format.rst b/core/vendor/twig/twig/doc/filters/number_format.rst index ccc8f2f917ac..b591b1e56bad 100644 --- a/core/vendor/twig/twig/doc/filters/number_format.rst +++ b/core/vendor/twig/twig/doc/filters/number_format.rst @@ -16,7 +16,7 @@ separator using the additional arguments: .. code-block:: jinja - {{ 9800.333|number_format(2, ',', '.') }} + {{ 9800.333|number_format(2, '.', ',') }} If no formatting options are provided then Twig will use the default formatting options of: @@ -30,7 +30,7 @@ These defaults can be easily changed through the core extension: .. code-block:: php $twig = new Twig_Environment($loader); - $twig->getExtension('core')->setNumberFormat(3, ',', '.'); + $twig->getExtension('core')->setNumberFormat(3, '.', ','); The defaults set for ``number_format`` can be over-ridden upon each call using the additional parameters. diff --git a/core/vendor/twig/twig/doc/filters/split.rst b/core/vendor/twig/twig/doc/filters/split.rst new file mode 100644 index 000000000000..9b9e4e65bdf0 --- /dev/null +++ b/core/vendor/twig/twig/doc/filters/split.rst @@ -0,0 +1,47 @@ +``split`` +========= + +.. versionadded:: 1.10.3 + The split filter was added in Twig 1.10.3. + +The ``split`` filter splits a string by the given delimiter and returns a list +of strings: + +.. code-block:: jinja + + {{ "one,two,three"|split(',') }} + {# returns ['one', 'two', 'three'] #} + +You can also pass a ``limit`` argument: + + * If ``limit`` is positive, the returned array will contain a maximum of + limit elements with the last element containing the rest of string; + + * If ``limit`` is negative, all components except the last -limit are + returned; + + * If ``limit`` is zero, then this is treated as 1. + +.. code-block:: jinja + + {{ "one,two,three,four,five"|split(',', 3) }} + {# returns [one, two, "three,four,five"] #} + +If the ``delimiter`` is an empty string, then value will be split by equal +chunks. Length is set by the ``limit`` argument (one character by default). + +.. code-block:: jinja + + {{ "123"|split('') }} + {# returns [1, 2, 3] #} + + {{ "aabbcc"|split('', 2) }} + {# returns [aa, bb, cc] #} + +.. note:: + + Internally, Twig uses the PHP `explode`_ or `str_split`_ (if delimiter is + empty) functions for string splitting. + +.. _`explode`: http://php.net/explode +.. _`str_split`: http://php.net/str_split diff --git a/core/vendor/twig/twig/doc/functions/index.rst b/core/vendor/twig/twig/doc/functions/index.rst index 331552809f82..4d9a003787a2 100644 --- a/core/vendor/twig/twig/doc/functions/index.rst +++ b/core/vendor/twig/twig/doc/functions/index.rst @@ -13,3 +13,4 @@ Functions parent dump date + template_from_string diff --git a/core/vendor/twig/twig/doc/functions/template_from_string.rst b/core/vendor/twig/twig/doc/functions/template_from_string.rst new file mode 100644 index 000000000000..0b3b0b4bb709 --- /dev/null +++ b/core/vendor/twig/twig/doc/functions/template_from_string.rst @@ -0,0 +1,27 @@ +``template_from_string`` +======================== + +.. versionadded:: 1.11 + The template_from_string function was added in Twig 1.11. + +The ``template_from_string`` function loads a template from a string: + +.. code-block:: jinja + + {% include template_from_string("Hello {{ name }}") %} + {% include template_from_string(page.template) %} + +.. note:: + + The ``template_from_string`` function is not available by default. You + must add the ``Twig_Extension_StringLoader`` extension explicitly when + creating your Twig environment:: + + $twig = new Twig_Environment(...); + $twig->addExtension(new Twig_Extension_StringLoader()); + +.. note:: + + Even if you will probably always use the ``template_from_string`` function + with the ``include`` tag, you can use it with any tag or function that + takes a template as an argument (like the ``embed`` or ``extends`` tags). diff --git a/core/vendor/twig/twig/doc/intro.rst b/core/vendor/twig/twig/doc/intro.rst index f9dc2268d0fd..69ffe643a317 100644 --- a/core/vendor/twig/twig/doc/intro.rst +++ b/core/vendor/twig/twig/doc/intro.rst @@ -127,6 +127,11 @@ The first step to use Twig is to register its autoloader:: Replace the ``/path/to/lib/`` path with the path you used for Twig installation. +If you have installed Twig via Composer you can take advantage of Composer's +autoload mechanism by replacing the previous snippet for:: + + require_once '/path/to/vendor/autoload.php' + .. note:: Twig follows the PEAR convention names for its classes, which means you diff --git a/core/vendor/twig/twig/doc/recipes.rst b/core/vendor/twig/twig/doc/recipes.rst index 59a6dfb926d5..6ece40dcef6b 100644 --- a/core/vendor/twig/twig/doc/recipes.rst +++ b/core/vendor/twig/twig/doc/recipes.rst @@ -328,35 +328,147 @@ you have some dynamic JavaScript files thanks to the ``autoescape`` tag: .. code-block:: jinja - {% autoescape js %} + {% autoescape 'js' %} ... some JS ... {% endautoescape %} But if you have many HTML and JS files, and if your template names follow some conventions, you can instead determine the default escaping strategy to use based on the template name. Let's say that your template names always ends -with ``.html`` for HTML files and ``.js`` for JavaScript ones, here is how you -can configure Twig:: +with ``.html`` for HTML files, ``.js`` for JavaScript ones, and ``.css`` for +stylesheets, here is how you can configure Twig:: - function twig_escaping_guesser($filename) + class TwigEscapingGuesser { - // get the format - $format = substr($filename, strrpos($filename, '.') + 1); - - switch ($format) { - 'js': - return 'js'; - default: - return 'html'; + function guess($filename) + { + // get the format + $format = substr($filename, strrpos($filename, '.') + 1); + + switch ($format) { + case 'js': + return 'js'; + case 'css': + return 'css'; + case 'html': + default: + return 'html'; + } } } $loader = new Twig_Loader_Filesystem('/path/to/templates'); $twig = new Twig_Environment($loader, array( - 'autoescape' => 'twig_escaping_guesser', + 'autoescape' => array(new TwigEscapingGuesser(), 'guess'), )); This dynamic strategy does not incur any overhead at runtime as auto-escaping is done at compilation time. +Using a Database to store Templates +----------------------------------- + +If you are developing a CMS, templates are usually stored in a database. This +recipe gives you a simple PDO template loader you can use as a starting point +for your own. + +First, let's create a temporary in-memory SQLite3 database to work with:: + + $dbh = new PDO('sqlite::memory:'); + $dbh->exec('CREATE TABLE templates (name STRING, source STRING, last_modified INTEGER)'); + $base = '{% block content %}{% endblock %}'; + $index = ' + {% extends "base.twig" %} + {% block content %}Hello {{ name }}{% endblock %} + '; + $now = time(); + $dbh->exec("INSERT INTO templates (name, source, last_modified) VALUES ('base.twig', '$base', $now)"); + $dbh->exec("INSERT INTO templates (name, source, last_modified) VALUES ('index.twig', '$index', $now)"); + +We have created a simple ``templates`` table that hosts two templates: +``base.twig`` and ``index.twig``. + +Now, let's define a loader able to use this database:: + + class DatabaseTwigLoader implements Twig_LoaderInterface, Twig_ExistsLoaderInterface + { + protected $dbh; + + public function __construct(PDO $dbh) + { + $this->dbh = $dbh; + } + + public function getSource($name) + { + if (false === $source = $this->getValue('source', $name)) { + throw new Twig_Error_Loader(sprintf('Template "%s" does not exist.', $name)); + } + + return $source; + } + + // Twig_ExistsLoaderInterface as of Twig 1.11 + public function exists($name) + { + return $name === $this->getValue('name', $name); + } + + public function getCacheKey($name) + { + return $name; + } + + public function isFresh($name, $time) + { + if (false === $lastModified = $this->getValue('last_modified', $name)) { + return false; + } + + return $lastModified <= $time; + } + + protected function getValue($column, $name) + { + $sth = $this->dbh->prepare('SELECT '.$column.' FROM templates WHERE name = :name'); + $sth->execute(array(':name' => (string) $name)); + + return $sth->fetchColumn(); + } + } + +Finally, here is an example on how you can use it:: + + $loader = new DatabaseTwigLoader($dbh); + $twig = new Twig_Environment($loader); + + echo $twig->render('index.twig', array('name' => 'Fabien')); + +Using different Template Sources +-------------------------------- + +This recipe is the continuation of the previous one. Even if you store the +contributed templates in a database, you might want to keep the original/base +templates on the filesystem. When templates can be loaded from different +sources, you need to use the ``Twig_Loader_Chain`` loader. + +As you can see in the previous recipe, we reference the template in the exact +same way as we would have done it with a regular filesystem loader. This is +the key to be able to mix and match templates coming from the database, the +filesystem, or any other loader for that matter: the template name should be a +logical name, and not the path from the filesystem:: + + $loader1 = new DatabaseTwigLoader($dbh); + $loader2 = new Twig_Loader_Array(array( + 'base.twig' => '{% block content %}{% endblock %}', + )); + $loader = new Twig_Loader_Chain(array($loader1, $loader2)); + + $twig = new Twig_Environment($loader); + + echo $twig->render('index.twig', array('name' => 'Fabien')); + +Now that the ``base.twig`` templates is defined in an array loader, you can +remove it from the database, and everything else will still work as before. + .. _callback: http://www.php.net/manual/en/function.is-callable.php diff --git a/core/vendor/twig/twig/doc/tags/extends.rst b/core/vendor/twig/twig/doc/tags/extends.rst index 8d644369b239..f995a5dcefab 100644 --- a/core/vendor/twig/twig/doc/tags/extends.rst +++ b/core/vendor/twig/twig/doc/tags/extends.rst @@ -33,8 +33,10 @@ skeleton document: </html> In this example, the :doc:`block<block>` tags define four blocks that child -templates can fill in. All the ``block`` tag does is to tell the template -engine that a child template may override those portions of the template. +templates can fill in. + +All the ``block`` tag does is to tell the template engine that a child +template may override those portions of the template. Child Template -------------- @@ -184,4 +186,83 @@ In this example, the template will extend the "minimum.html" layout template if the ``standalone`` variable evaluates to ``true``, and "base.html" otherwise. +How blocks work? +---------------- + +A block provides a way to change how a certain part of a template is rendered +but it does not interfere in any way with the logic around it. + +Let's take the following example to illustrate how a block work and more +importantly, how it does not work: + +.. code-block:: jinja + + {# base.twig #} + + {% for post in posts %} + {% block post %} + <h1>{{ post.title }}</h1> + <p>{{ post.body }}</p> + {% endblock %} + {% endfor %} + +If you render this template, the result would be exactly the same with or +without the ``block`` tag. The ``block`` inside the ``for`` loop is just a way +to make it overridable by a child template: + +.. code-block:: jinja + + {# child.twig #} + + {% extends "base.twig" %} + + {% block post %} + <article> + <header>{{ post.title }}</header> + <section>{{ post.text }}</section> + </article> + {% endblock %} + +Now, when rendering the child template, the loop is going to use the block +defined in the child template instead of the one defined in the base one; the +executed template is then equivalent to the following one: + +.. code-block:: jinja + + {% for post in posts %} + <article> + <header>{{ post.title }}</header> + <section>{{ post.text }}</section> + </article> + {% endfor %} + +Let's take another example: a block included within an ``if`` statement: + +.. code-block:: jinja + + {% if posts is empty %} + {% block head %} + {{ parent() }} + + <meta name="robots" content="noindex, follow"> + {% endblock head %} + {% endif %} + +Contrary to what you might think, this template does not define a block +conditionally; it just makes overridable by a child template the output of +what will be rendered when the condition is ``true``. + +If you want the output to be displayed conditionally, use the following +instead: + +.. code-block:: jinja + + {% block head %} + {{ parent() }} + + {% if posts is empty %} + <meta name="robots" content="noindex, follow"> + {% endif %} + {% endblock head %} + .. seealso:: :doc:`block<../functions/block>`, :doc:`block<../tags/block>`, :doc:`parent<../functions/parent>`, :doc:`use<../tags/use>` diff --git a/core/vendor/twig/twig/doc/tags/import.rst b/core/vendor/twig/twig/doc/tags/import.rst index 8d47b36b841c..f6bf718e4e27 100644 --- a/core/vendor/twig/twig/doc/tags/import.rst +++ b/core/vendor/twig/twig/doc/tags/import.rst @@ -49,31 +49,9 @@ namespace: </dl> <p>{{ textarea('comment') }}</p> -Importing is not needed if the macros and the template are defined in the same -file; use the special ``_self`` variable instead: +.. tip:: -.. code-block:: jinja - - {# index.html template #} - - {% macro textarea(name, value, rows) %} - <textarea name="{{ name }}" rows="{{ rows|default(10) }}" cols="{{ cols|default(40) }}">{{ value|e }}</textarea> - {% endmacro %} - - <p>{{ _self.textarea('comment') }}</p> - -But you can still create an alias by importing from the ``_self`` variable: - -.. code-block:: jinja - - {# index.html template #} - - {% macro textarea(name, value, rows) %} - <textarea name="{{ name }}" rows="{{ rows|default(10) }}" cols="{{ cols|default(40) }}">{{ value|e }}</textarea> - {% endmacro %} - - {% import _self as forms %} - - <p>{{ forms.textarea('comment') }}</p> + To import macros from the current file, use the special ``_self`` variable + for the source. .. seealso:: :doc:`macro<../tags/macro>`, :doc:`from<../tags/from>` diff --git a/core/vendor/twig/twig/doc/tags/macro.rst b/core/vendor/twig/twig/doc/tags/macro.rst index 3d920e31ccc6..155f7fe7b4fc 100644 --- a/core/vendor/twig/twig/doc/tags/macro.rst +++ b/core/vendor/twig/twig/doc/tags/macro.rst @@ -48,41 +48,33 @@ The macro can then be called at will: <p>{{ forms.input('password', null, 'password') }}</p> If macros are defined and used in the same template, you can use the -special ``_self`` variable, without importing them: +special ``_self`` variable to import them: .. code-block:: jinja - <p>{{ _self.input('username') }}</p> + {% import _self as forms %} -When you want to use a macro in another one from the same file, use the ``_self`` -variable: + <p>{{ forms.input('username') }}</p> -.. code-block:: jinja +.. warning:: - {% macro input(name, value, type, size) %} - <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" /> - {% endmacro %} + When you define a macro in the template where you are going to use it, you + might be tempted to call the macro directly via ``_self.input()`` instead + of importing it; even if seems to work, this is just a side-effect of the + current implementation and it won't work anymore in Twig 2.x. - {% macro wrapped_input(name, value, type, size) %} - <div class="field"> - {{ _self.input(name, value, type, size) }} - </div> - {% endmacro %} - -When the macro is defined in another file, you need to import it: +When you want to use a macro in another macro from the same file, you need to +import it locally: .. code-block:: jinja - {# forms.html #} - {% macro input(name, value, type, size) %} - <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" /> + <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" /> {% endmacro %} - {# shortcuts.html #} - {% macro wrapped_input(name, value, type, size) %} - {% import "forms.html" as forms %} + {% import _self as forms %} + <div class="field"> {{ forms.input(name, value, type, size) }} </div> diff --git a/core/vendor/twig/twig/doc/tags/sandbox.rst b/core/vendor/twig/twig/doc/tags/sandbox.rst index 027553726933..e186726c202e 100644 --- a/core/vendor/twig/twig/doc/tags/sandbox.rst +++ b/core/vendor/twig/twig/doc/tags/sandbox.rst @@ -19,7 +19,7 @@ template, when sandboxing is not enabled globally for the Twig environment: The ``sandbox`` tag can only be used to sandbox an include tag and it cannot be used to sandbox a section of a template. The following example - won't work for example: + won't work: .. code-block:: jinja diff --git a/core/vendor/twig/twig/doc/templates.rst b/core/vendor/twig/twig/doc/templates.rst index 278e56ddbe54..104dcad63c25 100644 --- a/core/vendor/twig/twig/doc/templates.rst +++ b/core/vendor/twig/twig/doc/templates.rst @@ -48,14 +48,15 @@ Many IDEs support syntax highlighting and auto-completion for Twig: * *Textmate* via the `Twig bundle`_ * *Vim* via the `Jinja syntax plugin`_ -* *Netbeans* via the `Twig syntax plugin`_ +* *Netbeans* via the `Twig syntax plugin`_ (until 7.1, native as of 7.2) * *PhpStorm* (native as of 2.1) * *Eclipse* via the `Twig plugin`_ * *Sublime Text* via the `Twig bundle`_ * *GtkSourceView* via the `Twig language definition`_ (used by gedit and other projects) * *Coda* and *SubEthaEdit* via the `Twig syntax mode`_ * *Coda 2* via the `other Twig syntax mode`_ -* *Komodo* and *Komodo Edit* via the Django highlight/syntax check mode +* *Komodo* and *Komodo Edit* via the Twig highlight/syntax check mode +* *Notepad++* via the `Notepad++ Twig Highlighter`_ Variables --------- @@ -74,6 +75,15 @@ properties of a PHP object, or items of a PHP array), or the so-called {{ foo.bar }} {{ foo['bar'] }} +When the attribute contains special characters (like ``-`` that would be +interpreted as the minus operator), use the ``attribute`` function instead to +access the variable attribute: + +.. code-block:: jinja + + {# equivalent to the non-working foo.data-foo #} + {{ attribute(foo, 'data-foo') }} + .. note:: It's important to know that the curly braces are *not* part of the @@ -317,7 +327,7 @@ A child template might look like this: {% block content %} <h1>Index</h1> <p class="important"> - Welcome on my awesome homepage. + Welcome to my awesome homepage. </p> {% endblock %} @@ -371,16 +381,24 @@ Twig supports both, automatic escaping is enabled by default. Working with Manual Escaping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If manual escaping is enabled it's **your** responsibility to escape variables -if needed. What to escape? If you have a variable that *may* include any of -the following chars (``>``, ``<``, ``&``, or ``"``) you **have to** escape it -unless the variable contains well-formed and trusted HTML. Escaping works by -piping the variable through the :doc:`escape<filters/escape>` or ``e`` filter: +If manual escaping is enabled, it is **your** responsibility to escape +variables if needed. What to escape? Any variable you don't trust. + +Escaping works by piping the variable through the +:doc:`escape<filters/escape>` or ``e`` filter: .. code-block:: jinja {{ user.username|e }} + +By default, the ``escape`` filter uses the ``html`` strategy, but depending on +the escaping context, you might want to explicitly use any other available +strategies: + {{ user.username|e('js') }} + {{ user.username|e('css') }} + {{ user.username|e('url') }} + {{ user.username|e('html_attr') }} Working with Automatic Escaping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -391,8 +409,18 @@ tag: .. code-block:: jinja - {% autoescape true %} - Everything will be automatically escaped in this block + {% autoescape %} + Everything will be automatically escaped in this block (using the HTML strategy) + {% endautoescape %} + +By default, auto-escaping uses the ``html`` escaping strategy. If you output +variables in other contexts, you need to explicitly escape them with the +appropriate escaping strategy: + +.. code-block:: jinja + + {% autoescape 'js' %} + Everything will be automatically escaped in this block (using the JS strategy) {% endautoescape %} Escaping @@ -514,6 +542,11 @@ Arrays and hashes can be nested: {% set foo = [1, {"foo": "bar"}] %} +.. tip:: + + Using double-quoted or single-quoted strings has no impact on performance + but string interpolation is only supported in double-quoted strings. + Math ~~~~ @@ -523,7 +556,7 @@ but exists for completeness' sake. The following operators are supported: * ``+``: Adds two objects together (the operands are casted to numbers). ``{{ 1 + 1 }}`` is ``2``. -* ``-``: Substracts the second number from the first one. ``{{ 3 - 2 }}`` is +* ``-``: Subtracts the second number from the first one. ``{{ 3 - 2 }}`` is ``1``. * ``/``: Divides two numbers. The returned value will be a floating point @@ -650,8 +683,8 @@ String Interpolation String interpolation was added in Twig 1.5. String interpolation (`#{expression}`) allows any valid expression to appear -within a string. The result of evaluating that expression is inserted into the -string: +within a *double-quoted string*. The result of evaluating that expression is +inserted into the string: .. code-block:: jinja @@ -717,11 +750,12 @@ If you are looking for new tags, filters, or functions, have a look at the Twig If you want to create your own, read the :ref:`Creating an Extension<creating_extensions>` chapter. -.. _`Twig bundle`: https://github.com/Anomareh/PHP-Twig.tmbundle -.. _`Jinja syntax plugin`: http://jinja.pocoo.org/2/documentation/integration -.. _`Twig syntax plugin`: http://plugins.netbeans.org/plugin/37069/php-twig -.. _`Twig plugin`: https://github.com/pulse00/Twig-Eclipse-Plugin -.. _`Twig language definition`: https://github.com/gabrielcorpse/gedit-twig-template-language -.. _`extension repository`: http://github.com/fabpot/Twig-extensions -.. _`Twig syntax mode`: https://github.com/bobthecow/Twig-HTML.mode -.. _`other Twig syntax mode`: https://github.com/muxx/Twig-HTML.mode +.. _`Twig bundle`: https://github.com/Anomareh/PHP-Twig.tmbundle +.. _`Jinja syntax plugin`: http://jinja.pocoo.org/2/documentation/integration +.. _`Twig syntax plugin`: http://plugins.netbeans.org/plugin/37069/php-twig +.. _`Twig plugin`: https://github.com/pulse00/Twig-Eclipse-Plugin +.. _`Twig language definition`: https://github.com/gabrielcorpse/gedit-twig-template-language +.. _`extension repository`: http://github.com/fabpot/Twig-extensions +.. _`Twig syntax mode`: https://github.com/bobthecow/Twig-HTML.mode +.. _`other Twig syntax mode`: https://github.com/muxx/Twig-HTML.mode +.. _`Notepad++ Twig Highlighter`: https://github.com/Banane9/notepadplusplus-twig diff --git a/core/vendor/twig/twig/doc/tests/empty.rst b/core/vendor/twig/twig/doc/tests/empty.rst index 0d1eb3234406..e5b55999d3b4 100644 --- a/core/vendor/twig/twig/doc/tests/empty.rst +++ b/core/vendor/twig/twig/doc/tests/empty.rst @@ -5,7 +5,7 @@ .. code-block:: jinja - {# evaluates to true if the foo variable is null, false, or the empty string #} + {# evaluates to true if the foo variable is null, false, an empty array, or the empty string #} {% if foo is empty %} ... {% endif %} diff --git a/core/vendor/twig/twig/ext/twig/php_twig.h b/core/vendor/twig/twig/ext/twig/php_twig.h index 13a0fc01bde9..0cba85879ebf 100644 --- a/core/vendor/twig/twig/ext/twig/php_twig.h +++ b/core/vendor/twig/twig/ext/twig/php_twig.h @@ -15,35 +15,17 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.8.3" +#define PHP_TWIG_VERSION "1.11.1" #include "php.h" extern zend_module_entry twig_module_entry; #define phpext_twig_ptr &twig_module_entry -#ifdef PHP_WIN32 -#define PHP_TWIG_API __declspec(dllexport) -#else -#define PHP_TWIG_API -#endif - #ifdef ZTS #include "TSRM.h" #endif PHP_FUNCTION(twig_template_get_attributes); -PHP_MINIT_FUNCTION(twig); -PHP_MSHUTDOWN_FUNCTION(twig); -PHP_RINIT_FUNCTION(twig); -PHP_RSHUTDOWN_FUNCTION(twig); -PHP_MINFO_FUNCTION(twig); - -#ifdef ZTS -#define TWIG_G(v) TSRMG(twig_globals_id, zend_twig_globals *, v) -#else -#define TWIG_G(v) (twig_globals.v) -#endif - #endif diff --git a/core/vendor/twig/twig/ext/twig/twig.c b/core/vendor/twig/twig/ext/twig/twig.c index 880b96445944..1fea683a4f6a 100644 --- a/core/vendor/twig/twig/ext/twig/twig.c +++ b/core/vendor/twig/twig/ext/twig/twig.c @@ -17,8 +17,6 @@ #endif #include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" #include "php_twig.h" #include "ext/standard/php_string.h" #include "ext/standard/php_smart_str.h" @@ -31,6 +29,20 @@ #define Z_ADDREF_P(pz) (pz)->refcount++ #endif +#define FREE_DTOR(z) \ + zval_dtor(z); \ + efree(z); + +#if PHP_VERSION_ID >= 50300 + #define APPLY_TSRMLS_DC TSRMLS_DC + #define APPLY_TSRMLS_CC TSRMLS_CC + #define APPLY_TSRMLS_FETCH() +#else + #define APPLY_TSRMLS_DC + #define APPLY_TSRMLS_CC + #define APPLY_TSRMLS_FETCH() TSRMLS_FETCH() +#endif + ZEND_BEGIN_ARG_INFO_EX(twig_template_get_attribute_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 6) ZEND_ARG_INFO(0, template) ZEND_ARG_INFO(0, object) @@ -47,19 +59,15 @@ zend_function_entry twig_functions[] = { zend_module_entry twig_module_entry = { -#if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, -#endif "twig", twig_functions, - PHP_MINIT(twig), - PHP_MSHUTDOWN(twig), - PHP_RINIT(twig), - PHP_RSHUTDOWN(twig), - PHP_MINFO(twig), -#if ZEND_MODULE_API_NO >= 20010901 + NULL, + NULL, + NULL, + NULL, + NULL, PHP_TWIG_VERSION, -#endif STANDARD_MODULE_PROPERTIES }; @@ -68,50 +76,6 @@ zend_module_entry twig_module_entry = { ZEND_GET_MODULE(twig) #endif -PHP_INI_BEGIN() -PHP_INI_END() - -PHP_MINIT_FUNCTION(twig) -{ - REGISTER_INI_ENTRIES(); - - return SUCCESS; -} - - -PHP_MSHUTDOWN_FUNCTION(twig) -{ - UNREGISTER_INI_ENTRIES(); - - return SUCCESS; -} - - - -PHP_RINIT_FUNCTION(twig) -{ - return SUCCESS; -} - - - -PHP_RSHUTDOWN_FUNCTION(twig) -{ - return SUCCESS; -} - - -PHP_MINFO_FUNCTION(twig) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "Twig support", "enabled"); - php_info_print_table_row(2, "Version", PHP_TWIG_VERSION); - php_info_print_table_end(); - - DISPLAY_INI_ENTRIES(); - -} - int TWIG_ARRAY_KEY_EXISTS(zval *array, char* key, int key_len) { if (Z_TYPE_P(array) != IS_ARRAY) { @@ -236,16 +200,14 @@ zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments TS fci.no_separation = 0; if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { - zval_dtor(zfunction); - efree(zfunction); + FREE_DTOR(zfunction) zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Could not execute %s::%s()", zend_get_class_entry(object TSRMLS_CC)->name, function TSRMLS_CC); } if (args) { efree(fci.params); } - zval_dtor(zfunction); - efree(zfunction); + FREE_DTOR(zfunction); return retval_ptr; } @@ -315,8 +277,7 @@ zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length ALLOC_INIT_ZVAL(tmp_name_zval); ZVAL_STRING(tmp_name_zval, prop_name, 1); tmp_ret_zval = TWIG_GET_ARRAYOBJECT_ELEMENT(class, tmp_name_zval TSRMLS_CC); - zval_dtor(tmp_name_zval); - efree(tmp_name_zval); + FREE_DTOR(tmp_name_zval); return tmp_ret_zval; } @@ -328,22 +289,8 @@ zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length zval *TWIG_PROPERTY(zval *object, zval *propname TSRMLS_DC) { - char *prot_name; - int prot_name_length; zval *tmp = NULL; - tmp = TWIG_GET_ARRAY_ELEMENT(object, Z_STRVAL_P(propname), Z_STRLEN_P(propname) TSRMLS_CC); - if (tmp) { - return tmp; - } - - zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, Z_STRVAL_P(propname), Z_STRLEN_P(propname), 0); - tmp = TWIG_GET_ARRAY_ELEMENT(object, prot_name, prot_name_length TSRMLS_CC); - efree(prot_name); - if (tmp) { - return tmp; - } - if (Z_OBJ_HT_P(object)->read_property) { #if PHP_VERSION_ID >= 50400 tmp = Z_OBJ_HT_P(object)->read_property(object, propname, BP_VAR_IS, NULL TSRMLS_CC); @@ -371,6 +318,19 @@ int TWIG_HAS_PROPERTY(zval *object, zval *propname TSRMLS_DC) return 0; } +int TWIG_HAS_DYNAMIC_PROPERTY(zval *object, char *prop, int prop_len TSRMLS_DC) +{ + if (Z_OBJ_HT_P(object)->get_properties) { + return zend_hash_quick_exists( + Z_OBJ_HT_P(object)->get_properties(object TSRMLS_CC), // the properties hash + prop, // property name + prop_len + 1, // property length + zend_get_hash_value(prop, prop_len + 1) // hash value + ); + } + return 0; +} + zval *TWIG_PROPERTY_CHAR(zval *object, char *propname TSRMLS_DC) { zval *tmp_name_zval, *tmp; @@ -378,8 +338,7 @@ zval *TWIG_PROPERTY_CHAR(zval *object, char *propname TSRMLS_DC) ALLOC_INIT_ZVAL(tmp_name_zval); ZVAL_STRING(tmp_name_zval, propname, 1); tmp = TWIG_PROPERTY(object, tmp_name_zval TSRMLS_CC); - zval_dtor(tmp_name_zval); - efree(tmp_name_zval); + FREE_DTOR(tmp_name_zval); return tmp; } @@ -417,13 +376,12 @@ zval *TWIG_CALL_S(zval *object, char *method, char *arg0 TSRMLS_DC) fci.no_separation = 0; if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { - zval_dtor(argument); + FREE_DTOR(zfunction); + zval_ptr_dtor(&argument); return 0; } - zval_dtor(zfunction); - efree(zfunction); - zval_dtor(argument); - efree(argument); + FREE_DTOR(zfunction); + zval_ptr_dtor(&argument); return retval_ptr; } @@ -469,16 +427,14 @@ int TWIG_CALL_Z(zval *object, char *method, zval *arg1 TSRMLS_DC) fci.no_separation = 0; if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { - zval_dtor(zfunction); - efree(zfunction); + FREE_DTOR(zfunction); if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } return 0; } - zval_dtor(zfunction); - efree(zfunction); + FREE_DTOR(zfunction); success = (retval_ptr && (Z_TYPE_P(retval_ptr) == IS_BOOL) && Z_LVAL_P(retval_ptr)); if (retval_ptr) { @@ -516,11 +472,11 @@ int TWIG_CALL_ZZ(zval *object, char *method, zval *arg1, zval *arg2 TSRMLS_DC) fci.no_separation = 0; if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { - zval_dtor(zfunction); + FREE_DTOR(zfunction); return 0; } - zval_dtor(zfunction); + FREE_DTOR(zfunction); success = (retval_ptr && (Z_TYPE_P(retval_ptr) == IS_BOOL) && Z_LVAL_P(retval_ptr)); if (retval_ptr) { @@ -551,7 +507,7 @@ void TWIG_NEW(zval *object, char *class, zval *arg0, zval *arg1 TSRMLS_DC) TWIG_CALL_ZZ(object, "__construct", arg0, arg1 TSRMLS_CC); } -static int twig_add_array_key_to_string(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int twig_add_array_key_to_string(void *pDest APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { smart_str *buf; char *joiner; @@ -584,7 +540,7 @@ char *TWIG_IMPLODE_ARRAY_KEYS(char *joiner, zval *array TSRMLS_DC) smart_str collector = { 0, 0, 0 }; smart_str_appendl(&collector, "", 0); - zend_hash_apply_with_arguments(HASH_OF(array) TSRMLS_CC, twig_add_array_key_to_string, 2, &collector, joiner); + zend_hash_apply_with_arguments(HASH_OF(array) APPLY_TSRMLS_CC, twig_add_array_key_to_string, 2, &collector, joiner); smart_str_0(&collector); return collector.c; @@ -596,8 +552,7 @@ static void TWIG_THROW_EXCEPTION(char *exception_name TSRMLS_DC, char *message, va_list args; zend_class_entry **pce; - if (zend_lookup_class(exception_name, strlen(exception_name), &pce TSRMLS_CC) == FAILURE) - { + if (zend_lookup_class(exception_name, strlen(exception_name), &pce TSRMLS_CC) == FAILURE) { return; } @@ -606,9 +561,67 @@ static void TWIG_THROW_EXCEPTION(char *exception_name TSRMLS_DC, char *message, va_end(args); zend_throw_exception_ex(*pce, 0 TSRMLS_CC, buffer); + efree(buffer); } -char *TWIG_GET_CLASS_NAME(zval *object TSRMLS_DC) +static void TWIG_RUNTIME_ERROR(zval *template TSRMLS_DC, char *message, ...) +{ + char *buffer; + va_list args; + zend_class_entry **pce; + zval *ex; + zval *constructor; + zval *zmessage; + zval *lineno; + zval *filename_func; + zval *filename; + zval *constructor_args[3]; + zval *constructor_retval; + + if (zend_lookup_class("Twig_Error_Runtime", strlen("Twig_Error_Runtime"), &pce TSRMLS_CC) == FAILURE) { + return; + } + + va_start(args, message); + vspprintf(&buffer, 0, message, args); + va_end(args); + + MAKE_STD_ZVAL(ex); + object_init_ex(ex, *pce); + + // Call Twig_Error constructor + MAKE_STD_ZVAL(constructor); + MAKE_STD_ZVAL(zmessage); + MAKE_STD_ZVAL(lineno); + MAKE_STD_ZVAL(filename); + MAKE_STD_ZVAL(filename_func); + MAKE_STD_ZVAL(constructor_retval); + + ZVAL_STRINGL(constructor, "__construct", sizeof("__construct")-1, 1); + ZVAL_STRING(zmessage, buffer, 1); + ZVAL_LONG(lineno, -1); + + // Get template filename + ZVAL_STRINGL(filename_func, "getTemplateName", sizeof("getTemplateName")-1, 1); + call_user_function(EG(function_table), &template, filename_func, filename, 0, 0 TSRMLS_CC); + + constructor_args[0] = zmessage; + constructor_args[1] = lineno; + constructor_args[2] = filename; + call_user_function(EG(function_table), &ex, constructor, constructor_retval, 3, constructor_args TSRMLS_CC); + + zval_ptr_dtor(&constructor_retval); + zval_ptr_dtor(&zmessage); + zval_ptr_dtor(&lineno); + zval_ptr_dtor(&filename); + FREE_DTOR(constructor); + FREE_DTOR(filename_func); + efree(buffer); + + zend_throw_exception_object(ex TSRMLS_CC); +} + +static char *TWIG_GET_CLASS_NAME(zval *object TSRMLS_DC) { char *class_name; zend_uint class_name_len; @@ -616,11 +629,15 @@ char *TWIG_GET_CLASS_NAME(zval *object TSRMLS_DC) if (Z_TYPE_P(object) != IS_OBJECT) { return ""; } +#if PHP_API_VERSION >= 20100412 + zend_get_object_classname(object, (const char **) &class_name, &class_name_len TSRMLS_CC); +#else zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC); +#endif return class_name; } -static int twig_add_method_to_class(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int twig_add_method_to_class(void *pDest APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { zval *retval; char *item; @@ -642,7 +659,7 @@ static int twig_add_method_to_class(void *pDest TSRMLS_DC, int num_args, va_list return 0; } -static int twig_add_property_to_class(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int twig_add_property_to_class(void *pDest APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { zend_class_entry *ce; zval *retval; @@ -656,32 +673,17 @@ static int twig_add_property_to_class(void *pDest TSRMLS_DC, int num_args, va_li ce = *va_arg(args, zend_class_entry**); retval = va_arg(args, zval*); +#if PHP_API_VERSION >= 20100412 + zend_unmangle_property_name(pptr->name, pptr->name_length, (const char **) &class_name, (const char **) &prop_name); +#else zend_unmangle_property_name(pptr->name, pptr->name_length, &class_name, &prop_name); +#endif add_assoc_string(retval, prop_name, prop_name, 1); return 0; } -/* {{{ _adddynproperty */ -static int twig_add_dyn_property_to_class(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) -{ - zend_class_entry *ce = *va_arg(args, zend_class_entry**); - zval *retval = va_arg(args, zval*), member; - char *class_name, *prop_name; - - if (hash_key->nKeyLength < 1 || hash_key->arKey[0] == '\0') { - return 0; /* non public cannot be dynamic */ - } - - ZVAL_STRINGL(&member, hash_key->arKey, hash_key->nKeyLength-1, 0); - if (zend_get_property_info(ce, &member, 1 TSRMLS_CC) == &EG(std_property_info)) { - zend_unmangle_property_name((&EG(std_property_info))->name, (&EG(std_property_info))->name_length, &class_name, &prop_name); - add_assoc_string(retval, prop_name, prop_name, 1); - } - return 0; -} - static void twig_add_class_to_cache(zval *cache, zval *object, char *class_name TSRMLS_DC) { zval *class_info, *class_methods, *class_properties; @@ -696,13 +698,9 @@ static void twig_add_class_to_cache(zval *cache, zval *object, char *class_name array_init(class_methods); array_init(class_properties); // add all methods to self::cache[$class]['methods'] - zend_hash_apply_with_arguments(&class_ce->function_table TSRMLS_CC, twig_add_method_to_class, 1, class_methods); - zend_hash_apply_with_arguments(&class_ce->properties_info TSRMLS_CC, twig_add_property_to_class, 2, &class_ce, class_properties); + zend_hash_apply_with_arguments(&class_ce->function_table APPLY_TSRMLS_CC, twig_add_method_to_class, 1, class_methods); + zend_hash_apply_with_arguments(&class_ce->properties_info APPLY_TSRMLS_CC, twig_add_property_to_class, 2, &class_ce, class_properties); - if (object && Z_OBJ_HT_P(object)->get_properties) { - HashTable *properties = Z_OBJ_HT_P(object)->get_properties(object TSRMLS_CC); - zend_hash_apply_with_arguments(properties TSRMLS_CC, twig_add_dyn_property_to_class, 2, &class_ce, class_properties); - } add_assoc_zval(class_info, "methods", class_methods); add_assoc_zval(class_info, "properties", class_properties); add_assoc_zval(cache, class_name, class_info); @@ -734,6 +732,16 @@ PHP_FUNCTION(twig_template_get_attributes) INIT_PZVAL(&zitem); ZVAL_STRINGL(&zitem, item, item_len, 0); + switch (is_numeric_string(item, item_len, &Z_LVAL(zitem), &Z_DVAL(zitem), 0)) { + case IS_LONG: + Z_TYPE(zitem) = IS_LONG; + break; + case IS_DOUBLE: + Z_TYPE(zitem) = IS_DOUBLE; + convert_to_long(&zitem); + break; + } + if (!type) { type = "any"; } @@ -763,6 +771,9 @@ PHP_FUNCTION(twig_template_get_attributes) } ret = TWIG_GET_ARRAY_ELEMENT(object, item, item_len TSRMLS_CC); + if (!ret) { + ret = &EG(uninitialized_zval); + } RETVAL_ZVAL(ret, 1, 0); if (free_ret) { zval_ptr_dtor(&ret); @@ -787,18 +798,21 @@ PHP_FUNCTION(twig_template_get_attributes) } /* if (is_object($object)) { - throw new Twig_Error_Runtime(sprintf('Key "%s" in object (with ArrayAccess) of type "%s" does not exist', $item, get_class($object))); - // array + throw new Twig_Error_Runtime(sprintf('Key "%s" in object (with ArrayAccess) of type "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName()); + } elseif (is_array($object)) { + throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $item, implode(', ', array_keys($object))), -1, $this->getTemplateName()); } else { - throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $item, implode(', ', array_keys($object)))); + throw new Twig_Error_Runtime(sprintf('Impossible to access a key ("%s") on a "%s" variable', $item, gettype($object)), -1, $this->getTemplateName()); } } } */ if (Z_TYPE_P(object) == IS_OBJECT) { - TWIG_THROW_EXCEPTION("Twig_Error_Runtime" TSRMLS_CC, "Key \"%s\" in object (with ArrayAccess) of type \"%s\" does not exist", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC)); + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" in object (with ArrayAccess) of type \"%s\" does not exist", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC)); + } else if (Z_TYPE_P(object) == IS_ARRAY) { + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist", item, TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC)); } else { - TWIG_THROW_EXCEPTION("Twig_Error_Runtime" TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist", item, TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC)); + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to access a key (\"%s\") on a \"%s\" variable", item, zend_zval_type_name(object)); } return; } @@ -826,11 +840,11 @@ PHP_FUNCTION(twig_template_get_attributes) RETURN_FALSE; } if (Z_TYPE_P(object) == IS_ARRAY) { - TWIG_THROW_EXCEPTION("Twig_Error_Runtime" TSRMLS_CC, "Item \"%s\" for \"Array\" does not exist", item); + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Item \"%s\" for \"Array\" does not exist", item); } else { Z_ADDREF_P(object); convert_to_string_ex(&object); - TWIG_THROW_EXCEPTION("Twig_Error_Runtime" TSRMLS_CC, "Item \"%s\" for \"%s\" does not exist", item, Z_STRVAL_P(object)); + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Item \"%s\" for \"%s\" does not exist", item, Z_STRVAL_P(object)); zval_ptr_dtor(&object); } return; @@ -890,8 +904,7 @@ PHP_FUNCTION(twig_template_get_attributes) efree(class_name); - if (tmp_item || TWIG_HAS_PROPERTY(object, &zitem TSRMLS_CC) || TWIG_ARRAY_KEY_EXISTS(object, item, item_len) // FIXME: Array key? is that array access here? - ) { + if (tmp_item || TWIG_HAS_PROPERTY(object, &zitem TSRMLS_CC) || TWIG_HAS_DYNAMIC_PROPERTY(object, item, item_len TSRMLS_CC)) { if (isDefinedTest) { RETURN_TRUE; } @@ -962,15 +975,20 @@ PHP_FUNCTION(twig_template_get_attributes) } */ } else { + efree(tmp_method_name_get); + efree(tmp_method_name_is); + efree(lcItem); + if (isDefinedTest) { RETURN_FALSE; } if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { return; } - TWIG_THROW_EXCEPTION("Twig_Error_Runtime" TSRMLS_CC, "Method \"%s\" for object \"%s\" does not exist", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC)); + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Method \"%s\" for object \"%s\" does not exist", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC)); return; } + if (isDefinedTest) { efree(tmp_method_name_get); efree(tmp_method_name_is); @@ -986,6 +1004,9 @@ PHP_FUNCTION(twig_template_get_attributes) TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getExtension", "sandbox" TSRMLS_CC), "checkMethodAllowed", object, &zitem TSRMLS_CC); } if (EG(exception)) { + efree(tmp_method_name_get); + efree(tmp_method_name_is); + efree(lcItem); return; } /* @@ -1001,22 +1022,27 @@ PHP_FUNCTION(twig_template_get_attributes) } /* if ($object instanceof Twig_TemplateInterface) { - return new Twig_Markup($ret, $this->env->getCharset()); + return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset()); } -*/ - if (TWIG_INSTANCE_OF_USERLAND(object, "Twig_TemplateInterface" TSRMLS_CC)) { - zval *charset = TWIG_CALL_USER_FUNC_ARRAY(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getCharset", NULL TSRMLS_CC); - TWIG_NEW(return_value, "Twig_Markup", ret, charset TSRMLS_CC); - zval_ptr_dtor(&charset); - if (ret) { - zval_ptr_dtor(&ret); - } - return; - } -/* + return $ret; */ + // ret can be null, if e.g. the called method throws an exception if (ret) { + if (TWIG_INSTANCE_OF_USERLAND(object, "Twig_TemplateInterface" TSRMLS_CC)) { + if (Z_STRVAL_P(ret) == "") { + free_ret = 1; + } else { + zval *charset = TWIG_CALL_USER_FUNC_ARRAY(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getCharset", NULL TSRMLS_CC); + TWIG_NEW(return_value, "Twig_Markup", ret, charset TSRMLS_CC); + zval_ptr_dtor(&charset); + if (ret) { + zval_ptr_dtor(&ret); + } + return; + } + } + RETVAL_ZVAL(ret, 1, 0); if (free_ret) { zval_ptr_dtor(&ret); diff --git a/core/vendor/twig/twig/lib/Twig/Autoloader.php b/core/vendor/twig/twig/lib/Twig/Autoloader.php index 59f28f72fe0f..9bcec43c812d 100644 --- a/core/vendor/twig/twig/lib/Twig/Autoloader.php +++ b/core/vendor/twig/twig/lib/Twig/Autoloader.php @@ -20,7 +20,7 @@ class Twig_Autoloader /** * Registers Twig_Autoloader as an SPL autoloader. */ - static public function register() + public static function register() { ini_set('unserialize_callback_func', 'spl_autoload_call'); spl_autoload_register(array(new self, 'autoload')); @@ -31,7 +31,7 @@ static public function register() * * @param string $class A class name. */ - static public function autoload($class) + public static function autoload($class) { if (0 !== strpos($class, 'Twig')) { return; diff --git a/core/vendor/twig/twig/lib/Twig/Compiler.php b/core/vendor/twig/twig/lib/Twig/Compiler.php index d03dfa09eb13..c1ab250bc6a6 100644 --- a/core/vendor/twig/twig/lib/Twig/Compiler.php +++ b/core/vendor/twig/twig/lib/Twig/Compiler.php @@ -25,6 +25,7 @@ class Twig_Compiler implements Twig_CompilerInterface protected $debugInfo; protected $sourceOffset; protected $sourceLine; + protected $filename; /** * Constructor. @@ -37,6 +38,11 @@ public function __construct(Twig_Environment $env) $this->debugInfo = array(); } + public function getFilename() + { + return $this->filename; + } + /** * Returns the environment instance related to this compiler. * @@ -70,9 +76,14 @@ public function compile(Twig_NodeInterface $node, $indentation = 0) $this->lastLine = null; $this->source = ''; $this->sourceOffset = 0; - $this->sourceLine = 0; + // source code starts at 1 (as we then increment it when we encounter new lines) + $this->sourceLine = 1; $this->indentation = $indentation; + if ($node instanceof Twig_Node_Module) { + $this->filename = $node->getAttribute('filename'); + } + $node->compile($this); return $this; @@ -197,6 +208,8 @@ public function repr($value) public function addDebugInfo(Twig_NodeInterface $node) { if ($node->getLine() != $this->lastLine) { + $this->write("// line {$node->getLine()}\n"); + // when mbstring.func_overload is set to 2 // mb_substr_count() replaces substr_count() // but they have different signatures! @@ -210,7 +223,6 @@ public function addDebugInfo(Twig_NodeInterface $node) $this->debugInfo[$this->sourceLine] = $node->getLine(); $this->lastLine = $node->getLine(); - $this->write("// line {$node->getLine()}\n"); } return $this; @@ -246,7 +258,7 @@ public function outdent($step = 1) { // can't outdent by more steps that the current indentation level if ($this->indentation < $step) { - throw new Twig_Error('Unable to call outdent() as the indentation would become negative'); + throw new LogicException('Unable to call outdent() as the indentation would become negative'); } $this->indentation -= $step; diff --git a/core/vendor/twig/twig/lib/Twig/CompilerInterface.php b/core/vendor/twig/twig/lib/Twig/CompilerInterface.php index f8613813d5b7..89d87e6b970b 100644 --- a/core/vendor/twig/twig/lib/Twig/CompilerInterface.php +++ b/core/vendor/twig/twig/lib/Twig/CompilerInterface.php @@ -24,12 +24,12 @@ interface Twig_CompilerInterface * * @return Twig_CompilerInterface The current compiler instance */ - function compile(Twig_NodeInterface $node); + public function compile(Twig_NodeInterface $node); /** * Gets the current PHP code after compilation. * * @return string The PHP code */ - function getSource(); + public function getSource(); } diff --git a/core/vendor/twig/twig/lib/Twig/Environment.php b/core/vendor/twig/twig/lib/Twig/Environment.php index 00ebcbae50e2..39e2c76ea927 100644 --- a/core/vendor/twig/twig/lib/Twig/Environment.php +++ b/core/vendor/twig/twig/lib/Twig/Environment.php @@ -17,7 +17,7 @@ */ class Twig_Environment { - const VERSION = '1.8.3'; + const VERSION = '1.11.1'; protected $charset; protected $loader; @@ -711,7 +711,7 @@ public function getTokenParsers() } elseif ($parser instanceof Twig_TokenParserBrokerInterface) { $this->parsers->addTokenParserBroker($parser); } else { - throw new Twig_Error_Runtime('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances'); + throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances'); } } } @@ -1100,6 +1100,6 @@ protected function writeCacheFile($file, $content) } } - throw new Twig_Error_Runtime(sprintf('Failed to write cache file "%s".', $file)); + throw new RuntimeException(sprintf('Failed to write cache file "%s".', $file)); } } diff --git a/core/vendor/twig/twig/lib/Twig/Error.php b/core/vendor/twig/twig/lib/Twig/Error.php index 4b74e4007475..138151b770f9 100644 --- a/core/vendor/twig/twig/lib/Twig/Error.php +++ b/core/vendor/twig/twig/lib/Twig/Error.php @@ -12,6 +12,23 @@ /** * Twig base exception. * + * This exception class and its children must only be used when + * an error occurs during the loading of a template, when a syntax error + * is detected in a template, or when rendering a template. Other + * errors must use regular PHP exception classes (like when the template + * cache directory is not writable for instance). + * + * To help debugging template issues, this class tracks the original template + * name and line where the error occurred. + * + * Whenever possible, you must set these information (original template name + * and line number) yourself by passing them to the constructor. If some or all + * these information are not available from where you throw the exception, then + * this class will guess them automatically (when the line number is set to -1 + * and/or the filename is set to null). As this is a costly operation, this + * can be disabled by passing false for both the filename and the line number + * when creating a new instance of this class. + * * @package twig * @author Fabien Potencier <fabien@symfony.com> */ @@ -25,6 +42,15 @@ class Twig_Error extends Exception /** * Constructor. * + * Set both the line number and the filename to false to + * disable automatic guessing of the original template name + * and line number. + * + * Set the line number to -1 to enable its automatic guessing. + * Set the filename to null to enable its automatic guessing. + * + * By default, automatic guessing is enabled. + * * @param string $message The error message * @param integer $lineno The template line where the error occurred * @param string $filename The template file name where the error occurred @@ -105,6 +131,12 @@ public function setTemplateLine($lineno) $this->updateRepr(); } + public function guess() + { + $this->guessTemplateInfo(); + $this->updateRepr(); + } + /** * For PHP < 5.3.0, provides access to the getPrevious() method. * @@ -112,6 +144,8 @@ public function setTemplateLine($lineno) * @param array $arguments The parameters to be passed to the method * * @return Exception The previous exception or null + * + * @throws BadMethodCallException */ public function __call($method, $arguments) { @@ -132,7 +166,7 @@ protected function updateRepr() $dot = true; } - if (null !== $this->filename) { + if ($this->filename) { if (is_string($this->filename) || (is_object($this->filename) && method_exists($this->filename, '__toString'))) { $filename = sprintf('"%s"', $this->filename); } else { @@ -141,7 +175,7 @@ protected function updateRepr() $this->message .= sprintf(' in %s', $filename); } - if ($this->lineno >= 0) { + if ($this->lineno && $this->lineno >= 0) { $this->message .= sprintf(' at line %d', $this->lineno); } @@ -155,17 +189,17 @@ protected function guessTemplateInfo() $template = null; foreach (debug_backtrace() as $trace) { if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) { - $template = $trace['object']; - - // update template filename - if (null === $this->filename) { - $this->filename = $template->getTemplateName(); + if (null === $this->filename || $this->filename == $trace['object']->getTemplateName()) { + $template = $trace['object']; } - - break; } } + // update template filename + if (null !== $template && null === $this->filename) { + $this->filename = $template->getTemplateName(); + } + if (null === $template || $this->lineno > -1) { return; } diff --git a/core/vendor/twig/twig/lib/Twig/Error/Loader.php b/core/vendor/twig/twig/lib/Twig/Error/Loader.php index 418a7760aa50..7124974b8dc7 100644 --- a/core/vendor/twig/twig/lib/Twig/Error/Loader.php +++ b/core/vendor/twig/twig/lib/Twig/Error/Loader.php @@ -12,9 +12,21 @@ /** * Exception thrown when an error occurs during template loading. * + * Automatic template information guessing is always turned off as + * if a template cannot be loaded, there is nothing to guess. + * However, when a template is loaded from another one, then, we need + * to find the current context and this is automatically done by + * Twig_Template::displayWithErrorHandling(). + * + * This strategy makes Twig_Environment::resolveTemplate() much faster. + * * @package twig * @author Fabien Potencier <fabien@symfony.com> */ class Twig_Error_Loader extends Twig_Error { + public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null) + { + parent::__construct($message, false, false, $previous); + } } diff --git a/core/vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php b/core/vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php new file mode 100644 index 000000000000..0e08a1dfcd18 --- /dev/null +++ b/core/vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Adds an exists() method for loaders. + * + * @package twig + * @author Florin Patan <florinpatan@gmail.com> + */ +interface Twig_ExistsLoaderInterface +{ + /** + * Check if we have the source code of a template, given its name. + * + * @param string $name The name of the template to check if we can load + * + * @return boolean If the template source code is handled by this loader or not + */ + public function exists($name); +} diff --git a/core/vendor/twig/twig/lib/Twig/ExpressionParser.php b/core/vendor/twig/twig/lib/Twig/ExpressionParser.php index 0f35930636af..3309bb52db75 100644 --- a/core/vendor/twig/twig/lib/Twig/ExpressionParser.php +++ b/core/vendor/twig/twig/lib/Twig/ExpressionParser.php @@ -158,7 +158,7 @@ public function parsePrimaryExpression() } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) { $node = $this->parseHashExpression(); } else { - throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine()); + throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine(), $this->parser->getFilename()); } } @@ -252,7 +252,7 @@ public function parseHashExpression() } else { $current = $stream->getCurrent(); - throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($current->getType(), $current->getLine()), $current->getValue()), $current->getLine()); + throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($current->getType(), $current->getLine()), $current->getValue()), $current->getLine(), $this->parser->getFilename()); } $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)'); @@ -291,11 +291,11 @@ public function getFunctionNode($name, $line) switch ($name) { case 'parent': if (!count($this->parser->getBlockStack())) { - throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line); + throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line, $this->parser->getFilename()); } if (!$this->parser->getParent() && !$this->parser->hasTraits()) { - throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden', $line); + throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden', $line, $this->parser->getFilename()); } return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line); @@ -303,12 +303,12 @@ public function getFunctionNode($name, $line) return new Twig_Node_Expression_BlockReference($args->getNode(0), false, $line); case 'attribute': if (count($args) < 2) { - throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes)', $line); + throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes)', $line, $this->parser->getFilename()); } return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : new Twig_Node_Expression_Array(array(), $line), Twig_TemplateInterface::ANY_CALL, $line); default: - if (null !== $alias = $this->parser->getImportedFunction($name)) { + if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) { $arguments = new Twig_Node_Expression_Array(array(), $line); foreach ($args as $n) { $arguments->addElement($n); @@ -351,7 +351,7 @@ public function parseSubscriptExpression($node) } } } else { - throw new Twig_Error_Syntax('Expected name or number', $lineno); + throw new Twig_Error_Syntax('Expected name or number', $lineno, $this->parser->getFilename()); } } else { $type = Twig_TemplateInterface::ARRAY_CALL; @@ -380,6 +380,13 @@ public function parseSubscriptExpression($node) $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']'); } + if ($node instanceof Twig_Node_Expression_Name && null !== $alias = $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) { + $node = new Twig_Node_Expression_MethodCall($node, 'get'.$arg->getAttribute('value'), $arguments, $lineno); + $node->setAttribute('safe', true); + + return $node; + } + return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno); } @@ -439,7 +446,7 @@ public function parseAssignmentExpression() while (true) { $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to'); if (in_array($token->getValue(), array('true', 'false', 'none'))) { - throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s"', $token->getValue()), $token->getLine()); + throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s"', $token->getValue()), $token->getLine(), $this->parser->getFilename()); } $targets[] = new Twig_Node_Expression_AssignName($token->getValue(), $token->getLine()); diff --git a/core/vendor/twig/twig/lib/Twig/Extension/Core.php b/core/vendor/twig/twig/lib/Twig/Extension/Core.php index 27c80cecb030..3db899f75017 100644 --- a/core/vendor/twig/twig/lib/Twig/Extension/Core.php +++ b/core/vendor/twig/twig/lib/Twig/Extension/Core.php @@ -62,6 +62,10 @@ public function setTimezone($timezone) */ public function getTimezone() { + if (null === $this->timezone) { + $this->timezone = new DateTimeZone(date_default_timezone_get()); + } + return $this->timezone; } @@ -123,6 +127,7 @@ public function getFilters() $filters = array( // formatting filters 'date' => new Twig_Filter_Function('twig_date_format_filter', array('needs_environment' => true)), + 'date_modify' => new Twig_Filter_Function('twig_date_modify_filter', array('needs_environment' => true)), 'format' => new Twig_Filter_Function('sprintf'), 'replace' => new Twig_Filter_Function('strtr'), 'number_format' => new Twig_Filter_Function('twig_number_format_filter', array('needs_environment' => true)), @@ -144,6 +149,7 @@ public function getFilters() // array helpers 'join' => new Twig_Filter_Function('twig_join_filter'), + 'split' => new Twig_Filter_Function('twig_split_filter'), 'sort' => new Twig_Filter_Function('twig_sort_filter'), 'merge' => new Twig_Filter_Function('twig_array_merge'), @@ -222,11 +228,11 @@ public function getOperators() '+' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'), ), array( - 'b-and' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'b-xor' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'b-or' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'or' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'and' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-or' => array('precedence' => 16, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-xor' => array('precedence' => 17, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-and' => array('precedence' => 18, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '!=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '<' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), @@ -313,8 +319,8 @@ function twig_cycle($values, $i) * - a random character from a string * - a random integer between 0 and the integer parameter * - * @param Twig_Environment $env A Twig_Environment instance - * @param Traversable|array|int|string $values The values to pick a random item from + * @param Twig_Environment $env A Twig_Environment instance + * @param Traversable|array|integer|string $values The values to pick a random item from * * @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is). * @@ -378,7 +384,7 @@ function twig_random(Twig_Environment $env, $values = null) * @param string $format A format * @param DateTimeZone|string $timezone A timezone * - * @return string The formatter date + * @return string The formatted date */ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $timezone = null) { @@ -387,18 +393,34 @@ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $ $format = $date instanceof DateInterval ? $formats[1] : $formats[0]; } - if ($date instanceof DateInterval || $date instanceof DateTime) { - if (null !== $timezone) { - $date = clone $date; - $date->setTimezone($timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone)); - } - + if ($date instanceof DateInterval) { return $date->format($format); } return twig_date_converter($env, $date, $timezone)->format($format); } +/** + * Returns a new date object modified + * + * <pre> + * {{ post.published_at|modify("-1day")|date("m/d/Y") }} + * </pre> + * + * @param Twig_Environment $env A Twig_Environment instance + * @param DateTime|string $date A date + * @param string $modifier A modifier string + * + * @return DateTime A new date object + */ +function twig_date_modify_filter(Twig_Environment $env, $date, $modifier) +{ + $date = twig_date_converter($env, $date, false); + $date->modify($modifier); + + return $date; +} + /** * Converts an input to a DateTime instance. * @@ -416,32 +438,33 @@ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $ */ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null) { - if (!$date instanceof DateTime) { - $asString = (string) $date; - - if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) { - $date = new DateTime('@'.$date); - } else { - $date = new DateTime($date); - } + // determine the timezone + if (!$timezone) { + $defaultTimezone = $env->getExtension('core')->getTimezone(); + } elseif (!$timezone instanceof DateTimeZone) { + $defaultTimezone = new DateTimeZone($timezone); } else { - $date = clone $date; + $defaultTimezone = $timezone; } - // set Timezone - if (null !== $timezone) { - if ($timezone instanceof DateTimeZone) { - $date->setTimezone($timezone); - } else { - $date->setTimezone(new DateTimeZone($timezone)); + if ($date instanceof DateTime) { + $date = clone $date; + if (false !== $timezone) { + $date->setTimezone($defaultTimezone); } - } elseif (($timezone = $env->getExtension('core')->getTimezone()) instanceof DateTimeZone) { - $date->setTimezone($timezone); - } else { - $date->setTimezone(new DateTimeZone(date_default_timezone_get())); + + return $date; } - return $date; + $asString = (string) $date; + if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) { + $date = new DateTime('@'.$date); + $date->setTimezone($defaultTimezone); + + return $date; + } + + return new DateTime($date, $defaultTimezone); } /** @@ -453,7 +476,7 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu * * @param Twig_Environment $env A Twig_Environment instance * @param mixed $number A float/int/string of the number to format - * @param int $decimal The number of decimal points to display. + * @param integer $decimal The number of decimal points to display. * @param string $decimalPoint The character(s) to use for the decimal point. * @param string $thousandSep The character(s) to use for the thousands separator. * @@ -623,6 +646,38 @@ function twig_join_filter($value, $glue = '') return implode($glue, (array) $value); } +/** + * Splits the string into an array. + * + * <pre> + * {{ "one,two,three"|split(',') }} + * {# returns [one, two, three] #} + * + * {{ "one,two,three,four,five"|split(',', 3) }} + * {# returns [one, two, "three,four,five"] #} + * + * {{ "123"|split('') }} + * {# returns [1, 2, 3] #} + * + * {{ "aabbcc"|split('', 2) }} + * {# returns [aa, bb, cc] #} + * </pre> + * + * @param string $value A string + * @param string $delimiter The delimiter + * @param integer $limit The limit + * + * @return array The split string as an array + */ +function twig_split_filter($value, $delimiter, $limit = null) +{ + if (empty($delimiter)) { + return str_split($value, null === $limit ? 1 : $limit); + } + + return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit); +} + // The '_default' filter is used internally to avoid using the ternary operator // which costs a lot for big contexts (before PHP 5.4). So, on average, // a function call is cheaper. @@ -718,8 +773,10 @@ function twig_sort_filter($array) /* used internally */ function twig_in_filter($value, $compare) { + $strict = is_object($value); + if (is_array($compare)) { - return in_array($value, $compare); + return in_array($value, $compare, $strict); } elseif (is_string($compare)) { if (!strlen((string) $value)) { return empty($compare); @@ -727,7 +784,7 @@ function twig_in_filter($value, $compare) return false !== strpos($compare, (string) $value); } elseif (is_object($compare) && $compare instanceof Traversable) { - return in_array($value, iterator_to_array($compare, false)); + return in_array($value, iterator_to_array($compare, false), $strict); } return false; @@ -766,10 +823,46 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $string = twig_convert_encoding($string, 'UTF-8', $charset); } - if (null === $string = preg_replace_callback('#[^\p{L}\p{N} ]#u', '_twig_escape_js_callback', $string)) { + if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) { + throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.'); + } + + $string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '_twig_escape_js_callback', $string); + + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, $charset, 'UTF-8'); + } + + return $string; + + case 'css': + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, 'UTF-8', $charset); + } + + if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) { throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.'); } + $string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '_twig_escape_css_callback', $string); + + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, $charset, 'UTF-8'); + } + + return $string; + + case 'html_attr': + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, 'UTF-8', $charset); + } + + if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) { + throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.'); + } + + $string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '_twig_escape_html_attr_callback', $string); + if ('UTF-8' != $charset) { $string = twig_convert_encoding($string, $charset, 'UTF-8'); } @@ -808,8 +901,15 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', return twig_convert_encoding($string, $charset, 'UTF-8'); + case 'url': + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + return str_replace('%7E', '~', rawurlencode($string)); + } + + return rawurlencode($string); + default: - throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: html, js).', $strategy)); + throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: html, js, url, css, and html_attr).', $strategy)); } } @@ -850,13 +950,89 @@ function _twig_escape_js_callback($matches) // \xHH if (!isset($char[1])) { - return '\\x'.substr('00'.bin2hex($char), -2); + return '\\x'.strtoupper(substr('00'.bin2hex($char), -2)); } // \uHHHH $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8'); - return '\\u'.substr('0000'.bin2hex($char), -4); + return '\\u'.strtoupper(substr('0000'.bin2hex($char), -4)); +} + +function _twig_escape_css_callback($matches) +{ + $char = $matches[0]; + + // \xHH + if (!isset($char[1])) { + $hex = ltrim(strtoupper(bin2hex($char)), '0'); + if (0 === strlen($hex)) { + $hex = '0'; + } + + return '\\'.$hex.' '; + } + + // \uHHHH + $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8'); + + return '\\'.ltrim(strtoupper(bin2hex($char)), '0').' '; +} + +/** + * This function is adapted from code coming from Zend Framework. + * + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +function _twig_escape_html_attr_callback($matches) +{ + /* + * While HTML supports far more named entities, the lowest common denominator + * has become HTML5's XML Serialisation which is restricted to the those named + * entities that XML supports. Using HTML entities would result in this error: + * XML Parsing Error: undefined entity + */ + static $entityMap = array( + 34 => 'quot', /* quotation mark */ + 38 => 'amp', /* ampersand */ + 60 => 'lt', /* less-than sign */ + 62 => 'gt', /* greater-than sign */ + ); + + $chr = $matches[0]; + $ord = ord($chr); + + /** + * The following replaces characters undefined in HTML with the + * hex entity for the Unicode replacement character. + */ + if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f)) { + return '�'; + } + + /** + * Check if the current character to escape has a name entity we should + * replace it with while grabbing the hex value of the character. + */ + if (strlen($chr) == 1) { + $hex = strtoupper(substr('00'.bin2hex($chr), -2)); + } else { + $chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8'); + $hex = strtoupper(substr('0000'.bin2hex($chr), -4)); + } + + $int = hexdec($hex); + if (array_key_exists($int, $entityMap)) { + return sprintf('&%s;', $entityMap[$int]); + } + + /** + * Per OWASP recommendations, we'll use hex entities for any other + * characters where a named entity does not exist. + */ + + return sprintf('&#x%s;', $hex); } // add multibyte extensions if possible @@ -944,8 +1120,7 @@ function twig_capitalize_string_filter(Twig_Environment $env, $string) } } // and byte fallback -else -{ +else { /** * Returns the length of a variable. * diff --git a/core/vendor/twig/twig/lib/Twig/Extension/Debug.php b/core/vendor/twig/twig/lib/Twig/Extension/Debug.php index 8059df051488..3dc4d2d20ed6 100644 --- a/core/vendor/twig/twig/lib/Twig/Extension/Debug.php +++ b/core/vendor/twig/twig/lib/Twig/Extension/Debug.php @@ -17,7 +17,7 @@ class Twig_Extension_Debug extends Twig_Extension */ public function getFunctions() { - // dump is safe if var_dump is overriden by xdebug + // dump is safe if var_dump is overridden by xdebug $isDumpOutputHtmlSafe = extension_loaded('xdebug') // false means that it was not set (and the default is on) or it explicitly enabled && (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump')) diff --git a/core/vendor/twig/twig/lib/Twig/Extension/Escaper.php b/core/vendor/twig/twig/lib/Twig/Extension/Escaper.php index c02c3a86c1b0..db1a50ef085c 100644 --- a/core/vendor/twig/twig/lib/Twig/Extension/Escaper.php +++ b/core/vendor/twig/twig/lib/Twig/Extension/Escaper.php @@ -105,4 +105,3 @@ function twig_raw_filter($string) { return $string; } - diff --git a/core/vendor/twig/twig/lib/Twig/Extension/StringLoader.php b/core/vendor/twig/twig/lib/Twig/Extension/StringLoader.php new file mode 100644 index 000000000000..90caf28a8c5f --- /dev/null +++ b/core/vendor/twig/twig/lib/Twig/Extension/StringLoader.php @@ -0,0 +1,64 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2012 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Extension_StringLoader extends Twig_Extension +{ + /** + * {@inheritdoc} + */ + public function getFunctions() + { + return array( + 'template_from_string' => new Twig_Function_Function('twig_template_from_string', array('needs_environment' => true)), + ); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'string_loader'; + } +} + +/** + * Loads a template from a string. + * + * <pre> + * {% include template_from_string("Hello {{ name }}") }} + * </pre> + * + * @param Twig_Environment $env A Twig_Environment instance + * @param string $template A template as a string + * + * @return Twig_Template A Twig_Template instance + */ +function twig_template_from_string(Twig_Environment $env, $template) +{ + static $loader; + + if (null === $loader) { + $loader = new Twig_Loader_String(); + } + + $current = $env->getLoader(); + $env->setLoader($loader); + try { + $template = $env->loadTemplate($template); + } catch (Exception $e) { + $env->setLoader($current); + + throw $e; + } + $env->setLoader($current); + + return $template; +} diff --git a/core/vendor/twig/twig/lib/Twig/ExtensionInterface.php b/core/vendor/twig/twig/lib/Twig/ExtensionInterface.php index 0bfed88c7a9e..fe20a4ebf262 100644 --- a/core/vendor/twig/twig/lib/Twig/ExtensionInterface.php +++ b/core/vendor/twig/twig/lib/Twig/ExtensionInterface.php @@ -24,61 +24,61 @@ interface Twig_ExtensionInterface * * @param Twig_Environment $environment The current Twig_Environment instance */ - function initRuntime(Twig_Environment $environment); + public function initRuntime(Twig_Environment $environment); /** * Returns the token parser instances to add to the existing list. * * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances */ - function getTokenParsers(); + public function getTokenParsers(); /** * Returns the node visitor instances to add to the existing list. * * @return array An array of Twig_NodeVisitorInterface instances */ - function getNodeVisitors(); + public function getNodeVisitors(); /** * Returns a list of filters to add to the existing list. * * @return array An array of filters */ - function getFilters(); + public function getFilters(); /** * Returns a list of tests to add to the existing list. * * @return array An array of tests */ - function getTests(); + public function getTests(); /** * Returns a list of functions to add to the existing list. * * @return array An array of functions */ - function getFunctions(); + public function getFunctions(); /** * Returns a list of operators to add to the existing list. * * @return array An array of operators */ - function getOperators(); + public function getOperators(); /** * Returns a list of global variables to add to the existing list. * * @return array An array of global variables */ - function getGlobals(); + public function getGlobals(); /** * Returns the name of the extension. * * @return string The extension name */ - function getName(); + public function getName(); } diff --git a/core/vendor/twig/twig/lib/Twig/FilterInterface.php b/core/vendor/twig/twig/lib/Twig/FilterInterface.php index f3980265498e..0a07c7c39e80 100644 --- a/core/vendor/twig/twig/lib/Twig/FilterInterface.php +++ b/core/vendor/twig/twig/lib/Twig/FilterInterface.php @@ -22,19 +22,19 @@ interface Twig_FilterInterface * * @return string The PHP code for the filter */ - function compile(); + public function compile(); - function needsEnvironment(); + public function needsEnvironment(); - function needsContext(); + public function needsContext(); - function getSafe(Twig_Node $filterArgs); + public function getSafe(Twig_Node $filterArgs); - function getPreservesSafety(); + public function getPreservesSafety(); - function getPreEscape(); + public function getPreEscape(); - function setArguments($arguments); + public function setArguments($arguments); - function getArguments(); + public function getArguments(); } diff --git a/core/vendor/twig/twig/lib/Twig/Function/Node.php b/core/vendor/twig/twig/lib/Twig/Function/Node.php index a687a8498ac6..df937e500972 100644 --- a/core/vendor/twig/twig/lib/Twig/Function/Node.php +++ b/core/vendor/twig/twig/lib/Twig/Function/Node.php @@ -15,7 +15,7 @@ * @package twig * @author Fabien Potencier <fabien@symfony.com> */ -class Twig_Function_Node extends Twig_Filter +class Twig_Function_Node extends Twig_Function { protected $class; diff --git a/core/vendor/twig/twig/lib/Twig/FunctionInterface.php b/core/vendor/twig/twig/lib/Twig/FunctionInterface.php index d402d17da22f..d652ac3c02c1 100644 --- a/core/vendor/twig/twig/lib/Twig/FunctionInterface.php +++ b/core/vendor/twig/twig/lib/Twig/FunctionInterface.php @@ -23,15 +23,15 @@ interface Twig_FunctionInterface * * @return string The PHP code for the function */ - function compile(); + public function compile(); - function needsEnvironment(); + public function needsEnvironment(); - function needsContext(); + public function needsContext(); - function getSafe(Twig_Node $filterArgs); + public function getSafe(Twig_Node $filterArgs); - function setArguments($arguments); + public function setArguments($arguments); - function getArguments(); + public function getArguments(); } diff --git a/core/vendor/twig/twig/lib/Twig/LexerInterface.php b/core/vendor/twig/twig/lib/Twig/LexerInterface.php index 2bec23542a0d..9c3d3d2ac23f 100644 --- a/core/vendor/twig/twig/lib/Twig/LexerInterface.php +++ b/core/vendor/twig/twig/lib/Twig/LexerInterface.php @@ -25,5 +25,5 @@ interface Twig_LexerInterface * * @return Twig_TokenStream A token stream instance */ - function tokenize($code, $filename = null); + public function tokenize($code, $filename = null); } diff --git a/core/vendor/twig/twig/lib/Twig/Loader/Array.php b/core/vendor/twig/twig/lib/Twig/Loader/Array.php index 87762643dcc6..e00910c60597 100644 --- a/core/vendor/twig/twig/lib/Twig/Loader/Array.php +++ b/core/vendor/twig/twig/lib/Twig/Loader/Array.php @@ -20,7 +20,7 @@ * @package twig * @author Fabien Potencier <fabien@symfony.com> */ -class Twig_Loader_Array implements Twig_LoaderInterface +class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { protected $templates; @@ -51,11 +51,7 @@ public function setTemplate($name, $template) } /** - * Gets the source code of a template, given its name. - * - * @param string $name The name of the template to load - * - * @return string The template source code + * {@inheritdoc} */ public function getSource($name) { @@ -68,11 +64,15 @@ public function getSource($name) } /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name The name of the template to load - * - * @return string The cache key + * {@inheritdoc} + */ + public function exists($name) + { + return isset($this->templates[(string) $name]); + } + + /** + * {@inheritdoc} */ public function getCacheKey($name) { @@ -85,10 +85,7 @@ public function getCacheKey($name) } /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * {@inheritdoc} */ public function isFresh($name, $time) { diff --git a/core/vendor/twig/twig/lib/Twig/Loader/Chain.php b/core/vendor/twig/twig/lib/Twig/Loader/Chain.php index a044905123fa..da61aca14bef 100644 --- a/core/vendor/twig/twig/lib/Twig/Loader/Chain.php +++ b/core/vendor/twig/twig/lib/Twig/Loader/Chain.php @@ -15,8 +15,9 @@ * @package twig * @author Fabien Potencier <fabien@symfony.com> */ -class Twig_Loader_Chain implements Twig_LoaderInterface +class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { + private $hasSourceCache = array(); protected $loaders; /** @@ -40,61 +41,96 @@ public function __construct(array $loaders = array()) public function addLoader(Twig_LoaderInterface $loader) { $this->loaders[] = $loader; + $this->hasSourceCache = array(); } /** - * Gets the source code of a template, given its name. - * - * @param string $name The name of the template to load - * - * @return string The template source code + * {@inheritdoc} */ public function getSource($name) { + $exceptions = array(); foreach ($this->loaders as $loader) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { + continue; + } + try { return $loader->getSource($name); } catch (Twig_Error_Loader $e) { + $exceptions[] = $e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(', ', $exceptions))); } /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name The name of the template to load - * - * @return string The cache key + * {@inheritdoc} + */ + public function exists($name) + { + $name = (string) $name; + + if (isset($this->hasSourceCache[$name])) { + return $this->hasSourceCache[$name]; + } + + foreach ($this->loaders as $loader) { + if ($loader instanceof Twig_ExistsLoaderInterface && $loader->exists($name)) { + return $this->hasSourceCache[$name] = true; + } + + try { + $loader->getSource($name); + + return $this->hasSourceCache[$name] = true; + } catch (Twig_Error_Loader $e) { + } + } + + return $this->hasSourceCache[$name] = false; + } + + /** + * {@inheritdoc} */ public function getCacheKey($name) { + $exceptions = array(); foreach ($this->loaders as $loader) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { + continue; + } + try { return $loader->getCacheKey($name); } catch (Twig_Error_Loader $e) { + $exceptions[] = get_class($loader).': '.$e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(' ', $exceptions))); } /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * {@inheritdoc} */ public function isFresh($name, $time) { + $exceptions = array(); foreach ($this->loaders as $loader) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { + continue; + } + try { return $loader->isFresh($name, $time); } catch (Twig_Error_Loader $e) { + $exceptions[] = get_class($loader).': '.$e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(' ', $exceptions))); } } diff --git a/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php b/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php index 18104a5d1070..8748e3d937f5 100644 --- a/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php +++ b/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php @@ -15,7 +15,7 @@ * @package twig * @author Fabien Potencier <fabien@symfony.com> */ -class Twig_Loader_Filesystem implements Twig_LoaderInterface +class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { protected $paths; protected $cache; @@ -33,36 +33,54 @@ public function __construct($paths) /** * Returns the paths to the templates. * + * @param string $namespace A path namespace + * * @return array The array of paths where to look for templates */ - public function getPaths() + public function getPaths($namespace = '__main__') + { + return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array(); + } + + /** + * Returns the path namespaces. + * + * The "__main__" namespace is always defined. + * + * @return array The array of defined namespaces + */ + public function getNamespaces() { - return $this->paths; + return array_keys($this->paths); } /** * Sets the paths where templates are stored. * - * @param string|array $paths A path or an array of paths where to look for templates + * @param string|array $paths A path or an array of paths where to look for templates + * @param string $namespace A path namespace */ - public function setPaths($paths) + public function setPaths($paths, $namespace = '__main__') { if (!is_array($paths)) { $paths = array($paths); } - $this->paths = array(); + $this->paths[$namespace] = array(); foreach ($paths as $path) { - $this->addPath($path); + $this->addPath($path, $namespace); } } /** * Adds a path where templates are stored. * - * @param string $path A path where to look for templates + * @param string $path A path where to look for templates + * @param string $namespace A path name + * + * @throws Twig_Error_Loader */ - public function addPath($path) + public function addPath($path, $namespace = '__main__') { // invalidate the cache $this->cache = array(); @@ -71,15 +89,37 @@ public function addPath($path) throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); } - $this->paths[] = rtrim($path, '/\\'); + $this->paths[$namespace][] = rtrim($path, '/\\'); } /** - * Gets the source code of a template, given its name. + * Prepends a path where templates are stored. * - * @param string $name The name of the template to load + * @param string $path A path where to look for templates + * @param string $namespace A path name * - * @return string The template source code + * @throws Twig_Error_Loader + */ + public function prependPath($path, $namespace = '__main__') + { + // invalidate the cache + $this->cache = array(); + + if (!is_dir($path)) { + throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); + } + + $path = rtrim($path, '/\\'); + + if (!isset($this->paths[$namespace])) { + $this->paths[$namespace][] = $path; + } else { + array_unshift($this->paths[$namespace], $path); + } + } + + /** + * {@inheritdoc} */ public function getSource($name) { @@ -87,11 +127,7 @@ public function getSource($name) } /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name The name of the template to load - * - * @return string The cache key + * {@inheritdoc} */ public function getCacheKey($name) { @@ -99,10 +135,26 @@ public function getCacheKey($name) } /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * {@inheritdoc} + */ + public function exists($name) + { + $name = (string) $name; + if (isset($this->cache[$name])) { + return true; + } + + try { + $this->findTemplate($name); + + return true; + } catch (Twig_Error_Loader $exception) { + return false; + } + } + + /** + * {@inheritdoc} */ public function isFresh($name, $time) { @@ -111,6 +163,8 @@ public function isFresh($name, $time) protected function findTemplate($name) { + $name = (string) $name; + // normalize name $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); @@ -120,13 +174,28 @@ protected function findTemplate($name) $this->validateName($name); - foreach ($this->paths as $path) { + $namespace = '__main__'; + if (isset($name[0]) && '@' == $name[0]) { + if (false === $pos = strpos($name, '/')) { + throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name)); + } + + $namespace = substr($name, 1, $pos - 1); + + $name = substr($name, $pos + 1); + } + + if (!isset($this->paths[$namespace])) { + throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace)); + } + + foreach ($this->paths[$namespace] as $path) { if (is_file($path.'/'.$name)) { return $this->cache[$name] = $path.'/'.$name; } } - throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths))); + throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]))); } protected function validateName($name) diff --git a/core/vendor/twig/twig/lib/Twig/Loader/String.php b/core/vendor/twig/twig/lib/Twig/Loader/String.php index bc792b12780a..6a4c0ab0b3f4 100644 --- a/core/vendor/twig/twig/lib/Twig/Loader/String.php +++ b/core/vendor/twig/twig/lib/Twig/Loader/String.php @@ -12,6 +12,10 @@ /** * Loads a template from a string. * + * This loader should only be used for unit testing as it has many limitations + * (for instance, the include or extends tag does not make any sense for a string + * loader). + * * When using this loader with a cache mechanism, you should know that a new cache * key is generated each time a template content "changes" (the cache key being the * source code of the template). If you don't want to see your cache grows out of @@ -20,14 +24,10 @@ * @package twig * @author Fabien Potencier <fabien@symfony.com> */ -class Twig_Loader_String implements Twig_LoaderInterface +class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { /** - * Gets the source code of a template, given its name. - * - * @param string $name The name of the template to load - * - * @return string The template source code + * {@inheritdoc} */ public function getSource($name) { @@ -35,11 +35,15 @@ public function getSource($name) } /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name The name of the template to load - * - * @return string The cache key + * {@inheritdoc} + */ + public function exists($name) + { + return true; + } + + /** + * {@inheritdoc} */ public function getCacheKey($name) { @@ -47,10 +51,7 @@ public function getCacheKey($name) } /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * {@inheritdoc} */ public function isFresh($name, $time) { diff --git a/core/vendor/twig/twig/lib/Twig/LoaderInterface.php b/core/vendor/twig/twig/lib/Twig/LoaderInterface.php index 55e3ac6357e0..3d69b141c8b6 100644 --- a/core/vendor/twig/twig/lib/Twig/LoaderInterface.php +++ b/core/vendor/twig/twig/lib/Twig/LoaderInterface.php @@ -26,7 +26,7 @@ interface Twig_LoaderInterface * * @throws Twig_Error_Loader When $name is not found */ - function getSource($name); + public function getSource($name); /** * Gets the cache key to use for the cache for a given template name. @@ -37,7 +37,7 @@ function getSource($name); * * @throws Twig_Error_Loader When $name is not found */ - function getCacheKey($name); + public function getCacheKey($name); /** * Returns true if the template is still fresh. @@ -49,5 +49,5 @@ function getCacheKey($name); * * @throws Twig_Error_Loader When $name is not found */ - function isFresh($name, $time); + public function isFresh($name, $time); } diff --git a/core/vendor/twig/twig/lib/Twig/Node.php b/core/vendor/twig/twig/lib/Twig/Node.php index 651ffc4d17c1..3048db502107 100644 --- a/core/vendor/twig/twig/lib/Twig/Node.php +++ b/core/vendor/twig/twig/lib/Twig/Node.php @@ -134,12 +134,12 @@ public function hasAttribute($name) * * @param string The attribute name * - * @return mixed The attribute value + * @return mixed The attribute value */ public function getAttribute($name) { if (!array_key_exists($name, $this->attributes)) { - throw new Twig_Error_Runtime(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this))); + throw new LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this))); } return $this->attributes[$name]; @@ -188,7 +188,7 @@ public function hasNode($name) public function getNode($name) { if (!array_key_exists($name, $this->nodes)) { - throw new Twig_Error_Runtime(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this))); + throw new LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this))); } return $this->nodes[$name]; diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php index 8a0903a5e98e..eb9cd310f8c0 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php @@ -26,7 +26,7 @@ public function compile(Twig_Compiler $compiler) $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); } - throw new Twig_Error_Syntax($message, $this->getLine()); + throw new Twig_Error_Syntax($message, $this->getLine(), $compiler->getFilename()); } $this->compileFilter($compiler, $filter); diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/Function.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/Function.php index 9342bb11b772..56403775a6fd 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/Function.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/Function.php @@ -25,7 +25,7 @@ public function compile(Twig_Compiler $compiler) $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); } - throw new Twig_Error_Syntax($message, $this->getLine()); + throw new Twig_Error_Syntax($message, $this->getLine(), $compiler->getFilename()); } $compiler->raw($function->compile().'('); diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php index 64984446385f..81a9b137abd1 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php @@ -13,12 +13,12 @@ class Twig_Node_Expression_GetAttr extends Twig_Node_Expression { public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression_Array $arguments, $type, $lineno) { - parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false), $lineno); + parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno); } public function compile(Twig_Compiler $compiler) { - if (function_exists('twig_template_get_attributes')) { + if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) { $compiler->raw('twig_template_get_attributes($this, '); } else { $compiler->raw('$this->getAttribute('); diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php index 50938084b506..620b02bf471e 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php @@ -13,6 +13,10 @@ class Twig_Node_Expression_MethodCall extends Twig_Node_Expression public function __construct(Twig_Node_Expression $node, $method, Twig_Node_Expression_Array $arguments, $lineno) { parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno); + + if ($node instanceof Twig_Node_Expression_Name) { + $node->setAttribute('always_defined', true); + } } public function compile(Twig_Compiler $compiler) diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/Name.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/Name.php index 8f5a1ea80804..3b8fae01dc6f 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/Name.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/Name.php @@ -19,7 +19,7 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression public function __construct($name, $lineno) { - parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false), $lineno); + parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno); } public function compile(Twig_Compiler $compiler) @@ -34,19 +34,31 @@ public function compile(Twig_Compiler $compiler) } } elseif ($this->isSpecial()) { $compiler->raw($this->specialVars[$name]); + } elseif ($this->getAttribute('always_defined')) { + $compiler + ->raw('$context[') + ->string($name) + ->raw(']') + ; } else { // remove the non-PHP 5.4 version when PHP 5.3 support is dropped // as the non-optimized version is just a workaround for slow ternary operator // when the context has a lot of variables - if (version_compare(phpversion(), '5.4.0RC1', '>=') && ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables())) { + if (version_compare(phpversion(), '5.4.0RC1', '>=')) { // PHP 5.4 ternary operator performance was optimized $compiler ->raw('(isset($context[') ->string($name) ->raw(']) ? $context[') ->string($name) - ->raw('] : null)') + ->raw('] : ') ; + + if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) { + $compiler->raw('null)'); + } else { + $compiler->raw('$this->getContext($context, ')->string($name)->raw('))'); + } } else { $compiler ->raw('$this->getContext($context, ') diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/Test.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/Test.php index 4e0b25e9a237..076e39dae2b6 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/Test.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/Test.php @@ -25,7 +25,7 @@ public function compile(Twig_Compiler $compiler) $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); } - throw new Twig_Error_Syntax($message, $this->getLine()); + throw new Twig_Error_Syntax($message, $this->getLine(), $compiler->getFilename()); } $name = $this->getAttribute('name'); diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php index e7c6828074f8..915e60ad771f 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php @@ -35,7 +35,7 @@ public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $this->changeIgnoreStrictCheck($node); } else { - throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine()); + throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine(), $compiler->getFilename()); } } diff --git a/core/vendor/twig/twig/lib/Twig/Node/Macro.php b/core/vendor/twig/twig/lib/Twig/Node/Macro.php index e0c3dcab1589..8bb5d9dfbe49 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Macro.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Macro.php @@ -31,7 +31,7 @@ public function compile(Twig_Compiler $compiler) { $arguments = array(); foreach ($this->getNode('arguments') as $argument) { - $arguments[] = '$'.$argument->getAttribute('name').' = null'; + $arguments[] = '$_'.$argument->getAttribute('name').' = null'; } $compiler @@ -52,7 +52,7 @@ public function compile(Twig_Compiler $compiler) $compiler ->write('') ->string($argument->getAttribute('name')) - ->raw(' => $'.$argument->getAttribute('name')) + ->raw(' => $_'.$argument->getAttribute('name')) ->raw(",\n") ; } @@ -70,13 +70,13 @@ public function compile(Twig_Compiler $compiler) ->indent() ->subcompile($this->getNode('body')) ->outdent() - ->write("} catch(Exception \$e) {\n") + ->write("} catch (Exception \$e) {\n") ->indent() ->write("ob_end_clean();\n\n") ->write("throw \$e;\n") ->outdent() ->write("}\n\n") - ->write("return ob_get_clean();\n") + ->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n") ->outdent() ->write("}\n\n") ; diff --git a/core/vendor/twig/twig/lib/Twig/Node/SandboxedModule.php b/core/vendor/twig/twig/lib/Twig/Node/SandboxedModule.php index 6dd63e5c93b8..c1b3bcef397f 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/SandboxedModule.php +++ b/core/vendor/twig/twig/lib/Twig/Node/SandboxedModule.php @@ -45,7 +45,7 @@ protected function compileDisplayFooter(Twig_Compiler $compiler) parent::compileDisplayFooter($compiler); $compiler - ->write("protected function checkSecurity() {\n") + ->write("protected function checkSecurity()\n", "{\n") ->indent() ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n") ->indent() diff --git a/core/vendor/twig/twig/lib/Twig/NodeInterface.php b/core/vendor/twig/twig/lib/Twig/NodeInterface.php index 29a84b03f81c..e77782f974dc 100644 --- a/core/vendor/twig/twig/lib/Twig/NodeInterface.php +++ b/core/vendor/twig/twig/lib/Twig/NodeInterface.php @@ -22,9 +22,9 @@ interface Twig_NodeInterface extends Countable, IteratorAggregate * * @param Twig_Compiler A Twig_Compiler instance */ - function compile(Twig_Compiler $compiler); + public function compile(Twig_Compiler $compiler); - function getLine(); + public function getLine(); - function getNodeTag(); + public function getNodeTag(); } diff --git a/core/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php b/core/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php index 5b1249d0c0a0..cc9a58b12dc8 100644 --- a/core/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php +++ b/core/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php @@ -22,6 +22,7 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface protected $safeAnalysis; protected $traverser; protected $defaultStrategy = false; + protected $safeVars = array(); public function __construct() { @@ -42,10 +43,13 @@ public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) if ($env->hasExtension('escaper') && $defaultStrategy = $env->getExtension('escaper')->getDefaultStrategy($node->getAttribute('filename'))) { $this->defaultStrategy = $defaultStrategy; } + $this->safeVars = array(); } elseif ($node instanceof Twig_Node_AutoEscape) { $this->statusStack[] = $node->getAttribute('value'); } elseif ($node instanceof Twig_Node_Block) { $this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env); + } elseif ($node instanceof Twig_Node_Import) { + $this->safeVars[] = $node->getNode('var')->getAttribute('name'); } return $node; @@ -63,6 +67,7 @@ public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) { if ($node instanceof Twig_Node_Module) { $this->defaultStrategy = false; + $this->safeVars = array(); } elseif ($node instanceof Twig_Node_Expression_Filter) { return $this->preEscapeFilterNode($node, $env); } elseif ($node instanceof Twig_Node_Print) { @@ -129,6 +134,9 @@ protected function isSafeFor($type, Twig_NodeInterface $expression, $env) if (null === $this->traverser) { $this->traverser = new Twig_NodeTraverser($env, array($this->safeAnalysis)); } + + $this->safeAnalysis->setSafeVars($this->safeVars); + $this->traverser->traverse($expression); $safe = $this->safeAnalysis->getSafe($expression); } diff --git a/core/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php b/core/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php index 7cc2e2241c1a..7dc65c0e6888 100644 --- a/core/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php +++ b/core/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php @@ -3,6 +3,12 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface { protected $data = array(); + protected $safeVars = array(); + + public function setSafeVars($safeVars) + { + $this->safeVars = $safeVars; + } public function getSafe(Twig_NodeInterface $node) { @@ -85,6 +91,14 @@ public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) } else { $this->setSafe($node, array()); } + } elseif ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name) { + $name = $node->getNode('node')->getAttribute('name'); + // attributes on template instances are safe + if ('_self' == $name || in_array($name, $this->safeVars)) { + $this->setSafe($node, array('all')); + } else { + $this->setSafe($node, array()); + } } else { $this->setSafe($node, array()); } diff --git a/core/vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php b/core/vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php index 61ef0c67c51c..1957f8a8d531 100644 --- a/core/vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php +++ b/core/vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php @@ -32,19 +32,6 @@ class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface */ public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) { - // in a sandbox tag, only include tags are allowed - if ($node instanceof Twig_Node_Sandbox && !$node->getNode('body') instanceof Twig_Node_Include) { - foreach ($node->getNode('body') as $n) { - if ($n instanceof Twig_Node_Text && ctype_space($n->getAttribute('data'))) { - continue; - } - - if (!$n instanceof Twig_Node_Include) { - throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $n->getLine()); - } - } - } - if ($node instanceof Twig_Node_Module) { $this->inAModule = true; $this->tags = array(); diff --git a/core/vendor/twig/twig/lib/Twig/NodeVisitorInterface.php b/core/vendor/twig/twig/lib/Twig/NodeVisitorInterface.php index e0123b5dc731..f4974c670a4e 100644 --- a/core/vendor/twig/twig/lib/Twig/NodeVisitorInterface.php +++ b/core/vendor/twig/twig/lib/Twig/NodeVisitorInterface.php @@ -25,7 +25,7 @@ interface Twig_NodeVisitorInterface * * @return Twig_NodeInterface The modified node */ - function enterNode(Twig_NodeInterface $node, Twig_Environment $env); + public function enterNode(Twig_NodeInterface $node, Twig_Environment $env); /** * Called after child nodes are visited. @@ -35,7 +35,7 @@ function enterNode(Twig_NodeInterface $node, Twig_Environment $env); * * @return Twig_NodeInterface The modified node */ - function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); + public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); /** * Returns the priority for this visitor. @@ -44,5 +44,5 @@ function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); * * @return integer The priority level */ - function getPriority(); + public function getPriority(); } diff --git a/core/vendor/twig/twig/lib/Twig/Parser.php b/core/vendor/twig/twig/lib/Twig/Parser.php index 8c578fd6bc96..1179913ca933 100644 --- a/core/vendor/twig/twig/lib/Twig/Parser.php +++ b/core/vendor/twig/twig/lib/Twig/Parser.php @@ -29,8 +29,7 @@ class Twig_Parser implements Twig_ParserInterface protected $macros; protected $env; protected $reservedMacroNames; - protected $importedFunctions; - protected $tmpVarCount; + protected $importedSymbols; protected $traits; protected $embeddedTemplates = array(); @@ -51,7 +50,12 @@ public function getEnvironment() public function getVarName() { - return sprintf('__internal_%s_%d', substr($this->env->getTemplateClass($this->stream->getFilename()), strlen($this->env->getTemplateClassPrefix())), ++$this->tmpVarCount); + return sprintf('__internal_%s', hash('sha1', uniqid(mt_rand(), true), false)); + } + + public function getFilename() + { + return $this->stream->getFilename(); } /** @@ -68,8 +72,6 @@ public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = fals unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser']); $this->stack[] = $vars; - $this->tmpVarCount = 0; - // tag handlers if (null === $this->handlers) { $this->handlers = $this->env->getTokenParsers(); @@ -91,7 +93,7 @@ public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = fals $this->macros = array(); $this->traits = array(); $this->blockStack = array(); - $this->importedFunctions = array(array()); + $this->importedSymbols = array(array()); $this->embeddedTemplates = array(); try { @@ -103,14 +105,18 @@ public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = fals } } } catch (Twig_Error_Syntax $e) { - if (null === $e->getTemplateFile()) { - $e->setTemplateFile($this->stream->getFilename()); + if (!$e->getTemplateFile()) { + $e->setTemplateFile($this->getFilename()); + } + + if (!$e->getTemplateLine()) { + $e->setTemplateLine($this->stream->getCurrent()->getLine()); } throw $e; } - $node = new Twig_Node_Module(new Twig_Node_Body(array($body)), $this->parent, new Twig_Node($this->blocks), new Twig_Node($this->macros), new Twig_Node($this->traits), $this->embeddedTemplates, $this->stream->getFilename()); + $node = new Twig_Node_Module(new Twig_Node_Body(array($body)), $this->parent, new Twig_Node($this->blocks), new Twig_Node($this->macros), new Twig_Node($this->traits), $this->embeddedTemplates, $this->getFilename()); $traverser = new Twig_NodeTraverser($this->env, $this->visitors); @@ -147,7 +153,7 @@ public function subparse($test, $dropNeedle = false) $token = $this->getCurrentToken(); if ($token->getType() !== Twig_Token::NAME_TYPE) { - throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine(), $this->stream->getFilename()); + throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine(), $this->getFilename()); } if (null !== $test && call_user_func($test, $token)) { @@ -165,7 +171,12 @@ public function subparse($test, $dropNeedle = false) $subparser = $this->handlers->getTokenParser($token->getValue()); if (null === $subparser) { if (null !== $test) { - throw new Twig_Error_Syntax(sprintf('Unexpected tag name "%s" (expecting closing tag for the "%s" tag defined near line %s)', $token->getValue(), $test[0]->getTag(), $lineno), $token->getLine(), $this->stream->getFilename()); + $error = sprintf('Unexpected tag name "%s"', $token->getValue()); + if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) { + $error .= sprintf(' (expecting closing tag for the "%s" tag defined near line %s)', $test[0]->getTag(), $lineno); + } + + throw new Twig_Error_Syntax($error, $token->getLine(), $this->getFilename()); } $message = sprintf('Unknown tag name "%s"', $token->getValue()); @@ -173,7 +184,7 @@ public function subparse($test, $dropNeedle = false) $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); } - throw new Twig_Error_Syntax($message, $token->getLine(), $this->stream->getFilename()); + throw new Twig_Error_Syntax($message, $token->getLine(), $this->getFilename()); } $this->stream->next(); @@ -185,7 +196,7 @@ public function subparse($test, $dropNeedle = false) break; default: - throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.', -1, $this->stream->getFilename()); + throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.', 0, $this->getFilename()); } } @@ -257,7 +268,7 @@ public function setMacro($name, Twig_Node_Macro $node) } if (in_array($name, $this->reservedMacroNames)) { - throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine()); + throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine(), $this->getFilename()); } $this->macros[$name] = $node; @@ -275,38 +286,38 @@ public function hasTraits() public function embedTemplate(Twig_Node_Module $template) { - $template->setIndex(count($this->embeddedTemplates) + 1); + $template->setIndex(mt_rand()); $this->embeddedTemplates[] = $template; } - public function addImportedFunction($alias, $name, Twig_Node_Expression $node) + public function addImportedSymbol($type, $alias, $name = null, Twig_Node_Expression $node = null) { - $this->importedFunctions[0][$alias] = array('name' => $name, 'node' => $node); + $this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node); } - public function getImportedFunction($alias) + public function getImportedSymbol($type, $alias) { - foreach ($this->importedFunctions as $functions) { - if (isset($functions[$alias])) { - return $functions[$alias]; + foreach ($this->importedSymbols as $functions) { + if (isset($functions[$type][$alias])) { + return $functions[$type][$alias]; } } } public function isMainScope() { - return 1 === count($this->importedFunctions); + return 1 === count($this->importedSymbols); } public function pushLocalScope() { - array_unshift($this->importedFunctions, array()); + array_unshift($this->importedSymbols, array()); } public function popLocalScope() { - array_shift($this->importedFunctions); + array_shift($this->importedSymbols); } /** @@ -358,10 +369,10 @@ protected function filterBodyNodes(Twig_NodeInterface $node) (!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface) ) { if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) { - throw new Twig_Error_Syntax('A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed.', $node->getLine(), $this->stream->getFilename()); + throw new Twig_Error_Syntax('A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed.', $node->getLine(), $this->getFilename()); } - throw new Twig_Error_Syntax('A template that extends another one cannot have a body.', $node->getLine(), $this->stream->getFilename()); + throw new Twig_Error_Syntax('A template that extends another one cannot have a body.', $node->getLine(), $this->getFilename()); } // bypass "set" nodes as they "capture" the output diff --git a/core/vendor/twig/twig/lib/Twig/ParserInterface.php b/core/vendor/twig/twig/lib/Twig/ParserInterface.php index 965984524c75..4de3999722c0 100644 --- a/core/vendor/twig/twig/lib/Twig/ParserInterface.php +++ b/core/vendor/twig/twig/lib/Twig/ParserInterface.php @@ -24,5 +24,5 @@ interface Twig_ParserInterface * * @return Twig_Node_Module A node tree */ - function parse(Twig_TokenStream $stream); + public function parse(Twig_TokenStream $stream); } diff --git a/core/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php b/core/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php index d5015affdbdb..655b16be5a65 100644 --- a/core/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php +++ b/core/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php @@ -17,9 +17,9 @@ */ interface Twig_Sandbox_SecurityPolicyInterface { - function checkSecurity($tags, $filters, $functions); + public function checkSecurity($tags, $filters, $functions); - function checkMethodAllowed($obj, $method); + public function checkMethodAllowed($obj, $method); - function checkPropertyAllowed($obj, $method); + public function checkPropertyAllowed($obj, $method); } diff --git a/core/vendor/twig/twig/lib/Twig/Template.php b/core/vendor/twig/twig/lib/Twig/Template.php index 7ecdba401045..a07862790c16 100644 --- a/core/vendor/twig/twig/lib/Twig/Template.php +++ b/core/vendor/twig/twig/lib/Twig/Template.php @@ -18,7 +18,7 @@ */ abstract class Twig_Template implements Twig_TemplateInterface { - static protected $cache = array(); + protected static $cache = array(); protected $parent; protected $parents; @@ -264,6 +264,17 @@ protected function displayWithErrorHandling(array $context, array $blocks = arra try { $this->doDisplay($context, $blocks); } catch (Twig_Error $e) { + if (!$e->getTemplateFile()) { + $e->setTemplateFile($this->getTemplateName()); + } + + // this is mostly useful for Twig_Error_Loader exceptions + // see Twig_Error_Loader + if (false === $e->getTemplateLine()) { + $e->setTemplateLine(-1); + $e->guess(); + } + throw $e; } catch (Exception $e) { throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, null, $e); @@ -284,7 +295,7 @@ abstract protected function doDisplay(array $context, array $blocks = array()); * This method is for internal use only and should never be called * directly. * - * This method should not be overriden in a sub-class as this is an + * This method should not be overridden in a sub-class as this is an * implementation detail that has been introduced to optimize variable * access for versions of PHP before 5.4. This is not a way to override * the way to get a variable value. @@ -304,7 +315,7 @@ final protected function getContext($context, $item, $ignoreStrictCheck = false) return null; } - throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist', $item)); + throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist', $item), -1, $this->getTemplateName()); } return $context[$item]; @@ -350,11 +361,11 @@ protected function getAttribute($object, $item, array $arguments = array(), $typ } if (is_object($object)) { - throw new Twig_Error_Runtime(sprintf('Key "%s" in object (with ArrayAccess) of type "%s" does not exist', $item, get_class($object))); + throw new Twig_Error_Runtime(sprintf('Key "%s" in object (with ArrayAccess) of type "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName()); } elseif (is_array($object)) { - throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $item, implode(', ', array_keys($object)))); + throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $item, implode(', ', array_keys($object))), -1, $this->getTemplateName()); } else { - throw new Twig_Error_Runtime(sprintf('Impossible to access a key ("%s") on a "%s" variable', $item, gettype($object))); + throw new Twig_Error_Runtime(sprintf('Impossible to access a key ("%s") on a "%s" variable', $item, gettype($object)), -1, $this->getTemplateName()); } } } @@ -368,7 +379,7 @@ protected function getAttribute($object, $item, array $arguments = array(), $typ return null; } - throw new Twig_Error_Runtime(sprintf('Item "%s" for "%s" does not exist', $item, is_array($object) ? 'Array' : $object)); + throw new Twig_Error_Runtime(sprintf('Item "%s" for "%s" does not exist', $item, is_array($object) ? 'Array' : $object), -1, $this->getTemplateName()); } $class = get_class($object); @@ -411,7 +422,7 @@ protected function getAttribute($object, $item, array $arguments = array(), $typ return null; } - throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object))); + throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName()); } if ($isDefinedTest) { @@ -424,7 +435,8 @@ protected function getAttribute($object, $item, array $arguments = array(), $typ $ret = call_user_func_array(array($object, $method), $arguments); - // hack to be removed when macro calls are refactored + // useful when calling a template method from a template + // this is not supported but unfortunately heavily used in the Symfony profiler if ($object instanceof Twig_TemplateInterface) { return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset()); } @@ -435,7 +447,7 @@ protected function getAttribute($object, $item, array $arguments = array(), $typ /** * This method is only useful when testing Twig. Do not use it. */ - static public function clearCache() + public static function clearCache() { self::$cache = array(); } diff --git a/core/vendor/twig/twig/lib/Twig/TemplateInterface.php b/core/vendor/twig/twig/lib/Twig/TemplateInterface.php index 08da116389c4..5d7b02717bad 100644 --- a/core/vendor/twig/twig/lib/Twig/TemplateInterface.php +++ b/core/vendor/twig/twig/lib/Twig/TemplateInterface.php @@ -28,7 +28,7 @@ interface Twig_TemplateInterface * * @return string The rendered template */ - function render(array $context); + public function render(array $context); /** * Displays the template with the given context. @@ -36,12 +36,12 @@ function render(array $context); * @param array $context An array of parameters to pass to the template * @param array $blocks An array of blocks to pass to the template */ - function display(array $context, array $blocks = array()); + public function display(array $context, array $blocks = array()); /** * Returns the bound environment for this template. * * @return Twig_Environment The current environment */ - function getEnvironment(); + public function getEnvironment(); } diff --git a/core/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php b/core/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php new file mode 100644 index 000000000000..2973dc5cb2bf --- /dev/null +++ b/core/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php @@ -0,0 +1,155 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Integration test helper + * + * @package twig + * @author Fabien Potencier <fabien@symfony.com> + * @author Karma Dordrak <drak@zikula.org> + */ +abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase +{ + abstract protected function getExtensions(); + abstract protected function getFixturesDir(); + + /** + * @dataProvider getTests + */ + public function testIntegration($file, $message, $condition, $templates, $exception, $outputs) + { + $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs); + } + + public function getTests() + { + $fixturesDir = realpath($this->getFixturesDir()); + $tests = array(); + + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { + if (!preg_match('/\.test$/', $file)) { + continue; + } + + $test = file_get_contents($file->getRealpath()); + + if (preg_match('/ + --TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) { + $message = $match[1]; + $condition = $match[2]; + $templates = $this->parseTemplates($match[3]); + $exception = $match[5]; + $outputs = array(array(null, $match[4], null, '')); + } elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) { + $message = $match[1]; + $condition = $match[2]; + $templates = $this->parseTemplates($match[3]); + $exception = false; + preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER); + } else { + throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file))); + } + + $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs); + } + + return $tests; + } + + protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs) + { + if ($condition) { + eval('$ret = '.$condition.';'); + if (!$ret) { + $this->markTestSkipped($condition); + } + } + + $loader = new Twig_Loader_Array($templates); + + foreach ($outputs as $match) { + $config = array_merge(array( + 'cache' => false, + 'strict_variables' => true, + ), $match[2] ? eval($match[2].';') : array()); + $twig = new Twig_Environment($loader, $config); + $twig->addGlobal('global', 'global'); + foreach ($this->getExtensions() as $extension) { + $twig->addExtension($extension); + } + + try { + $template = $twig->loadTemplate('index.twig'); + } catch (Exception $e) { + if (false !== $exception) { + $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage()))); + + return; + } + + if ($e instanceof Twig_Error_Syntax) { + $e->setTemplateFile($file); + + throw $e; + } + + throw new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e); + } + + try { + $output = trim($template->render(eval($match[1].';')), "\n "); + } catch (Exception $e) { + if (false !== $exception) { + $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage()))); + + return; + } + + if ($e instanceof Twig_Error_Syntax) { + $e->setTemplateFile($file); + } else { + $e = new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e); + } + + $output = trim(sprintf('%s: %s', get_class($e), $e->getMessage())); + } + + if (false !== $exception) { + list($class, ) = explode(':', $exception); + $this->assertThat(NULL, new PHPUnit_Framework_Constraint_Exception($class)); + } + + $expected = trim($match[3], "\n "); + + if ($expected != $output) { + echo 'Compiled template that failed:'; + + foreach (array_keys($templates) as $name) { + echo "Template: $name\n"; + $source = $loader->getSource($name); + echo $twig->compile($twig->parse($twig->tokenize($source, $name))); + } + } + $this->assertEquals($expected, $output, $message.' (in '.$file.')'); + } + } + + protected static function parseTemplates($test) + { + $templates = array(); + preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER); + foreach ($matches as $match) { + $templates[($match[1] ? $match[1] : 'index.twig')] = $match[2]; + } + + return $templates; + } +} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/TestCase.php b/core/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php similarity index 95% rename from core/vendor/twig/twig/test/Twig/Tests/Node/TestCase.php rename to core/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php index f142529c5d45..b15c85ffd7d6 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/TestCase.php +++ b/core/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php @@ -8,7 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -abstract class Twig_Tests_Node_TestCase extends PHPUnit_Framework_TestCase +abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase { abstract public function getTests(); diff --git a/core/vendor/twig/twig/lib/Twig/TestInterface.php b/core/vendor/twig/twig/lib/Twig/TestInterface.php index c2ff72583832..96db428264b8 100644 --- a/core/vendor/twig/twig/lib/Twig/TestInterface.php +++ b/core/vendor/twig/twig/lib/Twig/TestInterface.php @@ -22,5 +22,5 @@ interface Twig_TestInterface * * @return string The PHP code for the test */ - function compile(); + public function compile(); } diff --git a/core/vendor/twig/twig/lib/Twig/Token.php b/core/vendor/twig/twig/lib/Twig/Token.php index 918bb918edcb..7f58e560326b 100644 --- a/core/vendor/twig/twig/lib/Twig/Token.php +++ b/core/vendor/twig/twig/lib/Twig/Token.php @@ -126,7 +126,7 @@ public function getValue() * * @return string The string representation */ - static public function typeToString($type, $short = false, $line = -1) + public static function typeToString($type, $short = false, $line = -1) { switch ($type) { case self::EOF_TYPE: @@ -169,7 +169,7 @@ static public function typeToString($type, $short = false, $line = -1) $name = 'INTERPOLATION_END_TYPE'; break; default: - throw new Twig_Error_Syntax(sprintf('Token of type "%s" does not exist.', $type), $line); + throw new LogicException(sprintf('Token of type "%s" does not exist.', $type)); } return $short ? $name : 'Twig_Token::'.$name; @@ -183,7 +183,7 @@ static public function typeToString($type, $short = false, $line = -1) * * @return string The string representation */ - static public function typeToEnglish($type, $line = -1) + public static function typeToEnglish($type, $line = -1) { switch ($type) { case self::EOF_TYPE: @@ -213,7 +213,7 @@ static public function typeToEnglish($type, $line = -1) case self::INTERPOLATION_END_TYPE: return 'end of string interpolation'; default: - throw new Twig_Error_Syntax(sprintf('Token of type "%s" does not exist.', $type), $line); + throw new LogicException(sprintf('Token of type "%s" does not exist.', $type)); } } } diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php b/core/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php index 004084520ad7..27560288391d 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php @@ -39,13 +39,14 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser public function parse(Twig_Token $token) { $lineno = $token->getLine(); + $stream = $this->parser->getStream(); - if ($this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) { + if ($stream->test(Twig_Token::BLOCK_END_TYPE)) { $value = 'html'; } else { $expr = $this->parser->getExpressionParser()->parseExpression(); if (!$expr instanceof Twig_Node_Expression_Constant) { - throw new Twig_Error_Syntax('An escaping strategy must be a string or a Boolean.', $lineno); + throw new Twig_Error_Syntax('An escaping strategy must be a string or a Boolean.', $stream->getCurrent()->getLine(), $stream->getFilename()); } $value = $expr->getAttribute('value'); @@ -55,18 +56,18 @@ public function parse(Twig_Token $token) $value = 'html'; } - if ($compat && $this->parser->getStream()->test(Twig_Token::NAME_TYPE)) { + if ($compat && $stream->test(Twig_Token::NAME_TYPE)) { if (false === $value) { - throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $lineno); + throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getFilename()); } - $value = $this->parser->getStream()->next()->getValue(); + $value = $stream->next()->getValue(); } } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag()); } diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/Block.php b/core/vendor/twig/twig/lib/Twig/TokenParser/Block.php index 994078ebf098..a2e017f3e884 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/Block.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/Block.php @@ -35,7 +35,7 @@ public function parse(Twig_Token $token) $stream = $this->parser->getStream(); $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); if ($this->parser->hasBlock($name)) { - throw new Twig_Error_Syntax(sprintf("The block '$name' has already been defined line %d", $this->parser->getBlock($name)->getLine()), $lineno); + throw new Twig_Error_Syntax(sprintf("The block '$name' has already been defined line %d", $this->parser->getBlock($name)->getLine()), $stream->getCurrent()->getLine(), $stream->getFilename()); } $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno)); $this->parser->pushLocalScope(); @@ -49,7 +49,7 @@ public function parse(Twig_Token $token) $value = $stream->next()->getValue(); if ($value != $name) { - throw new Twig_Error_Syntax(sprintf("Expected endblock for block '$name' (but %s given)", $value), $lineno); + throw new Twig_Error_Syntax(sprintf("Expected endblock for block '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename()); } } } else { diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/Extends.php b/core/vendor/twig/twig/lib/Twig/TokenParser/Extends.php index 54f49ad3d788..110bc8b458ef 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/Extends.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/Extends.php @@ -29,11 +29,11 @@ class Twig_TokenParser_Extends extends Twig_TokenParser public function parse(Twig_Token $token) { if (!$this->parser->isMainScope()) { - throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine()); + throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine(), $this->parser->getFilename()); } if (null !== $this->parser->getParent()) { - throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine()); + throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine(), $this->parser->getFilename()); } $this->parser->setParent($this->parser->getExpressionParser()->parseExpression()); diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/From.php b/core/vendor/twig/twig/lib/Twig/TokenParser/From.php index 16999bc87d92..a54054dbc942 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/From.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/From.php @@ -56,7 +56,7 @@ public function parse(Twig_Token $token) $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag()); foreach ($targets as $name => $alias) { - $this->parser->addImportedFunction($alias, 'get'.$name, $node->getNode('var')); + $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var')); } return $node; diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/If.php b/core/vendor/twig/twig/lib/Twig/TokenParser/If.php index 1a694afde99d..3d7d1f517f93 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/If.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/If.php @@ -36,22 +36,23 @@ public function parse(Twig_Token $token) { $lineno = $token->getLine(); $expr = $this->parser->getExpressionParser()->parseExpression(); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream = $this->parser->getStream(); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideIfFork')); $tests = array($expr, $body); $else = null; $end = false; while (!$end) { - switch ($this->parser->getStream()->next()->getValue()) { + switch ($stream->next()->getValue()) { case 'else': - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $else = $this->parser->subparse(array($this, 'decideIfEnd')); break; case 'elseif': $expr = $this->parser->getExpressionParser()->parseExpression(); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideIfFork')); $tests[] = $expr; $tests[] = $body; @@ -62,11 +63,11 @@ public function parse(Twig_Token $token) break; default: - throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d)', $lineno), -1); + throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename()); } } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag()); } diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/Import.php b/core/vendor/twig/twig/lib/Twig/TokenParser/Import.php index 5219289d9ef8..e7050c70c6e8 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/Import.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/Import.php @@ -32,6 +32,8 @@ public function parse(Twig_Token $token) $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine()); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $this->parser->addImportedSymbol('template', $var->getAttribute('name')); + return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag()); } diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/Macro.php b/core/vendor/twig/twig/lib/Twig/TokenParser/Macro.php index ffd58487575b..de100591b507 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/Macro.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/Macro.php @@ -30,22 +30,23 @@ class Twig_TokenParser_Macro extends Twig_TokenParser public function parse(Twig_Token $token) { $lineno = $token->getLine(); - $name = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(); + $stream = $this->parser->getStream(); + $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); $arguments = $this->parser->getExpressionParser()->parseArguments(); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $this->parser->pushLocalScope(); $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE)) { - $value = $this->parser->getStream()->next()->getValue(); + if ($stream->test(Twig_Token::NAME_TYPE)) { + $value = $stream->next()->getValue(); if ($value != $name) { - throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $lineno); + throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename()); } } $this->parser->popLocalScope(); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag())); diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php b/core/vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php index 0277c70c5ff7..9457325ab455 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php @@ -35,6 +35,19 @@ public function parse(Twig_Token $token) $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + // in a sandbox tag, only include tags are allowed + if (!$body instanceof Twig_Node_Include) { + foreach ($body as $node) { + if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) { + continue; + } + + if (!$node instanceof Twig_Node_Include) { + throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $node->getLine(), $this->parser->getFilename()); + } + } + } + return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag()); } diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/Set.php b/core/vendor/twig/twig/lib/Twig/TokenParser/Set.php index 3b4479c13bb3..6dbd1db1a292 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/Set.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/Set.php @@ -49,13 +49,13 @@ public function parse(Twig_Token $token) $stream->expect(Twig_Token::BLOCK_END_TYPE); if (count($names) !== count($values)) { - throw new Twig_Error_Syntax("When using set, you must have the same number of variables and assignements.", $lineno); + throw new Twig_Error_Syntax("When using set, you must have the same number of variables and assignements.", $stream->getCurrent()->getLine(), $stream->getFilename()); } } else { $capture = true; if (count($names) > 1) { - throw new Twig_Error_Syntax("When using set with a block, you cannot have a multi-target.", $lineno); + throw new Twig_Error_Syntax("When using set with a block, you cannot have a multi-target.", $stream->getCurrent()->getLine(), $stream->getFilename()); } $stream->expect(Twig_Token::BLOCK_END_TYPE); diff --git a/core/vendor/twig/twig/lib/Twig/TokenParser/Use.php b/core/vendor/twig/twig/lib/Twig/TokenParser/Use.php index beafc8053f81..85f084a52836 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParser/Use.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParser/Use.php @@ -35,13 +35,12 @@ class Twig_TokenParser_Use extends Twig_TokenParser public function parse(Twig_Token $token) { $template = $this->parser->getExpressionParser()->parseExpression(); + $stream = $this->parser->getStream(); if (!$template instanceof Twig_Node_Expression_Constant) { - throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $token->getLine()); + throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getFilename()); } - $stream = $this->parser->getStream(); - $targets = array(); if ($stream->test('with')) { $stream->next(); diff --git a/core/vendor/twig/twig/lib/Twig/TokenParserBroker.php b/core/vendor/twig/twig/lib/Twig/TokenParserBroker.php index b214e99e308f..f2c27ee488ff 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParserBroker.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParserBroker.php @@ -32,13 +32,13 @@ public function __construct($parsers = array(), $brokers = array()) { foreach ($parsers as $parser) { if (!$parser instanceof Twig_TokenParserInterface) { - throw new Twig_Error('$parsers must a an array of Twig_TokenParserInterface'); + throw new LogicException('$parsers must a an array of Twig_TokenParserInterface'); } $this->parsers[$parser->getTag()] = $parser; } foreach ($brokers as $broker) { if (!$broker instanceof Twig_TokenParserBrokerInterface) { - throw new Twig_Error('$brokers must a an array of Twig_TokenParserBrokerInterface'); + throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface'); } $this->brokers[] = $broker; } diff --git a/core/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php b/core/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php index c2df7299bae5..b8e3c2341b99 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php @@ -27,19 +27,19 @@ interface Twig_TokenParserBrokerInterface * * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found */ - function getTokenParser($tag); + public function getTokenParser($tag); /** * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of. * * @param Twig_ParserInterface $parser A Twig_ParserInterface interface */ - function setParser(Twig_ParserInterface $parser); + public function setParser(Twig_ParserInterface $parser); /** * Gets the Twig_ParserInterface. * * @return null|Twig_ParserInterface A Twig_ParserInterface instance or null */ - function getParser(); + public function getParser(); } diff --git a/core/vendor/twig/twig/lib/Twig/TokenParserInterface.php b/core/vendor/twig/twig/lib/Twig/TokenParserInterface.php index 192c0186dbd3..2b6c2ac2aac1 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenParserInterface.php +++ b/core/vendor/twig/twig/lib/Twig/TokenParserInterface.php @@ -22,7 +22,7 @@ interface Twig_TokenParserInterface * * @param $parser A Twig_Parser instance */ - function setParser(Twig_Parser $parser); + public function setParser(Twig_Parser $parser); /** * Parses a token and returns a node. @@ -31,12 +31,12 @@ function setParser(Twig_Parser $parser); * * @return Twig_NodeInterface A Twig_NodeInterface instance */ - function parse(Twig_Token $token); + public function parse(Twig_Token $token); /** * Gets the tag name associated with this token parser. * * @return string The tag name */ - function getTag(); + public function getTag(); } diff --git a/core/vendor/twig/twig/lib/Twig/TokenStream.php b/core/vendor/twig/twig/lib/Twig/TokenStream.php index 5708091f3ac3..292c11fb339f 100644 --- a/core/vendor/twig/twig/lib/Twig/TokenStream.php +++ b/core/vendor/twig/twig/lib/Twig/TokenStream.php @@ -58,7 +58,7 @@ public function injectTokens(array $tokens) public function next() { if (!isset($this->tokens[++$this->current])) { - throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename); + throw new Twig_Error_Syntax('Unexpected end of template', $this->token[$this->current - 1]->getLine(), $this->filename); } return $this->tokens[$this->current - 1]; @@ -97,7 +97,7 @@ public function expect($type, $value = null, $message = null) public function look($number = 1) { if (!isset($this->tokens[$this->current + $number])) { - throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename); + throw new Twig_Error_Syntax('Unexpected end of template', $this->token[$this->current + $number - 1]->getLine(), $this->filename); } return $this->tokens[$this->current + $number]; diff --git a/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php b/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php index bb316906fdc4..76731ea043f4 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php @@ -25,7 +25,7 @@ public function testAutoescapeOption() )); $this->assertEquals('foo<br/ > foo<br/ >', $twig->render('html', array('foo' => 'foo<br/ >'))); - $this->assertEquals('foo\x3cbr\x2f \x3e foo\x3cbr\x2f \x3e', $twig->render('js', array('bar' => 'foo<br/ >'))); + $this->assertEquals('foo\x3Cbr\x2F\x20\x3E foo\x3Cbr\x2F\x20\x3E', $twig->render('js', array('bar' => 'foo<br/ >'))); } public function escapingStrategyCallback($filename) diff --git a/core/vendor/twig/twig/test/Twig/Tests/ErrorTest.php b/core/vendor/twig/twig/test/Twig/Tests/ErrorTest.php index d0e48bedd6ed..9b286974d621 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/ErrorTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/ErrorTest.php @@ -78,7 +78,6 @@ public function testTwigExceptionAddsFileAndLineWhenMissingWithInheritance() $twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false)); $template = $twig->loadTemplate('index'); - try { $template->render(array()); @@ -88,6 +87,66 @@ public function testTwigExceptionAddsFileAndLineWhenMissingWithInheritance() $this->assertEquals(3, $e->getTemplateLine()); $this->assertEquals('index', $e->getTemplateFile()); } + + try { + $template->render(array('foo' => new Twig_Tests_ErrorTest_Foo())); + + $this->fail(); + } catch (Twig_Error_Runtime $e) { + $this->assertEquals('An exception has been thrown during the rendering of a template ("Runtime error...") in "index" at line 3.', $e->getMessage()); + $this->assertEquals(3, $e->getTemplateLine()); + $this->assertEquals('index', $e->getTemplateFile()); + } + } + + public function testTwigExceptionAddsFileAndLineWhenMissingWithInheritanceAgain() + { + $loader = new Twig_Loader_Array(array( + 'index' => "{% extends 'base' %} + {% block content %} + {{ parent() }} + {% endblock %}", + 'base' => '{% block content %}{{ foo }}{% endblock %}' + )); + $twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false)); + + $template = $twig->loadTemplate('index'); + try { + $template->render(array()); + + $this->fail(); + } catch (Twig_Error_Runtime $e) { + $this->assertEquals('Variable "foo" does not exist in "base" at line 1', $e->getMessage()); + $this->assertEquals(1, $e->getTemplateLine()); + $this->assertEquals('base', $e->getTemplateFile()); + } + } + + public function testTwigExceptionAddsFileAndLineWhenMissingWithInheritanceOnDisk() + { + $loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/Fixtures/errors'); + $twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false)); + + $template = $twig->loadTemplate('index.html'); + try { + $template->render(array()); + + $this->fail(); + } catch (Twig_Error_Runtime $e) { + $this->assertEquals('Variable "foo" does not exist in "index.html" at line 3', $e->getMessage()); + $this->assertEquals(3, $e->getTemplateLine()); + $this->assertEquals('index.html', $e->getTemplateFile()); + } + + try { + $template->render(array('foo' => new Twig_Tests_ErrorTest_Foo())); + + $this->fail(); + } catch (Twig_Error_Runtime $e) { + $this->assertEquals('An exception has been thrown during the rendering of a template ("Runtime error...") in "index.html" at line 3.', $e->getMessage()); + $this->assertEquals(3, $e->getTemplateLine()); + $this->assertEquals('index.html', $e->getTemplateFile()); + } } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php b/core/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php index 0768c65c1b26..72253c88134f 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php @@ -11,7 +11,7 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase { - static protected $params, $templates; + protected static $params, $templates; public function setUp() { @@ -156,10 +156,13 @@ public function testSandboxLocallySetForAnInclude() public function testMacrosInASandbox() { $twig = $this->getEnvironment(true, array('autoescape' => true), array('index' => <<<EOF -{% macro test(text) %}<p>{{ text }}</p>{% endmacro %} -{{ _self.test('username') }} +{%- import _self as macros %} + +{%- macro test(text) %}<p>{{ text }}</p>{% endmacro %} + +{{- macros.test('username') }} EOF - ), array('macro'), array('escape')); + ), array('macro', 'import'), array('escape')); $this->assertEquals('<p>username</p>', $twig->loadTemplate('index')->render(array())); } @@ -177,11 +180,11 @@ protected function getEnvironment($sandboxed, $options, $templates, $tags = arra class FooObject { - static public $called = array('__toString' => 0, 'foo' => 0, 'getFooBar' => 0); + public static $called = array('__toString' => 0, 'foo' => 0, 'getFooBar' => 0); public $bar = 'bar'; - static public function reset() + public static function reset() { self::$called = array('__toString' => 0, 'foo' => 0, 'getFooBar' => 0); } diff --git a/core/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php b/core/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php index 2c77c06a631a..8efc948f4db1 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php @@ -10,7 +10,7 @@ public function setUp() { $this->tmpDir = sys_get_temp_dir().'/TwigTests'; if (!file_exists($this->tmpDir)) { - @mkdir($this->tmpDir, 0777, true);; + @mkdir($this->tmpDir, 0777, true); } if (!is_writable($this->tmpDir)) { diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/base.html b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/base.html new file mode 100644 index 000000000000..cb0dbe444bb4 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/base.html @@ -0,0 +1 @@ +{% block content %}{% endblock %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/index.html b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/index.html new file mode 100644 index 000000000000..df57c822f92e --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/index.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} +{% block content %} + {{ foo.bar }} +{% endblock %} +{% block foo %} + {{ foo.bar }} +{% endblock %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test index 911094c06730..7b56b76108e2 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test @@ -4,9 +4,11 @@ Twig supports bitwise operations {{ 1 b-and 5 }} {{ 1 b-or 5 }} {{ 1 b-xor 5 }} +{{ (1 and 0 b-or 0) is sameas(1 and (0 b-or 0)) ? 'ok' : 'ko' }} --DATA-- return array() --EXPECT-- 1 5 4 +ok diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/method_call.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/method_call.test index 9d84a4c053bb..5f801e6354a0 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/method_call.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/method_call.test @@ -12,7 +12,7 @@ Twig supports method calls {{ items.foo.in }} {{ items.foo.not }} --DATA-- -return array('foo' => 'bar', 'items' => array('foo' => new Foo(), 'bar' => 'foo')) +return array('foo' => 'bar', 'items' => array('foo' => new TwigTestFoo(), 'bar' => 'foo')) --CONFIG-- return array('strict_variables' => false) --EXPECT-- diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/postfix.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/postfix.test index db047c00503f..542c35046112 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/postfix.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/postfix.test @@ -1,6 +1,7 @@ --TEST-- Twig parses postfix expressions --TEMPLATE-- +{% import _self as macros %} {% macro foo() %}foo{% endmacro %} @@ -8,8 +9,8 @@ Twig parses postfix expressions {{ 'a'|upper }} {{ ('a')|upper }} {{ -1|upper }} -{{ _self.foo() }} -{{ (_self).foo() }} +{{ macros.foo() }} +{{ (macros).foo() }} --DATA-- return array(); --EXPECT-- diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test index ae6d0daf5e3a..f40f4cb9d767 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test @@ -11,6 +11,7 @@ {{ date2|date }} {{ date2|date('d/m/Y') }} {{ date2|date('d/m/Y H:i:s', 'Europe/Paris') }} +{{ date2|date('d/m/Y H:i:s', timezone1) }} {{ date2|date('d/m/Y H:i:s') }} {{ date3|date }} {{ date3|date('d/m/Y') }} @@ -20,8 +21,9 @@ {{ date5|date('d/m/Y') }} {{ date6|date('d/m/Y H:i:s P', 'Europe/Paris') }} {{ date6|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }} +{{ date6|date('d/m/Y H:i:s P', false) }} {{ date6|date('e', 'Europe/Paris') }} -{{ date6|date('e') }} +{{ date6|date('e', false) }} --DATA-- date_default_timezone_set('UTC'); return array( @@ -31,6 +33,7 @@ return array( 'date4' => 1286199900, 'date5' => -86410, 'date6' => new DateTime('2010-10-04 13:45', new DateTimeZone('America/New_York')), + 'timezone1' => new DateTimeZone('America/New_York'), ) --EXPECT-- October 4, 2010 13:45 @@ -43,6 +46,7 @@ UTC October 4, 2010 13:45 04/10/2010 04/10/2010 15:45:00 +04/10/2010 09:45:00 04/10/2010 13:45:00 October 4, 2010 13:45 04/10/2010 @@ -52,5 +56,6 @@ December 30, 1969 23:59 30/12/1969 04/10/2010 19:45:00 +02:00 05/10/2010 01:45:00 +08:00 +04/10/2010 13:45:00 -04:00 Europe/Paris -America/New_York \ No newline at end of file +America/New_York diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_interval.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_interval.test index 2d5adc11721f..0c8c6f1a28cc 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_interval.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_interval.test @@ -3,14 +3,17 @@ --CONDITION-- version_compare(phpversion(), '5.3.0', '>=') --TEMPLATE-- -{{ date6|date }} -{{ date6|date('%d days %h hours') }} +{{ date1|date }} +{{ date1|date('%d days %h hours') }} +{{ date1|date('%d days %h hours', timezone1) }} --DATA-- date_default_timezone_set('UTC'); return array( - 'date5' => -86410, - 'date6' => new DateInterval('P2D'), + 'date1' => new DateInterval('P2D'), + // This should have no effect on DateInterval formatting + 'timezone1' => new DateTimeZone('America/New_York'), ) --EXPECT-- 2 days 2 days 0 hours +2 days 0 hours diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_modify.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_modify.test new file mode 100644 index 000000000000..53d3a69cdf40 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_modify.test @@ -0,0 +1,14 @@ +--TEST-- +"date_modify" filter +--TEMPLATE-- +{{ date1|date_modify('-1day')|date('Y-m-d H:i:s') }} +{{ date2|date_modify('-1day')|date('Y-m-d H:i:s') }} +--DATA-- +date_default_timezone_set('UTC'); +return array( + 'date1' => '2010-10-04 13:45', + 'date2' => new DateTime('2010-10-04 13:45'), +) +--EXPECT-- +2010-10-03 13:45:00 +2010-10-03 13:45:00 diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test index 22e86e46b1d3..0e4404b1c761 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test @@ -51,7 +51,7 @@ return array( 'nullVar' => null, 'definedArray' => array(0), ), - 'object' => new Foo(), + 'object' => new TwigTestFoo(), ) --CONFIG-- return array('strict_variables' => false) @@ -106,7 +106,7 @@ return array( 'nullVar' => null, 'definedArray' => array(0), ), - 'object' => new Foo(), + 'object' => new TwigTestFoo(), ) --CONFIG-- return array('strict_variables' => true) diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/force_escape.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/force_escape.test index 3690e71516d8..85a9b7172bdd 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/force_escape.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/force_escape.test @@ -14,5 +14,5 @@ return array() --EXPECT-- foo<br /> - foo\x3cbr \x2f\x3e\x0a +\x20\x20\x20\x20foo\x3Cbr\x20\x2F\x3E\x0A foo<br /> diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/join.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/join.test index 8feef6356955..b342c174c985 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/join.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/join.test @@ -5,7 +5,7 @@ {{ foo|join(', ') }} {{ bar|join(', ') }} --DATA-- -return array('foo' => new Foo(), 'bar' => new ArrayObject(array(3, 4))) +return array('foo' => new TwigTestFoo(), 'bar' => new ArrayObject(array(3, 4))) --EXPECT-- foo, bar 1, 2 diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test index 357b3522e1b8..2bd3d4c0459e 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test @@ -5,10 +5,12 @@ {{ items|merge({'bar': 'foo'})|keys|join }} {{ {'bar': 'foo'}|merge(items)|join }} {{ {'bar': 'foo'}|merge(items)|keys|join }} +{{ numerics|merge([4, 5, 6])|join }} --DATA-- -return array('items' => array('foo' => 'bar')) +return array('items' => array('foo' => 'bar'), 'numerics' => array(1, 2, 3)) --EXPECT-- barfoo foobar foobar barfoo +123456 diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test new file mode 100644 index 000000000000..ce8ec9cec645 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test @@ -0,0 +1,18 @@ +--TEST-- +"split" filter +--TEMPLATE-- +{{ "one,two,three,four,five"|split(',')|join('-') }} +{{ foo|split(',')|join('-') }} +{{ foo|split(',', 3)|join('-') }} +{{ baz|split('')|join('-') }} +{{ baz|split('', 2)|join('-') }} +{{ foo|split(',', -2)|join('-') }} +--DATA-- +return array('foo' => "one,two,three,four,five", 'baz' => '12345',) +--EXPECT-- +one-two-three-four-five +one-two-three-four-five +one-two-three,four,five +1-2-3-4-5 +12-34-5 +one-two-three \ No newline at end of file diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test index ba7d5e82ed70..16ae1e8ba0a9 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test @@ -5,7 +5,7 @@ {{ attribute(array, item) }} {{ attribute(obj, "bar", ["a", "b"]) }} --DATA-- -return array('obj' => new Foo(), 'method' => 'foo', 'array' => array('foo' => 'bar'), 'item' => 'foo') +return array('obj' => new TwigTestFoo(), 'method' => 'foo', 'array' => array('foo' => 'bar'), 'item' => 'foo') --EXPECT-- foo bar diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test index 371a587758f4..f4072375a808 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test @@ -1,5 +1,7 @@ --TEST-- "dump" function +--CONDITION-- +!extension_loaded('xdebug') --TEMPLATE-- {{ dump('foo') }} {{ dump('foo', 'bar') }} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test new file mode 100644 index 000000000000..41428da190a9 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test @@ -0,0 +1,11 @@ +--TEST-- +"template_from_string" function +--TEMPLATE-- +{% include template_from_string(template) %} + +{% include template_from_string("Hello {{ name }}") %} +--DATA-- +return array('name' => 'Fabien', 'template' => "Hello {{ name }}") +--EXPECT-- +Hello Fabien +Hello Fabien diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/nested_calls.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/nested_calls.test new file mode 100644 index 000000000000..cd25428108c4 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/nested_calls.test @@ -0,0 +1,18 @@ +--TEST-- +macro +--TEMPLATE-- +{% import _self as macros %} + +{% macro foo(data) %} + {{ data }} +{% endmacro %} + +{% macro bar() %} + <br /> +{% endmacro %} + +{{ macros.foo(macros.bar()) }} +--DATA-- +return array(); +--EXPECT-- +<br /> diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/reserved_variables.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/reserved_variables.test new file mode 100644 index 000000000000..cbfb921b2cba --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/reserved_variables.test @@ -0,0 +1,14 @@ +--TEST-- +macro +--TEMPLATE-- +{% from _self import test %} + +{% macro test(this) -%} + {{ this }} +{%- endmacro %} + +{{ test(this) }} +--DATA-- +return array('this' => 'foo'); +--EXPECT-- +foo diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/functions.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/functions.test index 864655ced2bd..ce7ea789ebb2 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/functions.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/functions.test @@ -80,4 +80,4 @@ unsafe_br()|escape autoescape js safe_br -\x3cbr \x2f\x3e +\x3Cbr\x20\x2F\x3E diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test index 101d5afe5d04..cf8cceef32b1 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test @@ -11,7 +11,7 @@ --DATA-- return array('var' => '<br />"') --EXPECT-- -\x3cbr \x2f\x3e\x22 +\x3Cbr\x20\x2F\x3E\x22 <br />" -\x3cbr \x2f\x3e\x22 +\x3Cbr\x20\x2F\x3E\x22 <br />" diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/type.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/type.test index 10fd63f91d76..4f415201db1e 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/type.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/type.test @@ -44,15 +44,15 @@ return array('msg' => "<>\n'\"") 1. autoescape 'html' |escape('js') -<a onclick="alert("\x3c\x3e\x0a\x27\x22")"></a> +<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a> 2. autoescape 'html' |escape('js') -<a onclick="alert("\x3c\x3e\x0a\x27\x22")"></a> +<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a> 3. autoescape 'js' |escape('js') -<a onclick="alert("\x3c\x3e\x0a\x27\x22")"></a> +<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a> 4. no escape @@ -61,9 +61,9 @@ return array('msg' => "<>\n'\"") 5. |escape('js')|escape('html') -<a onclick="alert("\x3c\x3e\x0a\x27\x22")"></a> +<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a> 6. autoescape 'html' |escape('js')|escape('html') -<a onclick="alert("\x3c\x3e\x0a\x27\x22")"></a> +<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a> diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/nested.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/nested.test new file mode 100644 index 000000000000..81563dcef7a2 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/nested.test @@ -0,0 +1,42 @@ +--TEST-- +"embed" tag +--TEMPLATE-- +{% embed "foo.twig" %} + {% block c1 %} + {{ parent() }} + {% embed "foo.twig" %} + {% block c1 %} + {{ parent() }} + block1extended + {% endblock %} + {% endembed %} + + {% endblock %} +{% endembed %} +--TEMPLATE(foo.twig)-- +A +{% block c1 %} + block1 +{% endblock %} +B +{% block c2 %} + block2 +{% endblock %} +C +--DATA-- +return array() +--EXPECT-- +A + block1 + + +A + block1 + + block1extended + B + block2 +C + B + block2 +C diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing.test new file mode 100644 index 000000000000..f25e8715517b --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing.test @@ -0,0 +1,8 @@ +--TEST-- +"include" tag +--TEMPLATE-- +{% include "foo.twig" %} +--DATA-- +return array(); +--EXCEPTION-- +Twig_Error_Loader: Template "foo.twig" is not defined in "index.twig" at line 2. diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing_nested.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing_nested.test new file mode 100644 index 000000000000..86c186444685 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing_nested.test @@ -0,0 +1,16 @@ +--TEST-- +"include" tag +--TEMPLATE-- +{% extends "base.twig" %} + +{% block content %} + {{ parent() }} +{% endblock %} +--TEMPLATE(base.twig)-- +{% block content %} + {% include "foo.twig" %} +{% endblock %} +--DATA-- +return array(); +--EXCEPTION-- +Twig_Error_Loader: Template "foo.twig" is not defined in "base.twig" at line 3. diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/basic.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/basic.test index ef59a57c47fa..eef0c10d591a 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/basic.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/basic.test @@ -1,8 +1,10 @@ --TEST-- "macro" tag --TEMPLATE-- -{{ _self.input('username') }} -{{ _self.input('password', null, 'password', 1) }} +{% import _self as macros %} + +{{ macros.input('username') }} +{{ macros.input('password', null, 'password', 1) }} {% macro input(name, value, type, size) %} <input type="{{ type|default("text") }}" name="{{ name }}" value="{{ value|e|default('') }}" size="{{ size|default(20) }}"> diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test index fa811892ab51..ae6203bb64f2 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test @@ -1,8 +1,10 @@ --TEST-- "macro" tag supports name for endmacro --TEMPLATE-- -{{ _self.foo() }} -{{ _self.bar() }} +{% import _self as macros %} + +{{ macros.foo() }} +{{ macros.bar() }} {% macro foo() %}foo{% endmacro %} {% macro bar() %}bar{% endmacro bar %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test index e61716eee47f..099995110374 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test @@ -1,7 +1,9 @@ --TEST-- "☃" as a macro name --TEMPLATE-- -{{ _self.☃('foo') }} +{% import _self as macros %} + +{{ macros.☃('foo') }} {% macro ☃(foo) %} ☃{{ foo }}☃ diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/constant.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/constant.test index fb3d288554ce..c8adb15b15ae 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/constant.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/constant.test @@ -2,8 +2,8 @@ "const" test --TEMPLATE-- {{ 8 is constant('E_NOTICE') ? 'ok' : 'no' }} -{{ 'bar' is constant('Foo::BAR_NAME') ? 'ok' : 'no' }} -{{ value is constant('Foo::BAR_NAME') ? 'ok' : 'no' }} +{{ 'bar' is constant('TwigTestFoo::BAR_NAME') ? 'ok' : 'no' }} +{{ value is constant('TwigTestFoo::BAR_NAME') ? 'ok' : 'no' }} --DATA-- return array('value' => 'bar'); --EXPECT-- diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined.test index 2fbaa86dca52..cbfe03de5a06 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined.test @@ -37,7 +37,7 @@ return array( 'nullVar' => null, 'definedArray' => array(0), ), - 'object' => new Foo(), + 'object' => new TwigTestFoo(), ); --EXPECT-- ok @@ -76,7 +76,7 @@ return array( 'nullVar' => null, 'definedArray' => array(0), ), - 'object' => new Foo(), + 'object' => new TwigTestFoo(), ); --CONFIG-- return array('strict_variables' => false) diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in_with_objects.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in_with_objects.test new file mode 100644 index 000000000000..8e08061bb580 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in_with_objects.test @@ -0,0 +1,19 @@ +--TEST-- +Twig supports the in operator when using objects +--TEMPLATE-- +{% if object in object_list %} +TRUE +{% endif %} +--DATA-- +$foo = new TwigTestFoo(); +$foo1 = new TwigTestFoo(); + +$foo->position = $foo1; +$foo1->position = $foo; + +return array( + 'object' => $foo, + 'object_list' => array($foo1, $foo), +); +--EXPECT-- +TRUE diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php b/core/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php index 22ae5aa0afb8..9ea2d0e3a508 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php @@ -49,4 +49,42 @@ public function getSecurityTests() array('filters\\//../\\/\\..\\AutoloaderTest.php'), ); } + + public function testPaths() + { + $basePath = dirname(__FILE__).'/Fixtures'; + + $loader = new Twig_Loader_Filesystem(array($basePath.'/normal', $basePath.'/normal_bis')); + $loader->setPaths(array($basePath.'/named', $basePath.'/named_bis'), 'named'); + $loader->addPath($basePath.'/named_ter', 'named'); + $loader->addPath($basePath.'/normal_ter'); + $loader->prependPath($basePath.'/normal_final'); + $loader->prependPath($basePath.'/named_final', 'named'); + + $this->assertEquals(array( + $basePath.'/normal_final', + $basePath.'/normal', + $basePath.'/normal_bis', + $basePath.'/normal_ter', + ), $loader->getPaths()); + $this->assertEquals(array( + $basePath.'/named_final', + $basePath.'/named', + $basePath.'/named_bis', + $basePath.'/named_ter', + ), $loader->getPaths('named')); + + $this->assertEquals("path (final)\n", $loader->getSource('index.html')); + $this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html')); + $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html')); + } + + public function testGetNamespaces() + { + $loader = new Twig_Loader_Filesystem(sys_get_temp_dir()); + $this->assertEquals(array('__main__'), $loader->getNamespaces()); + + $loader->addPath(sys_get_temp_dir(), 'named'); + $this->assertEquals(array('__main__', 'named'), $loader->getNamespaces()); + } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named/index.html b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named/index.html new file mode 100644 index 000000000000..9e5449c7c50e --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named/index.html @@ -0,0 +1 @@ +named path diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_bis/index.html b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_bis/index.html new file mode 100644 index 000000000000..d3a272b19d64 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_bis/index.html @@ -0,0 +1 @@ +named path (bis) diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_final/index.html b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_final/index.html new file mode 100644 index 000000000000..9f05d15075c6 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_final/index.html @@ -0,0 +1 @@ +named path (final) diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_ter/index.html b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_ter/index.html new file mode 100644 index 000000000000..24fb68ad2e9b --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_ter/index.html @@ -0,0 +1 @@ +named path (ter) diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal/index.html b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal/index.html new file mode 100644 index 000000000000..e7a8fd4d0a8d --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal/index.html @@ -0,0 +1 @@ +path diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_bis/index.html b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_bis/index.html new file mode 100644 index 000000000000..bfa916049ff6 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_bis/index.html @@ -0,0 +1 @@ +path (bis) diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_final/index.html b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_final/index.html new file mode 100644 index 000000000000..73a089bbda5b --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_final/index.html @@ -0,0 +1 @@ +path (final) diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_ter/index.html b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_ter/index.html new file mode 100644 index 000000000000..b7ad97d8f480 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_ter/index.html @@ -0,0 +1 @@ +path (ter) diff --git a/core/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php b/core/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php new file mode 100644 index 000000000000..3fafd335eda8 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php @@ -0,0 +1,29 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class Twig_Tests_NativeExtensionTest extends PHPUnit_Framework_TestCase +{ + public function testGetProperties() + { + $twig = new Twig_Environment(new Twig_Loader_String(), array( + 'debug' => true, + 'cache' => false, + 'autoescape' => false + )); + + $d1 = new DateTime(); + $d2 = new DateTime(); + $output = $twig->render('{{ d1.date }}{{ d2.date }}', compact('d1', 'd2')); + + // If it fails, PHP will crash. + $this->assertEquals($output, $d1->date . $d2->date); + } +} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php index ebfcb48952ff..608446bc8af8 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_AutoEscapeTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_AutoEscapeTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_AutoEscape::__construct */ public function testConstructor() { - $body = new Twig_Node(array(new Twig_Node_Text('foo', 0))); - $node = new Twig_Node_AutoEscape(true, $body, 0); + $body = new Twig_Node(array(new Twig_Node_Text('foo', 1))); + $node = new Twig_Node_AutoEscape(true, $body, 1); $this->assertEquals($body, $node->getNode('body')); $this->assertEquals(true, $node->getAttribute('value')); @@ -36,11 +34,11 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $body = new Twig_Node(array(new Twig_Node_Text('foo', 0))); - $node = new Twig_Node_AutoEscape(true, $body, 0); + $body = new Twig_Node(array(new Twig_Node_Text('foo', 1))); + $node = new Twig_Node_AutoEscape(true, $body, 1); return array( - array($node, 'echo "foo";'), + array($node, "// line 1\necho \"foo\";"), ); } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php index f1c5ab1a1cba..96d0e101c671 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php @@ -9,16 +9,14 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_BlockReferenceTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_BlockReferenceTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_BlockReference::__construct */ public function testConstructor() { - $node = new Twig_Node_BlockReference('foo', 0); + $node = new Twig_Node_BlockReference('foo', 1); $this->assertEquals('foo', $node->getAttribute('name')); } @@ -35,7 +33,11 @@ public function testCompile($node, $source, $environment = null) public function getTests() { return array( - array(new Twig_Node_BlockReference('foo', 0), '$this->displayBlock(\'foo\', $context, $blocks);'), + array(new Twig_Node_BlockReference('foo', 1), <<<EOF +// line 1 +\$this->displayBlock('foo', \$context, \$blocks); +EOF + ), ); } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php index 6bc5e79158e4..024049de0845 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_BlockTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_BlockTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Block::__construct */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Block('foo', $body, 0); + $body = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Block('foo', $body, 1); $this->assertEquals($body, $node->getNode('body')); $this->assertEquals('foo', $node->getAttribute('name')); @@ -36,11 +34,12 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $body = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Block('foo', $body, 0); + $body = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Block('foo', $body, 1); return array( array($node, <<<EOF +// line 1 public function block_foo(\$context, array \$blocks = array()) { echo "foo"; diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/DoTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/DoTest.php index 49c2a595c70b..a406e22d722a 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/DoTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/DoTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_DoTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_DoTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Do::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = new Twig_Node_Do($expr, 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = new Twig_Node_Do($expr, 1); $this->assertEquals($expr, $node->getNode('expr')); } @@ -37,9 +35,9 @@ public function getTests() { $tests = array(); - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = new Twig_Node_Do($expr, 0); - $tests[] = array($node, '"foo";'); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = new Twig_Node_Do($expr, 1); + $tests[] = array($node, "// line 1\n\"foo\";"); return $tests; } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php index 06b30e94862f..c6a9044b34c4 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_ArrayTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_ArrayTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Array::__construct */ public function testConstructor() { - $elements = array(new Twig_Node_Expression_Constant('foo', 0), $foo = new Twig_Node_Expression_Constant('bar', 0)); - $node = new Twig_Node_Expression_Array($elements, 0); + $elements = array(new Twig_Node_Expression_Constant('foo', 1), $foo = new Twig_Node_Expression_Constant('bar', 1)); + $node = new Twig_Node_Expression_Array($elements, 1); $this->assertEquals($foo, $node->getNode(1)); } @@ -36,13 +34,13 @@ public function testCompile($node, $source, $environment = null) public function getTests() { $elements = array( - new Twig_Node_Expression_Constant('foo', 0), - new Twig_Node_Expression_Constant('bar', 0), + new Twig_Node_Expression_Constant('foo', 1), + new Twig_Node_Expression_Constant('bar', 1), - new Twig_Node_Expression_Constant('bar', 0), - new Twig_Node_Expression_Constant('foo', 0), + new Twig_Node_Expression_Constant('bar', 1), + new Twig_Node_Expression_Constant('foo', 1), ); - $node = new Twig_Node_Expression_Array($elements, 0); + $node = new Twig_Node_Expression_Array($elements, 1); return array( array($node, 'array("foo" => "bar", "bar" => "foo")'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php index fc92b0dcc1e3..b156dcc042c4 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php @@ -9,16 +9,14 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_AssignName::__construct */ public function testConstructor() { - $node = new Twig_Node_Expression_AssignName('foo', 0); + $node = new Twig_Node_Expression_AssignName('foo', 1); $this->assertEquals('foo', $node->getAttribute('name')); } @@ -34,7 +32,7 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $node = new Twig_Node_Expression_AssignName('foo', 0); + $node = new Twig_Node_Expression_AssignName('foo', 1); return array( array($node, '$context["foo"]'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php index 80d318f3aa0b..a0f49cb3d281 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_Add::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Add($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Add($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Add($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Add($left, $right, 1); return array( array($node, '(1 + 2)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php index a6ed4f236ebb..50e551a775d5 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_And::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_And($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_And($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_And($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_And($left, $right, 1); return array( array($node, '(1 && 2)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php index a04edc976edb..140329fa9e35 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_Concat::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Concat($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Concat($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Concat($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Concat($left, $right, 1); return array( array($node, '(1 . 2)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php index 42002fc13f1c..0c1a3c7f79bb 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_Div::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Div($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Div($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Div($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Div($left, $right, 1); return array( array($node, '(1 / 2)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php index 94ff2f644a7d..ead1fde84efc 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_FloorDiv::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1); return array( array($node, 'intval(floor((1 / 2)))'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php index 67612a547141..4fe1a1fc02ac 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_Mod::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Mod($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Mod($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Mod($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Mod($left, $right, 1); return array( array($node, '(1 % 2)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php index c817d0246a58..12bb35c961a6 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_Mul::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Mul($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Mul($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Mul($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Mul($left, $right, 1); return array( array($node, '(1 * 2)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php index d8e2f8da0c98..9534c41c9555 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_Or::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Or($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Or($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Or($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Or($left, $right, 1); return array( array($node, '(1 || 2)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php index 6583d09f113d..9074893b1d12 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Binary_Sub::__construct */ public function testConstructor() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Sub($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Sub($left, $right, 1); $this->assertEquals($left, $node->getNode('left')); $this->assertEquals($right, $node->getNode('right')); @@ -38,9 +36,9 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $left = new Twig_Node_Expression_Constant(1, 0); - $right = new Twig_Node_Expression_Constant(2, 0); - $node = new Twig_Node_Expression_Binary_Sub($left, $right, 0); + $left = new Twig_Node_Expression_Constant(1, 1); + $right = new Twig_Node_Expression_Constant(2, 1); + $node = new Twig_Node_Expression_Binary_Sub($left, $right, 1); return array( array($node, '(1 - 2)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php index 4a05e4e7ef79..9906d512722a 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php @@ -9,19 +9,17 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_ConditionalTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_ConditionalTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Conditional::__construct */ public function testConstructor() { - $expr1 = new Twig_Node_Expression_Constant(1, 0); - $expr2 = new Twig_Node_Expression_Constant(2, 0); - $expr3 = new Twig_Node_Expression_Constant(3, 0); - $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 0); + $expr1 = new Twig_Node_Expression_Constant(1, 1); + $expr2 = new Twig_Node_Expression_Constant(2, 1); + $expr3 = new Twig_Node_Expression_Constant(3, 1); + $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 1); $this->assertEquals($expr1, $node->getNode('expr1')); $this->assertEquals($expr2, $node->getNode('expr2')); @@ -41,10 +39,10 @@ public function getTests() { $tests = array(); - $expr1 = new Twig_Node_Expression_Constant(1, 0); - $expr2 = new Twig_Node_Expression_Constant(2, 0); - $expr3 = new Twig_Node_Expression_Constant(3, 0); - $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 0); + $expr1 = new Twig_Node_Expression_Constant(1, 1); + $expr2 = new Twig_Node_Expression_Constant(2, 1); + $expr3 = new Twig_Node_Expression_Constant(3, 1); + $node = new Twig_Node_Expression_Conditional($expr1, $expr2, $expr3, 1); $tests[] = array($node, '((1) ? (2) : (3))'); return $tests; diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php index 0cf38672b4de..d0dec5313048 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php @@ -9,16 +9,14 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_ConstantTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_ConstantTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Constant::__construct */ public function testConstructor() { - $node = new Twig_Node_Expression_Constant('foo', 0); + $node = new Twig_Node_Expression_Constant('foo', 1); $this->assertEquals('foo', $node->getAttribute('value')); } @@ -36,7 +34,7 @@ public function getTests() { $tests = array(); - $node = new Twig_Node_Expression_Constant('foo', 0); + $node = new Twig_Node_Expression_Constant('foo', 1); $tests[] = array($node, '"foo"'); return $tests; diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php index 2c524824e7a1..d37dd220fa9e 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php @@ -9,19 +9,17 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_FilterTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Filter::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo', 0); - $name = new Twig_Node_Expression_Constant('upper', 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $name = new Twig_Node_Expression_Constant('upper', 1); $args = new Twig_Node(); - $node = new Twig_Node_Expression_Filter($expr, $name, $args, 0); + $node = new Twig_Node_Expression_Filter($expr, $name, $args, 1); $this->assertEquals($expr, $node->getNode('node')); $this->assertEquals($name, $node->getNode('filter')); @@ -35,30 +33,33 @@ public function testConstructor() public function testCompile($node, $source, $environment = null) { parent::testCompile($node, $source, $environment); + } - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = $this->createFilter($expr, 'foobar', array(new Twig_Node_Expression_Constant('bar', 0), new Twig_Node_Expression_Constant('foobar', 0))); + /** + * @covers Twig_Node_Expression_Filter::compile + * @expectedException Twig_Error_Syntax + * @expectedExceptionMessage The filter "lowe" does not exist. Did you mean "lower" at line 1 + */ + public function testCompileUnknownFilter() + { + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = $this->createFilter($expr, 'lowe', array(new Twig_Node_Expression_Constant('bar', 1), new Twig_Node_Expression_Constant('foobar', 1))); - try { - $node->compile($this->getCompiler()); - $this->fail(); - } catch (Exception $e) { - $this->assertEquals('Twig_Error_Syntax', get_class($e)); - } + $node->compile($this->getCompiler()); } public function getTests() { $tests = array(); - $expr = new Twig_Node_Expression_Constant('foo', 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); $node = $this->createFilter($expr, 'upper'); - $node = $this->createFilter($node, 'lower', array(new Twig_Node_Expression_Constant('bar', 0), new Twig_Node_Expression_Constant('foobar', 0))); + $node = $this->createFilter($node, 'number_format', array(new Twig_Node_Expression_Constant(2, 1), new Twig_Node_Expression_Constant('.', 1), new Twig_Node_Expression_Constant(',', 1))); if (function_exists('mb_get_info')) { - $tests[] = array($node, 'twig_lower_filter($this->env, twig_upper_filter($this->env, "foo"), "bar", "foobar")'); + $tests[] = array($node, 'twig_number_format_filter($this->env, twig_upper_filter($this->env, "foo"), 2, ".", ",")'); } else { - $tests[] = array($node, 'strtolower(strtoupper("foo"), "bar", "foobar")'); + $tests[] = array($node, 'twig_number_format_filter($this->env, strtoupper("foo"), 2, ".", ",")'); } return $tests; @@ -67,19 +68,19 @@ public function getTests() /** * @covers Twig_Node_Expression_Filter::compile * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage The filter "uppe" does not exist. Did you mean "upper" at line 0 + * @expectedExceptionMessage The filter "uppe" does not exist. Did you mean "upper" at line 1 */ public function testUnknownFilter() { - $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 0), 'uppe'); + $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'uppe'); $node->compile($this->getCompiler()); } protected function createFilter($node, $name, array $arguments = array()) { - $name = new Twig_Node_Expression_Constant($name, 0); + $name = new Twig_Node_Expression_Constant($name, 1); $arguments = new Twig_Node($arguments); - return new Twig_Node_Expression_Filter($node, $name, $arguments, 0); + return new Twig_Node_Expression_Filter($node, $name, $arguments, 1); } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php index 68c5c6177422..13f48232645d 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php @@ -9,9 +9,7 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_FunctionTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Function::__construct @@ -20,7 +18,7 @@ public function testConstructor() { $name = 'function'; $args = new Twig_Node(); - $node = new Twig_Node_Expression_Function($name, $args, 0); + $node = new Twig_Node_Expression_Function($name, $args, 1); $this->assertEquals($name, $node->getAttribute('name')); $this->assertEquals($args, $node->getNode('arguments')); @@ -38,7 +36,7 @@ public function testCompile($node, $source, $environment = null) /** * @covers Twig_Node_Expression_Filter::compile * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage The function "cycl" does not exist. Did you mean "cycle" at line 0 + * @expectedExceptionMessage The function "cycl" does not exist. Did you mean "cycle" at line 1 */ public function testUnknownFunction() { @@ -59,25 +57,25 @@ public function getTests() $node = $this->createFunction('foo'); $tests[] = array($node, 'foo()', $environment); - $node = $this->createFunction('foo', array(new Twig_Node_Expression_Constant('bar', 0), new Twig_Node_Expression_Constant('foobar', 0))); + $node = $this->createFunction('foo', array(new Twig_Node_Expression_Constant('bar', 1), new Twig_Node_Expression_Constant('foobar', 1))); $tests[] = array($node, 'foo("bar", "foobar")', $environment); $node = $this->createFunction('bar'); $tests[] = array($node, 'bar($this->env)', $environment); - $node = $this->createFunction('bar', array(new Twig_Node_Expression_Constant('bar', 0))); + $node = $this->createFunction('bar', array(new Twig_Node_Expression_Constant('bar', 1))); $tests[] = array($node, 'bar($this->env, "bar")', $environment); $node = $this->createFunction('foofoo'); $tests[] = array($node, 'foofoo($context)', $environment); - $node = $this->createFunction('foofoo', array(new Twig_Node_Expression_Constant('bar', 0))); + $node = $this->createFunction('foofoo', array(new Twig_Node_Expression_Constant('bar', 1))); $tests[] = array($node, 'foofoo($context, "bar")', $environment); $node = $this->createFunction('foobar'); $tests[] = array($node, 'foobar($this->env, $context)', $environment); - $node = $this->createFunction('foobar', array(new Twig_Node_Expression_Constant('bar', 0))); + $node = $this->createFunction('foobar', array(new Twig_Node_Expression_Constant('bar', 1))); $tests[] = array($node, 'foobar($this->env, $context, "bar")', $environment); return $tests; @@ -85,6 +83,6 @@ public function getTests() protected function createFunction($name, array $arguments = array()) { - return new Twig_Node_Expression_Function($name, new Twig_Node($arguments), 0); + return new Twig_Node_Expression_Function($name, new Twig_Node($arguments), 1); } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php index 6df143de622b..6a63cce655f9 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php @@ -9,21 +9,19 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_GetAttr::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Name('foo', 0); - $attr = new Twig_Node_Expression_Constant('bar', 0); - $args = new Twig_Node_Expression_Array(array(), 0); - $args->addElement(new Twig_Node_Expression_Name('foo', 0)); - $args->addElement(new Twig_Node_Expression_Constant('bar', 0)); - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 0); + $expr = new Twig_Node_Expression_Name('foo', 1); + $attr = new Twig_Node_Expression_Constant('bar', 1); + $args = new Twig_Node_Expression_Array(array(), 1); + $args->addElement(new Twig_Node_Expression_Name('foo', 1)); + $args->addElement(new Twig_Node_Expression_Constant('bar', 1)); + $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 1); $this->assertEquals($expr, $node->getNode('node')); $this->assertEquals($attr, $node->getNode('attribute')); @@ -44,19 +42,19 @@ public function getTests() { $tests = array(); - $expr = new Twig_Node_Expression_Name('foo', 0); - $attr = new Twig_Node_Expression_Constant('bar', 0); - $args = new Twig_Node_Expression_Array(array(), 0); - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ANY_CALL, 0); + $expr = new Twig_Node_Expression_Name('foo', 1); + $attr = new Twig_Node_Expression_Constant('bar', 1); + $args = new Twig_Node_Expression_Array(array(), 1); + $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ANY_CALL, 1); $tests[] = array($node, sprintf('%s%s, "bar")', $this->getAttributeGetter(), $this->getVariableGetter('foo'))); - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 0); + $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 1); $tests[] = array($node, sprintf('%s%s, "bar", array(), "array")', $this->getAttributeGetter(), $this->getVariableGetter('foo'))); - $args = new Twig_Node_Expression_Array(array(), 0); - $args->addElement(new Twig_Node_Expression_Name('foo', 0)); - $args->addElement(new Twig_Node_Expression_Constant('bar', 0)); - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::METHOD_CALL, 0); + $args = new Twig_Node_Expression_Array(array(), 1); + $args->addElement(new Twig_Node_Expression_Name('foo', 1)); + $args->addElement(new Twig_Node_Expression_Constant('bar', 1)); + $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::METHOD_CALL, 1); $tests[] = array($node, sprintf('%s%s, "bar", array(0 => %s, 1 => "bar"), "method")', $this->getAttributeGetter(), $this->getVariableGetter('foo'), $this->getVariableGetter('foo'))); return $tests; diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php index e77b432e2fa7..76d109b6241b 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php @@ -9,16 +9,14 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_NameTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Name::__construct */ public function testConstructor() { - $node = new Twig_Node_Expression_Name('foo', 0); + $node = new Twig_Node_Expression_Name('foo', 1); $this->assertEquals('foo', $node->getAttribute('name')); } @@ -34,15 +32,15 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $node = new Twig_Node_Expression_Name('foo', 0); - $self = new Twig_Node_Expression_Name('_self', 0); - $context = new Twig_Node_Expression_Name('_context', 0); + $node = new Twig_Node_Expression_Name('foo', 1); + $self = new Twig_Node_Expression_Name('_self', 1); + $context = new Twig_Node_Expression_Name('_context', 1); $env = new Twig_Environment(null, array('strict_variables' => true)); $env1 = new Twig_Environment(null, array('strict_variables' => false)); return array( - array($node, '$this->getContext($context, "foo")', $env), + version_compare(PHP_VERSION, '5.4.0') >= 0 ? array($node, '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))', $env) : array($node, '$this->getContext($context, "foo")', $env), array($node, $this->getVariableGetter('foo'), $env1), array($self, '$this'), array($context, '$context'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php index 7efbe03180b6..4d40419b1570 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php @@ -9,16 +9,14 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_ParentTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_ParentTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Parent::__construct */ public function testConstructor() { - $node = new Twig_Node_Expression_Parent('foo', 0); + $node = new Twig_Node_Expression_Parent('foo', 1); $this->assertEquals('foo', $node->getAttribute('name')); } @@ -35,7 +33,7 @@ public function testCompile($node, $source, $environment = null) public function getTests() { $tests = array(); - $tests[] = array(new Twig_Node_Expression_Parent('foo', 0), '$this->renderParentBlock("foo", $context, $blocks)'); + $tests[] = array(new Twig_Node_Expression_Parent('foo', 1), '$this->renderParentBlock("foo", $context, $blocks)'); return $tests; } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php index 08668c037294..4d0cf41c8886 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php @@ -9,19 +9,17 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../TestCase.php'; - -class Twig_Tests_Node_Expression_TestTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Test::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo', 0); - $name = new Twig_Node_Expression_Constant('null', 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $name = new Twig_Node_Expression_Constant('null', 1); $args = new Twig_Node(); - $node = new Twig_Node_Expression_Test($expr, $name, $args, 0); + $node = new Twig_Node_Expression_Test($expr, $name, $args, 1); $this->assertEquals($expr, $node->getNode('node')); $this->assertEquals($args, $node->getNode('arguments')); @@ -41,8 +39,8 @@ public function getTests() { $tests = array(); - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = new Twig_Node_Expression_Test_Null($expr, 'null', new Twig_Node(array()), 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = new Twig_Node_Expression_Test_Null($expr, 'null', new Twig_Node(array()), 1); $tests[] = array($node, '(null === "foo")'); @@ -52,16 +50,16 @@ public function getTests() /** * @covers Twig_Node_Expression_Filter::compile * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage The test "nul" does not exist. Did you mean "null" at line 0 + * @expectedExceptionMessage The test "nul" does not exist. Did you mean "null" at line 1 */ public function testUnknownTest() { - $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 0), 'nul'); + $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'nul'); $node->compile($this->getCompiler()); } protected function createTest($node, $name, array $arguments = array()) { - return new Twig_Node_Expression_Test($node, $name, new Twig_Node($arguments), 0); + return new Twig_Node_Expression_Test($node, $name, new Twig_Node($arguments), 1); } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php index 218de6eb873f..d55ab3335c6e 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Unary_NegTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Unary_NegTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Unary_Neg::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Neg($expr, 0); + $expr = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Neg($expr, 1); $this->assertEquals($expr, $node->getNode('node')); } @@ -36,8 +34,8 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $node = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Neg($node, 0); + $node = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Neg($node, 1); return array( array($node, '(-1)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php index ed6349c3655a..625c25273f39 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Unary_NotTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Unary_NotTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Unary_Not::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Not($expr, 0); + $expr = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Not($expr, 1); $this->assertEquals($expr, $node->getNode('node')); } @@ -36,8 +34,8 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $node = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Not($node, 0); + $node = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Not($node, 1); return array( array($node, '(!1)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php index 6a414bcacb8e..047a09771109 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../TestCase.php'; - -class Twig_Tests_Node_Expression_Unary_PosTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_Expression_Unary_PosTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Expression_Unary_Pos::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Pos($expr, 0); + $expr = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Pos($expr, 1); $this->assertEquals($expr, $node->getNode('node')); } @@ -36,8 +34,8 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $node = new Twig_Node_Expression_Constant(1, 0); - $node = new Twig_Node_Expression_Unary_Pos($node, 0); + $node = new Twig_Node_Expression_Constant(1, 1); + $node = new Twig_Node_Expression_Unary_Pos($node, 1); return array( array($node, '(+1)'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php index ef3be8262ce2..f1093b7592b1 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php @@ -9,22 +9,20 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_ForTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_For::__construct */ public function testConstructor() { - $keyTarget = new Twig_Node_Expression_AssignName('key', 0); - $valueTarget = new Twig_Node_Expression_AssignName('item', 0); - $seq = new Twig_Node_Expression_Name('items', 0); - $ifexpr = new Twig_Node_Expression_Constant(true, 0); - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); + $keyTarget = new Twig_Node_Expression_AssignName('key', 1); + $valueTarget = new Twig_Node_Expression_AssignName('item', 1); + $seq = new Twig_Node_Expression_Name('items', 1); + $ifexpr = new Twig_Node_Expression_Constant(true, 1); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', false); $this->assertEquals($keyTarget, $node->getNode('key_target')); @@ -35,8 +33,8 @@ public function testConstructor() $this->assertEquals($body, $node->getNode('body')->getNode('tests')->getNode(1)->getNode(0)); $this->assertEquals(null, $node->getNode('else')); - $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0); - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', false); $this->assertEquals($else, $node->getNode('else')); } @@ -54,16 +52,17 @@ public function getTests() { $tests = array(); - $keyTarget = new Twig_Node_Expression_AssignName('key', 0); - $valueTarget = new Twig_Node_Expression_AssignName('item', 0); - $seq = new Twig_Node_Expression_Name('items', 0); + $keyTarget = new Twig_Node_Expression_AssignName('key', 1); + $valueTarget = new Twig_Node_Expression_AssignName('item', 1); + $seq = new Twig_Node_Expression_Name('items', 1); $ifexpr = null; - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', false); $tests[] = array($node, <<<EOF +// line 1 \$context['_parent'] = (array) \$context; \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('items')}); foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) { @@ -75,16 +74,17 @@ public function getTests() EOF ); - $keyTarget = new Twig_Node_Expression_AssignName('k', 0); - $valueTarget = new Twig_Node_Expression_AssignName('v', 0); - $seq = new Twig_Node_Expression_Name('values', 0); + $keyTarget = new Twig_Node_Expression_AssignName('k', 1); + $valueTarget = new Twig_Node_Expression_AssignName('v', 1); + $seq = new Twig_Node_Expression_Name('values', 1); $ifexpr = null; - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', true); $tests[] = array($node, <<<EOF +// line 1 \$context['_parent'] = (array) \$context; \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')}); \$context['loop'] = array( @@ -117,16 +117,17 @@ public function getTests() EOF ); - $keyTarget = new Twig_Node_Expression_AssignName('k', 0); - $valueTarget = new Twig_Node_Expression_AssignName('v', 0); - $seq = new Twig_Node_Expression_Name('values', 0); - $ifexpr = new Twig_Node_Expression_Constant(true, 0); - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); + $keyTarget = new Twig_Node_Expression_AssignName('k', 1); + $valueTarget = new Twig_Node_Expression_AssignName('v', 1); + $seq = new Twig_Node_Expression_Name('values', 1); + $ifexpr = new Twig_Node_Expression_Constant(true, 1); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', true); $tests[] = array($node, <<<EOF +// line 1 \$context['_parent'] = (array) \$context; \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')}); \$context['loop'] = array( @@ -149,16 +150,17 @@ public function getTests() EOF ); - $keyTarget = new Twig_Node_Expression_AssignName('k', 0); - $valueTarget = new Twig_Node_Expression_AssignName('v', 0); - $seq = new Twig_Node_Expression_Name('values', 0); + $keyTarget = new Twig_Node_Expression_AssignName('k', 1); + $valueTarget = new Twig_Node_Expression_AssignName('v', 1); + $seq = new Twig_Node_Expression_Name('values', 1); $ifexpr = null; - $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0)), array(), 0); - $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0); - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 0); + $body = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1)), array(), 1); + $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1); + $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); $node->setAttribute('with_loop', true); $tests[] = array($node, <<<EOF +// line 1 \$context['_parent'] = (array) \$context; \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')}); \$context['_iterated'] = false; diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php index 04b92e761a07..92fc29dcdeea 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php @@ -9,9 +9,7 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_IfTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_IfTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_If::__construct @@ -19,17 +17,17 @@ class Twig_Tests_Node_IfTest extends Twig_Tests_Node_TestCase public function testConstructor() { $t = new Twig_Node(array( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), - ), array(), 0); + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), + ), array(), 1); $else = null; - $node = new Twig_Node_If($t, $else, 0); + $node = new Twig_Node_If($t, $else, 1); $this->assertEquals($t, $node->getNode('tests')); $this->assertEquals(null, $node->getNode('else')); - $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 0), 0); - $node = new Twig_Node_If($t, $else, 0); + $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1); + $node = new Twig_Node_If($t, $else, 1); $this->assertEquals($else, $node->getNode('else')); } @@ -47,13 +45,14 @@ public function getTests() $tests = array(); $t = new Twig_Node(array( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), - ), array(), 0); + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), + ), array(), 1); $else = null; - $node = new Twig_Node_If($t, $else, 0); + $node = new Twig_Node_If($t, $else, 1); $tests[] = array($node, <<<EOF +// line 1 if (true) { echo {$this->getVariableGetter('foo')}; } @@ -61,15 +60,16 @@ public function getTests() ); $t = new Twig_Node(array( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), - new Twig_Node_Expression_Constant(false, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 0), 0), - ), array(), 0); + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), + new Twig_Node_Expression_Constant(false, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1), + ), array(), 1); $else = null; - $node = new Twig_Node_If($t, $else, 0); + $node = new Twig_Node_If($t, $else, 1); $tests[] = array($node, <<<EOF +// line 1 if (true) { echo {$this->getVariableGetter('foo')}; } elseif (false) { @@ -79,13 +79,14 @@ public function getTests() ); $t = new Twig_Node(array( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), - ), array(), 0); - $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 0), 0); - $node = new Twig_Node_If($t, $else, 0); + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1), + ), array(), 1); + $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1); + $node = new Twig_Node_If($t, $else, 1); $tests[] = array($node, <<<EOF +// line 1 if (true) { echo {$this->getVariableGetter('foo')}; } else { diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php index 6a8919542ced..db36581aaadd 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_ImportTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_ImportTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Import::__construct */ public function testConstructor() { - $macro = new Twig_Node_Expression_Constant('foo.twig', 0); - $var = new Twig_Node_Expression_AssignName('macro', 0); - $node = new Twig_Node_Import($macro, $var, 0); + $macro = new Twig_Node_Expression_Constant('foo.twig', 1); + $var = new Twig_Node_Expression_AssignName('macro', 1); + $node = new Twig_Node_Import($macro, $var, 1); $this->assertEquals($macro, $node->getNode('expr')); $this->assertEquals($var, $node->getNode('var')); @@ -39,11 +37,15 @@ public function getTests() { $tests = array(); - $macro = new Twig_Node_Expression_Constant('foo.twig', 0); - $var = new Twig_Node_Expression_AssignName('macro', 0); - $node = new Twig_Node_Import($macro, $var, 0); + $macro = new Twig_Node_Expression_Constant('foo.twig', 1); + $var = new Twig_Node_Expression_AssignName('macro', 1); + $node = new Twig_Node_Import($macro, $var, 1); - $tests[] = array($node, '$context["macro"] = $this->env->loadTemplate("foo.twig");'); + $tests[] = array($node, <<<EOF +// line 1 +\$context["macro"] = \$this->env->loadTemplate("foo.twig"); +EOF + ); return $tests; } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php index d0683924b1fd..3b7da6e054d4 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php @@ -9,24 +9,22 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_IncludeTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_IncludeTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Include::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo.twig', 0); - $node = new Twig_Node_Include($expr, null, false, false, 0); + $expr = new Twig_Node_Expression_Constant('foo.twig', 1); + $node = new Twig_Node_Include($expr, null, false, false, 1); $this->assertEquals(null, $node->getNode('variables')); $this->assertEquals($expr, $node->getNode('expr')); $this->assertFalse($node->getAttribute('only')); - $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 0), new Twig_Node_Expression_Constant(true, 0)), 0); - $node = new Twig_Node_Include($expr, $vars, true, false, 0); + $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Constant(true, 1)), 1); + $node = new Twig_Node_Include($expr, $vars, true, false, 1); $this->assertEquals($vars, $node->getNode('variables')); $this->assertTrue($node->getAttribute('only')); } @@ -44,33 +42,47 @@ public function getTests() { $tests = array(); - $expr = new Twig_Node_Expression_Constant('foo.twig', 0); - $node = new Twig_Node_Include($expr, null, false, false, 0); - $tests[] = array($node, '$this->env->loadTemplate("foo.twig")->display($context);'); + $expr = new Twig_Node_Expression_Constant('foo.twig', 1); + $node = new Twig_Node_Include($expr, null, false, false, 1); + $tests[] = array($node, <<<EOF +// line 1 +\$this->env->loadTemplate("foo.twig")->display(\$context); +EOF + ); $expr = new Twig_Node_Expression_Conditional( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Expression_Constant('foo', 0), - new Twig_Node_Expression_Constant('foo', 0), + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Expression_Constant('foo', 1), + new Twig_Node_Expression_Constant('foo', 1), 0 ); - $node = new Twig_Node_Include($expr, null, false, false, 0); + $node = new Twig_Node_Include($expr, null, false, false, 1); $tests[] = array($node, <<<EOF +// line 1 \$template = \$this->env->resolveTemplate(((true) ? ("foo") : ("foo"))); \$template->display(\$context); EOF ); - $expr = new Twig_Node_Expression_Constant('foo.twig', 0); - $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 0), new Twig_Node_Expression_Constant(true, 0)), 0); - $node = new Twig_Node_Include($expr, $vars, false, false, 0); - $tests[] = array($node, '$this->env->loadTemplate("foo.twig")->display(array_merge($context, array("foo" => true)));'); + $expr = new Twig_Node_Expression_Constant('foo.twig', 1); + $vars = new Twig_Node_Expression_Array(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Constant(true, 1)), 1); + $node = new Twig_Node_Include($expr, $vars, false, false, 1); + $tests[] = array($node, <<<EOF +// line 1 +\$this->env->loadTemplate("foo.twig")->display(array_merge(\$context, array("foo" => true))); +EOF + ); - $node = new Twig_Node_Include($expr, $vars, true, false, 0); - $tests[] = array($node, '$this->env->loadTemplate("foo.twig")->display(array("foo" => true));'); + $node = new Twig_Node_Include($expr, $vars, true, false, 1); + $tests[] = array($node, <<<EOF +// line 1 +\$this->env->loadTemplate("foo.twig")->display(array("foo" => true)); +EOF + ); - $node = new Twig_Node_Include($expr, $vars, true, true, 0); + $node = new Twig_Node_Include($expr, $vars, true, true, 1); $tests[] = array($node, <<<EOF +// line 1 try { \$this->env->loadTemplate("foo.twig")->display(array("foo" => true)); } catch (Twig_Error_Loader \$e) { diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php index 3dd57a6d5c79..39e81315a9ce 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_MacroTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Macro::__construct */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 0)), array(), 0); - $node = new Twig_Node_Macro('foo', $body, $arguments, 0); + $body = new Twig_Node_Text('foo', 1); + $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 1)), array(), 1); + $node = new Twig_Node_Macro('foo', $body, $arguments, 1); $this->assertEquals($body, $node->getNode('body')); $this->assertEquals($arguments, $node->getNode('arguments')); @@ -38,16 +36,17 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $body = new Twig_Node_Text('foo', 0); - $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 0)), array(), 0); - $node = new Twig_Node_Macro('foo', $body, $arguments, 0); + $body = new Twig_Node_Text('foo', 1); + $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 1)), array(), 1); + $node = new Twig_Node_Macro('foo', $body, $arguments, 1); return array( array($node, <<<EOF -public function getfoo(\$foo = null) +// line 1 +public function getfoo(\$_foo = null) { \$context = \$this->env->mergeGlobals(array( - "foo" => \$foo, + "foo" => \$_foo, )); \$blocks = array(); @@ -55,13 +54,13 @@ public function getfoo(\$foo = null) ob_start(); try { echo "foo"; - } catch(Exception \$e) { + } catch (Exception \$e) { ob_end_clean(); throw \$e; } - return ob_get_clean(); + return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset()); } EOF ), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php index 592949b43b1a..9411e99e2783 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_ModuleTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Module::__construct */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $parent = new Twig_Node_Expression_Constant('layout.twig', 0); + $body = new Twig_Node_Text('foo', 1); + $parent = new Twig_Node_Expression_Constant('layout.twig', 1); $blocks = new Twig_Node(); $macros = new Twig_Node(); $traits = new Twig_Node(); @@ -55,7 +53,7 @@ public function getTests() $tests = array(); - $body = new Twig_Node_Text('foo', 0); + $body = new Twig_Node_Text('foo', 1); $extends = null; $blocks = new Twig_Node(); $macros = new Twig_Node(); @@ -81,6 +79,7 @@ public function __construct(Twig_Environment \$env) protected function doDisplay(array \$context, array \$blocks = array()) { + // line 1 echo "foo"; } @@ -91,16 +90,16 @@ public function getTemplateName() public function getDebugInfo() { - return array (); + return array ( 19 => 1,); } } EOF , $twig); - $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 0), new Twig_Node_Expression_AssignName('macro', 0), 0); + $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 1); $body = new Twig_Node(array($import)); - $extends = new Twig_Node_Expression_Constant('layout.twig', 0); + $extends = new Twig_Node_Expression_Constant('layout.twig', 1); $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename); $tests[] = array($node, <<<EOF @@ -126,6 +125,7 @@ protected function doGetParent(array \$context) protected function doDisplay(array \$context, array \$blocks = array()) { + // line 1 \$context["macro"] = \$this->env->loadTemplate("foo.twig"); \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks)); } @@ -142,7 +142,7 @@ public function isTraitable() public function getDebugInfo() { - return array (); + return array ( 24 => 1,); } } EOF @@ -150,9 +150,9 @@ public function getDebugInfo() $body = new Twig_Node(); $extends = new Twig_Node_Expression_Conditional( - new Twig_Node_Expression_Constant(true, 0), - new Twig_Node_Expression_Constant('foo', 0), - new Twig_Node_Expression_Constant('foo', 0), + new Twig_Node_Expression_Constant(true, 1), + new Twig_Node_Expression_Constant('foo', 1), + new Twig_Node_Expression_Constant('foo', 1), 0 ); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php index 168663c68354..6fe43a417e59 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_PrintTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_PrintTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Print::__construct */ public function testConstructor() { - $expr = new Twig_Node_Expression_Constant('foo', 0); - $node = new Twig_Node_Print($expr, 0); + $expr = new Twig_Node_Expression_Constant('foo', 1); + $node = new Twig_Node_Print($expr, 1); $this->assertEquals($expr, $node->getNode('expr')); } @@ -36,7 +34,7 @@ public function testCompile($node, $source, $environment = null) public function getTests() { $tests = array(); - $tests[] = array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 0), 0), 'echo "foo";'); + $tests[] = array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 1), 1), "// line 1\necho \"foo\";"); return $tests; } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php index 161087381c98..db9dbf95d2fa 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_SandboxTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_SandboxTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Sandbox::__construct */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Sandbox($body, 0); + $body = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Sandbox($body, 1); $this->assertEquals($body, $node->getNode('body')); } @@ -37,10 +35,11 @@ public function getTests() { $tests = array(); - $body = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Sandbox($body, 0); + $body = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Sandbox($body, 1); $tests[] = array($node, <<<EOF +// line 1 \$sandbox = \$this->env->getExtension('sandbox'); if (!\$alreadySandboxed = \$sandbox->isSandboxed()) { \$sandbox->enableSandbox(); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php index 2ce0584e5949..217e3408ff5c 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_SandboxedModuleTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_SandboxedModuleTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_SandboxedModule::__construct */ public function testConstructor() { - $body = new Twig_Node_Text('foo', 0); - $parent = new Twig_Node_Expression_Constant('layout.twig', 0); + $body = new Twig_Node_Text('foo', 1); + $parent = new Twig_Node_Expression_Constant('layout.twig', 1); $blocks = new Twig_Node(); $macros = new Twig_Node(); $traits = new Twig_Node(); @@ -51,7 +49,7 @@ public function getTests() $tests = array(); - $body = new Twig_Node_Text('foo', 0); + $body = new Twig_Node_Text('foo', 1); $extends = null; $blocks = new Twig_Node(); $macros = new Twig_Node(); @@ -80,10 +78,12 @@ public function __construct(Twig_Environment \$env) protected function doDisplay(array \$context, array \$blocks = array()) { \$this->checkSecurity(); + // line 1 echo "foo"; } - protected function checkSecurity() { + protected function checkSecurity() + { \$this->env->getExtension('sandbox')->checkSecurity( array('upper'), array('for'), @@ -98,14 +98,14 @@ public function getTemplateName() public function getDebugInfo() { - return array (); + return array ( 20 => 1,); } } EOF , $twig); $body = new Twig_Node(); - $extends = new Twig_Node_Expression_Constant('layout.twig', 0); + $extends = new Twig_Node_Expression_Constant('layout.twig', 1); $blocks = new Twig_Node(); $macros = new Twig_Node(); $traits = new Twig_Node(); @@ -141,7 +141,8 @@ protected function doDisplay(array \$context, array \$blocks = array()) \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks)); } - protected function checkSecurity() { + protected function checkSecurity() + { \$this->env->getExtension('sandbox')->checkSecurity( array('upper'), array('for'), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php index 85adddfa53fd..058e02bc22eb 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php @@ -9,16 +9,14 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_SandboxedPrintTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_SandboxedPrintTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_SandboxedPrint::__construct */ public function testConstructor() { - $node = new Twig_Node_SandboxedPrint($expr = new Twig_Node_Expression_Constant('foo', 0), 0); + $node = new Twig_Node_SandboxedPrint($expr = new Twig_Node_Expression_Constant('foo', 1), 1); $this->assertEquals($expr, $node->getNode('expr')); } @@ -36,7 +34,8 @@ public function getTests() { $tests = array(); - $tests[] = array(new Twig_Node_SandboxedPrint(new Twig_Node_Expression_Constant('foo', 0), 0), <<<EOF + $tests[] = array(new Twig_Node_SandboxedPrint(new Twig_Node_Expression_Constant('foo', 1), 1), <<<EOF +// line 1 echo \$this->env->getExtension('sandbox')->ensureToStringAllowed("foo"); EOF ); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php index 6319fb6bfab1..d64d671a8ee5 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php @@ -9,18 +9,16 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_SetTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_SetTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Set::__construct */ public function testConstructor() { - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0)), array(), 0); - $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 0)), array(), 0); - $node = new Twig_Node_Set(false, $names, $values, 0); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); + $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1); + $node = new Twig_Node_Set(false, $names, $values, 1); $this->assertEquals($names, $node->getNode('names')); $this->assertEquals($values, $node->getNode('values')); @@ -40,30 +38,40 @@ public function getTests() { $tests = array(); - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0)), array(), 0); - $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 0)), array(), 0); - $node = new Twig_Node_Set(false, $names, $values, 0); - $tests[] = array($node, '$context["foo"] = "foo";'); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); + $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1)), array(), 1); + $node = new Twig_Node_Set(false, $names, $values, 1); + $tests[] = array($node, <<<EOF +// line 1 +\$context["foo"] = "foo"; +EOF + ); - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0)), array(), 0); - $values = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 0), 0)), array(), 0); - $node = new Twig_Node_Set(true, $names, $values, 0); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); + $values = new Twig_Node(array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 1), 1)), array(), 1); + $node = new Twig_Node_Set(true, $names, $values, 1); $tests[] = array($node, <<<EOF +// line 1 ob_start(); echo "foo"; \$context["foo"] = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset()); EOF ); - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0)), array(), 0); - $values = new Twig_Node_Text('foo', 0); - $node = new Twig_Node_Set(true, $names, $values, 0); - $tests[] = array($node, '$context["foo"] = (\'\' === $tmp = "foo") ? \'\' : new Twig_Markup($tmp, $this->env->getCharset());'); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1); + $values = new Twig_Node_Text('foo', 1); + $node = new Twig_Node_Set(true, $names, $values, 1); + $tests[] = array($node, <<<EOF +// line 1 +\$context["foo"] = ('' === \$tmp = "foo") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset()); +EOF + ); - $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 0), new Twig_Node_Expression_AssignName('bar', 0)), array(), 0); - $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 0), new Twig_Node_Expression_Name('bar', 0)), array(), 0); - $node = new Twig_Node_Set(false, $names, $values, 0); + $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1), new Twig_Node_Expression_AssignName('bar', 1)), array(), 1); + $values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 1), new Twig_Node_Expression_Name('bar', 1)), array(), 1); + $node = new Twig_Node_Set(false, $names, $values, 1); $tests[] = array($node, <<<EOF +// line 1 list(\$context["foo"], \$context["bar"]) = array("foo", {$this->getVariableGetter('bar')}); EOF ); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php index 55892f461f6e..6735dc316dce 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php @@ -9,17 +9,15 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_SpacelessTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_SpacelessTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Spaceless::__construct */ public function testConstructor() { - $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 0))); - $node = new Twig_Node_Spaceless($body, 0); + $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1))); + $node = new Twig_Node_Spaceless($body, 1); $this->assertEquals($body, $node->getNode('body')); } @@ -35,11 +33,12 @@ public function testCompile($node, $source, $environment = null) public function getTests() { - $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 0))); - $node = new Twig_Node_Spaceless($body, 0); + $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1))); + $node = new Twig_Node_Spaceless($body, 1); return array( array($node, <<<EOF +// line 1 ob_start(); echo "<div> <div> foo </div> </div>"; echo trim(preg_replace('/>\s+</', '><', ob_get_clean())); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php index 87e0337f7231..6f85576e0f46 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php @@ -9,16 +9,14 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/TestCase.php'; - -class Twig_Tests_Node_TextTest extends Twig_Tests_Node_TestCase +class Twig_Tests_Node_TextTest extends Twig_Test_NodeTestCase { /** * @covers Twig_Node_Text::__construct */ public function testConstructor() { - $node = new Twig_Node_Text('foo', 0); + $node = new Twig_Node_Text('foo', 1); $this->assertEquals('foo', $node->getAttribute('data')); } @@ -35,7 +33,7 @@ public function testCompile($node, $source, $environment = null) public function getTests() { $tests = array(); - $tests[] = array(new Twig_Node_Text('foo', 0), 'echo "foo";'); + $tests[] = array(new Twig_Node_Text('foo', 1), "// line 1\necho \"foo\";"); return $tests; } diff --git a/core/vendor/twig/twig/test/Twig/Tests/ParserTest.php b/core/vendor/twig/twig/test/Twig/Tests/ParserTest.php index 76f257a41c4f..9c757eebe99b 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/ParserTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/ParserTest.php @@ -15,21 +15,21 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase */ public function testSetMacroThrowsExceptionOnReservedMethods() { - $parser = new Twig_Parser(new Twig_Environment()); + $parser = $this->getParser(); $parser->setMacro('display', $this->getMock('Twig_Node_Macro', array(), array(), '', null)); } /** * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown tag name "foo". Did you mean "for" at line 0 + * @expectedExceptionMessage Unknown tag name "foo". Did you mean "for" at line 1 */ public function testUnkownTag() { $stream = new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 0), - new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 0), - new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 0), - new Twig_Token(Twig_Token::EOF_TYPE, '', 0), + new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 1), + new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 1), + new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1), + new Twig_Token(Twig_Token::EOF_TYPE, '', 1), )); $parser = new Twig_Parser(new Twig_Environment()); $parser->parse($stream); @@ -40,7 +40,7 @@ public function testUnkownTag() */ public function testFilterBodyNodes($input, $expected) { - $parser = $this->getParserForFilterBodyNodes(); + $parser = $this->getParser(); $this->assertEquals($expected, $parser->filterBodyNodes($input)); } @@ -49,15 +49,15 @@ public function getFilterBodyNodesData() { return array( array( - new Twig_Node(array(new Twig_Node_Text(' ', 0))), + new Twig_Node(array(new Twig_Node_Text(' ', 1))), new Twig_Node(array()), ), array( - $input = new Twig_Node(array(new Twig_Node_Set(false, new Twig_Node(), new Twig_Node(), 0))), + $input = new Twig_Node(array(new Twig_Node_Set(false, new Twig_Node(), new Twig_Node(), 1))), $input, ), array( - $input = new Twig_Node(array(new Twig_Node_Set(true, new Twig_Node(), new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 0))))), 0))), + $input = new Twig_Node(array(new Twig_Node_Set(true, new Twig_Node(), new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 1))))), 1))), $input, ), ); @@ -69,7 +69,7 @@ public function getFilterBodyNodesData() */ public function testFilterBodyNodesThrowsException($input) { - $parser = $this->getParserForFilterBodyNodes(); + $parser = $this->getParser(); $parser->filterBodyNodes($input); } @@ -77,19 +77,19 @@ public function testFilterBodyNodesThrowsException($input) public function getFilterBodyNodesDataThrowsException() { return array( - array(new Twig_Node_Text('foo', 0)), - array(new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 0)))))), + array(new Twig_Node_Text('foo', 1)), + array(new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 1)))))), ); } /** * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed at line 0. + * @expectedExceptionMessage A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed at line 1. */ public function testFilterBodyNodesWithBOM() { - $parser = $this->getParserForFilterBodyNodes(); - $parser->filterBodyNodes(new Twig_Node_Text(chr(0xEF).chr(0xBB).chr(0xBF), 0)); + $parser = $this->getParser(); + $parser->filterBodyNodes(new Twig_Node_Text(chr(0xEF).chr(0xBB).chr(0xBF), 1)); } public function testParseIsReentrant() @@ -103,19 +103,39 @@ public function testParseIsReentrant() $parser = new Twig_Parser($twig); $parser->parse(new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 0), - new Twig_Token(Twig_Token::NAME_TYPE, 'test', 0), - new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 0), - new Twig_Token(Twig_Token::VAR_START_TYPE, '', 0), - new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 0), - new Twig_Token(Twig_Token::VAR_END_TYPE, '', 0), - new Twig_Token(Twig_Token::EOF_TYPE, '', 0), + new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 1), + new Twig_Token(Twig_Token::NAME_TYPE, 'test', 1), + new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1), + new Twig_Token(Twig_Token::VAR_START_TYPE, '', 1), + new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 1), + new Twig_Token(Twig_Token::VAR_END_TYPE, '', 1), + new Twig_Token(Twig_Token::EOF_TYPE, '', 1), ))); $this->assertEquals(null, $parser->getParent()); } - protected function getParserForFilterBodyNodes() + // The getVarName() must not depend on the template loaders, + // If this test does not throw any exception, that's good. + // see https://github.com/symfony/symfony/issues/4218 + public function testGetVarName() + { + $twig = new Twig_Environment(null, array( + 'autoescape' => false, + 'optimizations' => 0, + )); + + $twig->parse($twig->tokenize(<<<EOF +{% from _self import foo %} + +{% macro foo() %} + {{ foo }} +{% endmacro %} +EOF + )); + } + + protected function getParser() { $parser = new TestParser(new Twig_Environment()); $parser->setParent(new Twig_Node()); @@ -141,11 +161,11 @@ public function parse(Twig_Token $token) { // simulate the parsing of another template right in the middle of the parsing of the current template $this->parser->parse(new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 0), - new Twig_Token(Twig_Token::NAME_TYPE, 'extends', 0), - new Twig_Token(Twig_Token::STRING_TYPE, 'base', 0), - new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 0), - new Twig_Token(Twig_Token::EOF_TYPE, '', 0), + new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 1), + new Twig_Token(Twig_Token::NAME_TYPE, 'extends', 1), + new Twig_Token(Twig_Token::STRING_TYPE, 'base', 1), + new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1), + new Twig_Token(Twig_Token::EOF_TYPE, '', 1), ))); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); diff --git a/core/vendor/twig/twig/test/Twig/Tests/TemplateTest.php b/core/vendor/twig/twig/test/Twig/Tests/TemplateTest.php index 4213e2b654aa..75103d15d988 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/TemplateTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/TemplateTest.php @@ -11,17 +11,54 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase { /** - * @expectedException Twig_Error_Runtime - * @expectedExceptionMessage Impossible to access a key ("a") on a "string" variable + * @dataProvider getAttributeExceptions */ - public function testAttributeOnAString() + public function testGetAttributeExceptions($template, $message, $useExt) { - $template = new Twig_TemplateTest( - new Twig_Environment(null, array('strict_variables' => true)), - false + $name = 'index_'.($useExt ? 1 : 0); + $templates = array( + $name => $template.$useExt, // appending $useExt makes the template content unique ); - $template->getAttribute('string', 'a', array(), Twig_TemplateInterface::ARRAY_CALL, false); + $env = new Twig_Environment(new Twig_Loader_Array($templates), array('strict_variables' => true)); + if (!$useExt) { + $env->addNodeVisitor(new CExtDisablingNodeVisitor()); + } + $template = $env->loadTemplate($name); + + $context = array( + 'string' => 'foo', + 'array' => array('foo' => 'foo'), + 'array_access' => new Twig_TemplateArrayAccessObject(), + ); + + try { + $template->render($context); + } catch (Twig_Error_Runtime $e) { + $this->assertEquals(sprintf($message, $name), $e->getMessage()); + } + } + + public function getAttributeExceptions() + { + $tests = array( + array('{{ string["a"] }}', 'Impossible to access a key ("a") on a "string" variable in "%s" at line 1', false), + array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1', false), + array('{{ array_access["a"] }}', 'Key "a" in object (with ArrayAccess) of type "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false), + array('{{ string.a }}', 'Item "a" for "foo" does not exist in "%s" at line 1', false), + array('{{ array.a }}', 'Item "a" for "Array" does not exist in "%s" at line 1', false), + array('{{ array_access.a }}', 'Method "a" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false), + array('{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ _self.foo(array_access) }}', 'Method "missing_method" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false), + ); + + if (function_exists('twig_template_get_attributes')) { + foreach (array_slice($tests, 0) as $test) { + $test[2] = true; + $tests[] = $test; + } + } + + return $tests; } /** @@ -29,10 +66,7 @@ public function testAttributeOnAString() */ public function testGetAttribute($defined, $value, $object, $item, $arguments, $type, $useExt = false) { - $template = new Twig_TemplateTest( - new Twig_Environment(), - $useExt - ); + $template = new Twig_TemplateTest(new Twig_Environment(), $useExt); $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); } @@ -42,10 +76,7 @@ public function testGetAttribute($defined, $value, $object, $item, $arguments, $ */ public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false, $exceptionMessage = null) { - $template = new Twig_TemplateTest( - new Twig_Environment(null, array('strict_variables' => true)), - $useExt - ); + $template = new Twig_TemplateTest(new Twig_Environment(null, array('strict_variables' => true)), $useExt); if ($defined) { $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); @@ -67,10 +98,7 @@ public function testGetAttributeStrict($defined, $value, $object, $item, $argume */ public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type, $useExt = false) { - $template = new Twig_TemplateTest( - new Twig_Environment(), - $useExt - ); + $template = new Twig_TemplateTest(new Twig_Environment(), $useExt); $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true)); } @@ -80,10 +108,7 @@ public function testGetAttributeDefined($defined, $value, $object, $item, $argum */ public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false) { - $template = new Twig_TemplateTest( - new Twig_Environment(null, array('strict_variables' => true)), - $useExt - ); + $template = new Twig_TemplateTest(new Twig_Environment(null, array('strict_variables' => true)), $useExt); $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true)); } @@ -102,6 +127,7 @@ public function getGetAttributeTests() $magicPropertyObject = new Twig_TemplateMagicPropertyObject(); $propertyObject = new Twig_TemplatePropertyObject(); $propertyObject1 = new Twig_TemplatePropertyObjectAndIterator(); + $propertyObject2 = new Twig_TemplatePropertyObjectAndArrayAccess(); $methodObject = new Twig_TemplateMethodObject(); $magicMethodObject = new Twig_TemplateMagicMethodObject(); @@ -129,6 +155,7 @@ public function getGetAttributeTests() array($methodObject, $anyType), array($propertyObject, $anyType), array($propertyObject1, $anyType), + array($propertyObject2, $anyType), ); $tests = array(); @@ -194,7 +221,7 @@ public function getGetAttributeTests() // add twig_template_get_attributes tests if (function_exists('twig_template_get_attributes')) { - foreach(array_slice($tests, 0) as $test) { + foreach (array_slice($tests, 0) as $test) { $test = array_pad($test, 7, null); $test[6] = true; $tests[] = $test; @@ -203,11 +230,6 @@ public function getGetAttributeTests() return $tests; } - - public function useExtGetAttribute() - { - return false; - } } class Twig_TemplateTest extends Twig_Template @@ -318,6 +340,29 @@ public function getIterator() } } +class Twig_TemplatePropertyObjectAndArrayAccess extends Twig_TemplatePropertyObject implements ArrayAccess +{ + private $data = array(); + + public function offsetExists($offset) + { + return array_key_exists($offset, $this->data); + } + + public function offsetGet($offset) + { + return $this->offsetExists($offset) ? $this->data[$offset] : 'n/a'; + } + + public function offsetSet($offset, $value) + { + } + + public function offsetUnset($offset) + { + } +} + class Twig_TemplateMethodObject { public function getDefined() @@ -345,7 +390,7 @@ protected function getProtected() return 'protected'; } - static public function getStatic() + public static function getStatic() { return 'static'; } @@ -354,24 +399,50 @@ static public function getStatic() class Twig_TemplateMethodAndPropObject { private $a = 'a_prop'; - public function getA() { + public function getA() + { return 'a'; } public $b = 'b_prop'; - public function getB() { + public function getB() + { return 'b'; } private $c = 'c_prop'; - private function getC() { + private function getC() + { return 'c'; } } class Twig_TemplateMagicMethodObject { - public function __call($method, $arguments) { + public function __call($method, $arguments) + { return '__call_'.$method; } } + +class CExtDisablingNodeVisitor implements Twig_NodeVisitorInterface +{ + public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) + { + if ($node instanceof Twig_Node_Expression_GetAttr) { + $node->setAttribute('disable_c_ext', true); + } + + return $node; + } + + public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) + { + return $node; + } + + public function getPriority() + { + return 0; + } +} diff --git a/core/vendor/twig/twig/test/Twig/Tests/TokenStreamTest.php b/core/vendor/twig/twig/test/Twig/Tests/TokenStreamTest.php index 794a037eb8af..4edb8c31d8b0 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/TokenStreamTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/TokenStreamTest.php @@ -11,19 +11,19 @@ class Twig_Tests_TokenStreamTest extends PHPUnit_Framework_TestCase { - static protected $tokens; + protected static $tokens; public function setUp() { self::$tokens = array( - new Twig_Token(Twig_Token::TEXT_TYPE, 1, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 2, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 3, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 4, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 5, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 6, 0), - new Twig_Token(Twig_Token::TEXT_TYPE, 7, 0), - new Twig_Token(Twig_Token::EOF_TYPE, 0, 0), + new Twig_Token(Twig_Token::TEXT_TYPE, 1, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 2, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 3, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 4, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 5, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 6, 1), + new Twig_Token(Twig_Token::TEXT_TYPE, 7, 1), + new Twig_Token(Twig_Token::EOF_TYPE, 0, 1), ); } diff --git a/core/vendor/twig/twig/test/Twig/Tests/escapingTest.php b/core/vendor/twig/twig/test/Twig/Tests/escapingTest.php new file mode 100644 index 000000000000..2492b3acb98a --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/escapingTest.php @@ -0,0 +1,320 @@ +<?php + +/** + * This class is adapted from code coming from Zend Framework. + * + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ + +class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase +{ + /** + * All character encodings supported by htmlspecialchars() + */ + protected $htmlSpecialChars = array( + '\'' => ''', + '"' => '"', + '<' => '<', + '>' => '>', + '&' => '&' + ); + + protected $htmlAttrSpecialChars = array( + '\'' => ''', + /* Characters beyond ASCII value 255 to unicode escape */ + 'Ä€' => 'Ā', + /* Immune chars excluded */ + ',' => ',', + '.' => '.', + '-' => '-', + '_' => '_', + /* Basic alnums exluded */ + 'a' => 'a', + 'A' => 'A', + 'z' => 'z', + 'Z' => 'Z', + '0' => '0', + '9' => '9', + /* Basic control characters and null */ + "\r" => '
', + "\n" => '
', + "\t" => '	', + "\0" => '�', // should use Unicode replacement char + /* Encode chars as named entities where possible */ + '<' => '<', + '>' => '>', + '&' => '&', + '"' => '"', + /* Encode spaces for quoteless attribute protection */ + ' ' => ' ', + ); + + protected $jsSpecialChars = array( + /* HTML special chars - escape without exception to hex */ + '<' => '\\x3C', + '>' => '\\x3E', + '\'' => '\\x27', + '"' => '\\x22', + '&' => '\\x26', + /* Characters beyond ASCII value 255 to unicode escape */ + 'Ā' => '\\u0100', + /* Immune chars excluded */ + ',' => ',', + '.' => '.', + '_' => '_', + /* Basic alnums exluded */ + 'a' => 'a', + 'A' => 'A', + 'z' => 'z', + 'Z' => 'Z', + '0' => '0', + '9' => '9', + /* Basic control characters and null */ + "\r" => '\\x0D', + "\n" => '\\x0A', + "\t" => '\\x09', + "\0" => '\\x00', + /* Encode spaces for quoteless attribute protection */ + ' ' => '\\x20', + ); + + protected $urlSpecialChars = array( + /* HTML special chars - escape without exception to percent encoding */ + '<' => '%3C', + '>' => '%3E', + '\'' => '%27', + '"' => '%22', + '&' => '%26', + /* Characters beyond ASCII value 255 to hex sequence */ + 'Ā' => '%C4%80', + /* Punctuation and unreserved check */ + ',' => '%2C', + '.' => '.', + '_' => '_', + '-' => '-', + ':' => '%3A', + ';' => '%3B', + '!' => '%21', + /* Basic alnums excluded */ + 'a' => 'a', + 'A' => 'A', + 'z' => 'z', + 'Z' => 'Z', + '0' => '0', + '9' => '9', + /* Basic control characters and null */ + "\r" => '%0D', + "\n" => '%0A', + "\t" => '%09', + "\0" => '%00', + /* PHP quirks from the past */ + ' ' => '%20', + '~' => '~', + '+' => '%2B', + ); + + protected $cssSpecialChars = array( + /* HTML special chars - escape without exception to hex */ + '<' => '\\3C ', + '>' => '\\3E ', + '\'' => '\\27 ', + '"' => '\\22 ', + '&' => '\\26 ', + /* Characters beyond ASCII value 255 to unicode escape */ + 'Ā' => '\\100 ', + /* Immune chars excluded */ + ',' => '\\2C ', + '.' => '\\2E ', + '_' => '\\5F ', + /* Basic alnums exluded */ + 'a' => 'a', + 'A' => 'A', + 'z' => 'z', + 'Z' => 'Z', + '0' => '0', + '9' => '9', + /* Basic control characters and null */ + "\r" => '\\D ', + "\n" => '\\A ', + "\t" => '\\9 ', + "\0" => '\\0 ', + /* Encode spaces for quoteless attribute protection */ + ' ' => '\\20 ', + ); + + protected $env; + + public function setUp() + { + $this->env = new Twig_Environment(); + } + + public function testHtmlEscapingConvertsSpecialChars() + { + foreach ($this->htmlSpecialChars as $key => $value) { + $this->assertEquals($value, twig_escape_filter($this->env, $key, 'html'), 'Failed to escape: '.$key); + } + } + + public function testHtmlAttributeEscapingConvertsSpecialChars() + { + foreach ($this->htmlAttrSpecialChars as $key => $value) { + $this->assertEquals($value, twig_escape_filter($this->env, $key, 'html_attr'), 'Failed to escape: '.$key); + } + } + + public function testJavascriptEscapingConvertsSpecialChars() + { + foreach ($this->jsSpecialChars as $key => $value) { + $this->assertEquals($value, twig_escape_filter($this->env, $key, 'js'), 'Failed to escape: '.$key); + } + } + + public function testJavascriptEscapingReturnsStringIfZeroLength() + { + $this->assertEquals('', twig_escape_filter($this->env, '', 'js')); + } + + public function testJavascriptEscapingReturnsStringIfContainsOnlyDigits() + { + $this->assertEquals('123', twig_escape_filter($this->env, '123', 'js')); + } + + public function testCssEscapingConvertsSpecialChars() + { + foreach ($this->cssSpecialChars as $key => $value) { + $this->assertEquals($value, twig_escape_filter($this->env, $key, 'css'), 'Failed to escape: '.$key); + } + } + + public function testCssEscapingReturnsStringIfZeroLength() + { + $this->assertEquals('', twig_escape_filter($this->env, '', 'css')); + } + + public function testCssEscapingReturnsStringIfContainsOnlyDigits() + { + $this->assertEquals('123', twig_escape_filter($this->env, '123', 'css')); + } + + public function testUrlEscapingConvertsSpecialChars() + { + foreach ($this->urlSpecialChars as $key => $value) { + $this->assertEquals($value, twig_escape_filter($this->env, $key, 'url'), 'Failed to escape: '.$key); + } + } + + /** + * Range tests to confirm escaped range of characters is within OWASP recommendation + */ + + /** + * Only testing the first few 2 ranges on this prot. function as that's all these + * other range tests require + */ + public function testUnicodeCodepointConversionToUtf8() + { + $expected = " ~ޙ"; + $codepoints = array(0x20, 0x7e, 0x799); + $result = ''; + foreach ($codepoints as $value) { + $result .= $this->codepointToUtf8($value); + } + $this->assertEquals($expected, $result); + } + + /** + * Convert a Unicode Codepoint to a literal UTF-8 character. + * + * @param int Unicode codepoint in hex notation + * @return string UTF-8 literal string + */ + protected function codepointToUtf8($codepoint) + { + if ($codepoint < 0x80) { + return chr($codepoint); + } + if ($codepoint < 0x800) { + return chr($codepoint >> 6 & 0x3f | 0xc0) + . chr($codepoint & 0x3f | 0x80); + } + if ($codepoint < 0x10000) { + return chr($codepoint >> 12 & 0x0f | 0xe0) + . chr($codepoint >> 6 & 0x3f | 0x80) + . chr($codepoint & 0x3f | 0x80); + } + if ($codepoint < 0x110000) { + return chr($codepoint >> 18 & 0x07 | 0xf0) + . chr($codepoint >> 12 & 0x3f | 0x80) + . chr($codepoint >> 6 & 0x3f | 0x80) + . chr($codepoint & 0x3f | 0x80); + } + throw new Exception('Codepoint requested outside of Unicode range'); + } + + public function testJavascriptEscapingEscapesOwaspRecommendedRanges() + { + $immune = array(',', '.', '_'); // Exceptions to escaping ranges + for ($chr=0; $chr < 0xFF; $chr++) { + if ($chr >= 0x30 && $chr <= 0x39 + || $chr >= 0x41 && $chr <= 0x5A + || $chr >= 0x61 && $chr <= 0x7A) { + $literal = $this->codepointToUtf8($chr); + $this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'js')); + } else { + $literal = $this->codepointToUtf8($chr); + if (in_array($literal, $immune)) { + $this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'js')); + } else { + $this->assertNotEquals( + $literal, + twig_escape_filter($this->env, $literal, 'js'), + "$literal should be escaped!"); + } + } + } + } + + public function testHtmlAttributeEscapingEscapesOwaspRecommendedRanges() + { + $immune = array(',', '.', '-', '_'); // Exceptions to escaping ranges + for ($chr=0; $chr < 0xFF; $chr++) { + if ($chr >= 0x30 && $chr <= 0x39 + || $chr >= 0x41 && $chr <= 0x5A + || $chr >= 0x61 && $chr <= 0x7A) { + $literal = $this->codepointToUtf8($chr); + $this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'html_attr')); + } else { + $literal = $this->codepointToUtf8($chr); + if (in_array($literal, $immune)) { + $this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'html_attr')); + } else { + $this->assertNotEquals( + $literal, + twig_escape_filter($this->env, $literal, 'html_attr'), + "$literal should be escaped!"); + } + } + } + } + + public function testCssEscapingEscapesOwaspRecommendedRanges() + { + $immune = array(); // CSS has no exceptions to escaping ranges + for ($chr=0; $chr < 0xFF; $chr++) { + if ($chr >= 0x30 && $chr <= 0x39 + || $chr >= 0x41 && $chr <= 0x5A + || $chr >= 0x61 && $chr <= 0x7A) { + $literal = $this->codepointToUtf8($chr); + $this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'css')); + } else { + $literal = $this->codepointToUtf8($chr); + $this->assertNotEquals( + $literal, + twig_escape_filter($this->env, $literal, 'css'), + "$literal should be escaped!"); + } + } + } +} diff --git a/core/vendor/twig/twig/test/Twig/Tests/integrationTest.php b/core/vendor/twig/twig/test/Twig/Tests/integrationTest.php index b905b56c5c57..3b053cdc8411 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/integrationTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/integrationTest.php @@ -16,128 +16,23 @@ function html() return 'foo'; } -class Twig_Tests_IntegrationTest extends PHPUnit_Framework_TestCase +class Twig_Tests_IntegrationTest extends Twig_Test_IntegrationTestCase { - public function getTests() + public function getExtensions() { - $fixturesDir = realpath(dirname(__FILE__).'/Fixtures/'); - $tests = array(); - - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - if (!preg_match('/\.test$/', $file)) { - continue; - } - - $test = file_get_contents($file->getRealpath()); - - if (preg_match('/ - --TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*))+)\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) { - $message = $match[1]; - $condition = $match[2]; - $templates = $this->parseTemplates($match[3]); - $exception = $match[4]; - $outputs = array(null, array(), null, ''); - } elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) { - $message = $match[1]; - $condition = $match[2]; - $templates = $this->parseTemplates($match[3]); - $exception = false; - preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER); - } else { - throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file))); - } - - $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs); - } - - return $tests; - } + $policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(), array(), array()); - /** - * @dataProvider getTests - */ - public function testIntegration($file, $message, $condition, $templates, $exception, $outputs) - { - if ($condition) { - eval('$ret = '.$condition.';'); - if (!$ret) { - $this->markTestSkipped($condition); - } - } - - $loader = new Twig_Loader_Array($templates); - - foreach ($outputs as $match) { - $config = array_merge(array( - 'cache' => false, - 'strict_variables' => true, - ), $match[2] ? eval($match[2].';') : array()); - $twig = new Twig_Environment($loader, $config); - $twig->addExtension(new TestExtension()); - $twig->addExtension(new Twig_Extension_Debug()); - $policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(), array(), array()); - $twig->addExtension(new Twig_Extension_Sandbox($policy, false)); - $twig->addGlobal('global', 'global'); - - try { - $template = $twig->loadTemplate('index.twig'); - } catch (Exception $e) { - if (false !== $exception) { - $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage()))); - - return; - } - - if ($e instanceof Twig_Error_Syntax) { - $e->setTemplateFile($file); - - throw $e; - } - - throw new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e); - } - - try { - $output = trim($template->render(eval($match[1].';')), "\n "); - } catch (Exception $e) { - if (false !== $exception) { - $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage()))); - - return; - } - - if ($e instanceof Twig_Error_Syntax) { - $e->setTemplateFile($file); - } else { - $e = new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e); - } - - $output = trim(sprintf('%s: %s', get_class($e), $e->getMessage())); - } - $expected = trim($match[3], "\n "); - - if ($expected != $output) { - echo 'Compiled template that failed:'; - - foreach (array_keys($templates) as $name) { - echo "Template: $name\n"; - $source = $loader->getSource($name); - echo $twig->compile($twig->parse($twig->tokenize($source, $name))); - } - } - $this->assertEquals($expected, $output, $message.' (in '.$file.')'); - } + return array( + new Twig_Extension_Debug(), + new Twig_Extension_Sandbox($policy, false), + new Twig_Extension_StringLoader(), + new TwigTestExtension(), + ); } - protected function parseTemplates($test) + public function getFixturesDir() { - $templates = array(); - preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER); - foreach ($matches as $match) { - $templates[($match[1] ? $match[1] : 'index.twig')] = $match[2]; - } - - return $templates; + return dirname(__FILE__).'/Fixtures/'; } } @@ -146,7 +41,7 @@ function test_foo($value = 'foo') return $value; } -class Foo implements Iterator +class TwigTestFoo implements Iterator { const BAR_NAME = 'bar'; @@ -214,7 +109,7 @@ public function valid() } } -class TestTokenParser_☃ extends Twig_TokenParser +class TwigTestTokenParser_☃ extends Twig_TokenParser { public function parse(Twig_Token $token) { @@ -229,12 +124,12 @@ public function getTag() } } -class TestExtension extends Twig_Extension +class TwigTestExtension extends Twig_Extension { public function getTokenParsers() { return array( - new TestTokenParser_☃(), + new TwigTestTokenParser_☃(), ); } -- GitLab